提交 35a3c076 编写于 作者: fxy060608's avatar fxy060608

wip(app): uni-app-vite

上级 2c89f5a1
......@@ -24,16 +24,16 @@ declare namespace UniApp {
interface UniConfig {
ready?: boolean
router: {
router?: {
strict: boolean
base: string
}
nvue: {
nvue?: {
'flex-direction': 'column' | 'row'
}
globalStyle: {
navigationBar: PageNavigationBar
refreshOptions?: PageRefreshOptions
pullToRefresh?: PageRefreshOptions
maxWidth?: number
rpxCalcMaxDeviceWidth?: number
rpxCalcBaseDeviceWidth?: number
......@@ -125,12 +125,12 @@ declare namespace UniApp {
coverage?: string
}
interface PageRefreshOptions {
support: boolean
color: string
style: 'circle' | string
height: number
range: number
offset: number
support?: boolean
color?: string
style?: 'circle' | string
height?: number
range?: number
offset?: number
}
interface PagesJsonPagePlatformStyle {
......@@ -149,7 +149,7 @@ declare namespace UniApp {
disableScroll?: boolean
enablePullDownRefresh?: boolean
navigationBar: PageNavigationBar
refreshOptions?: PageRefreshOptions
pullToRefresh?: PageRefreshOptions
onReachBottomDistance?: number
pageOrientation?: 'auto' | 'portrait' | 'landscape'
backgroundColor?: string
......
// Jest Snapshot v1, https://goo.gl/fbAQLP
exports[`webviewStyle basic 1`] = `
Object {
"bounce": "vertical",
"titleNView": Object {
"autoBackButton": true,
},
}
`;
import { parseWebviewStyle } from '../src/service/framework/page/webview/style'
function initDefaultUniConfig() {
return JSON.parse(
JSON.stringify({
globalStyle: {
navigationBar: {},
},
})
)
}
beforeAll(() => {
global.__uniConfig = initDefaultUniConfig()
})
const defaultPath = '/pages/index/index'
const defaultRoute = 'pages/index/index'
describe('webviewStyle', () => {
test('basic', () => {
expect(
parseWebviewStyle(1, defaultPath, {
path: defaultPath,
meta: {
route: defaultRoute,
navigationBar: {},
},
})
).toMatchSnapshot()
})
})
......@@ -112,7 +112,32 @@ var serviceContext = (function () {
const DATA_RE = /^data:.*,.*/;
const WEB_INVOKE_APPSERVICE = 'WEB_INVOKE_APPSERVICE';
const PAGE_META_KEYS = ['navigationBar', 'refreshOptions'];
function hasRpx(str) {
return str.indexOf('rpx') !== -1 || str.indexOf('upx') !== -1;
}
function rpx2px(str, replace = false) {
if (replace) {
return rpx2pxWithReplace(str);
}
if (typeof str === 'string') {
const res = parseInt(str) || 0;
if (hasRpx(str)) {
return uni.upx2px(res);
}
return res;
}
return str;
}
function rpx2pxWithReplace(str) {
if (!hasRpx(str)) {
return str;
}
return str.replace(/(\d+(\.\d+)?)[ru]px/g, (_a, b) => {
return uni.upx2px(parseFloat(b)) + 'px';
});
}
const PAGE_META_KEYS = ['navigationBar', 'pullToRefresh'];
function initGlobalStyle() {
return JSON.parse(JSON.stringify(__uniConfig.globalStyle || {}));
}
......@@ -123,6 +148,18 @@ var serviceContext = (function () {
res[name] = extend({}, globalStyle[name], pageMeta[name]);
});
return res;
}
function normalizePullToRefreshRpx(pullToRefresh) {
if (pullToRefresh.offset) {
pullToRefresh.offset = rpx2px(pullToRefresh.offset);
}
if (pullToRefresh.height) {
pullToRefresh.height = rpx2px(pullToRefresh.height);
}
if (pullToRefresh.range) {
pullToRefresh.range = rpx2px(pullToRefresh.range);
}
return pullToRefresh;
}
function getRealRoute(fromRoute, toRoute) {
......@@ -585,9 +622,9 @@ var serviceContext = (function () {
if (!routeMeta.enablePullDownRefresh) {
return;
}
webviewStyle.pullToRefresh = extend({}, plus.os.name === 'Android'
webviewStyle.pullToRefresh = normalizePullToRefreshRpx(extend({}, plus.os.name === 'Android'
? defaultAndroidPullToRefresh
: defaultPullToRefresh, routeMeta.refreshOptions);
: defaultPullToRefresh, routeMeta.pullToRefresh));
}
const defaultAndroidPullToRefresh = { support: true, style: 'circle' };
const defaultPullToRefresh = {
......@@ -693,7 +730,7 @@ var serviceContext = (function () {
'disableScroll',
'enablePullDownRefresh',
'navigationBar',
'refreshOptions',
'pullToRefresh',
'onReachBottomDistance',
'pageOrientation',
'backgroundColor',
......
......@@ -48,7 +48,7 @@ const WEBVIEW_STYLE_BLACKLIST = [
'disableScroll',
'enablePullDownRefresh',
'navigationBar',
'refreshOptions',
'pullToRefresh',
'onReachBottomDistance',
'pageOrientation',
'backgroundColor',
......
import { normalizePullToRefreshRpx } from '@dcloudio/uni-core'
import { extend } from '@vue/shared'
export function initPullToRefresh(
......@@ -7,12 +8,14 @@ export function initPullToRefresh(
if (!routeMeta.enablePullDownRefresh) {
return
}
webviewStyle.pullToRefresh = extend(
{},
plus.os.name === 'Android'
? defaultAndroidPullToRefresh
: defaultPullToRefresh,
routeMeta.refreshOptions
webviewStyle.pullToRefresh = normalizePullToRefreshRpx(
extend(
{},
plus.os.name === 'Android'
? defaultAndroidPullToRefresh
: defaultPullToRefresh,
routeMeta.pullToRefresh
)
) as unknown as PlusWebviewWebviewPullToRefreshStyles
}
......
......@@ -11,7 +11,7 @@ function uniCopyPlugin() {
return uni_cli_shared_1.uniViteCopyPlugin({
targets: [
{
src: slash_1.default(path_1.default.resolve(__dirname, '../../lib/template/')),
src: slash_1.default(path_1.default.resolve(__dirname, '../../lib/template/*')),
dest: process.env.UNI_OUTPUT_DIR,
},
{
......
......@@ -7,7 +7,7 @@ export function uniCopyPlugin() {
return uniViteCopyPlugin({
targets: [
{
src: slash(path.resolve(__dirname, '../../lib/template/')),
src: slash(path.resolve(__dirname, '../../lib/template/*')),
dest: process.env.UNI_OUTPUT_DIR,
},
{
......
......@@ -106,7 +106,7 @@ function normalizePageStyle(
pageStyle.navigationBar = normalizeNavigationBar(pageStyle)
if (isEnablePullDownRefresh(pageStyle)) {
pageStyle.enablePullDownRefresh = true
pageStyle.refreshOptions = normalizePullToRefresh(pageStyle)
pageStyle.pullToRefresh = normalizePullToRefresh(pageStyle)
}
}
return removePlatformStyle(pageStyle)
......
// Jest Snapshot v1, https://goo.gl/fbAQLP
exports[`page mergePageMeta 1`] = `
Object {
"id": 1,
"navigationBar": Object {
"titleText": "uni-app",
},
"pullToRefresh": Object {},
"route": "",
}
`;
exports[`page mergePageMeta 2`] = `
Object {
"enablePullDownRefresh": true,
"id": 1,
"navigationBar": Object {
"titleColor": "#000000",
"titleText": "hello",
},
"pullToRefresh": Object {},
"route": "",
}
`;
exports[`page mergePageMeta 3`] = `
Object {
"enablePullDownRefresh": true,
"id": 1,
"navigationBar": Object {
"titleColor": "#000000",
"titleText": "uni-app",
},
"pullToRefresh": Object {
"offset": 100,
},
"route": "",
}
`;
import { mergePageMeta } from '../../src/helpers/page'
function initDefaultUniConfig() {
return JSON.parse(
JSON.stringify({
globalStyle: {
navigationBar: {},
},
})
)
}
describe('page', () => {
test('mergePageMeta', () => {
global.__uniConfig = initDefaultUniConfig()
global.__uniConfig.globalStyle.navigationBar.titleText = 'uni-app'
expect(
mergePageMeta(1, {
route: '',
navigationBar: {},
})
).toMatchSnapshot()
expect(
mergePageMeta(1, {
route: '',
navigationBar: { titleText: 'hello', titleColor: '#000000' },
enablePullDownRefresh: true,
})
).toMatchSnapshot()
expect(
mergePageMeta(1, {
route: '',
navigationBar: { titleColor: '#000000' },
enablePullDownRefresh: true,
pullToRefresh: {
offset: 100,
},
})
).toMatchSnapshot()
})
})
import { extend } from '@vue/shared'
import { ComponentPublicInstance, getCurrentInstance } from 'vue'
import { rpx2px } from './util'
export function useCurrentPageId() {
return getCurrentInstance()!.root.proxy!.$page.id
......@@ -15,7 +16,7 @@ export function getPageIdByVm(vm: ComponentPublicInstance) {
}
}
const PAGE_META_KEYS = ['navigationBar', 'refreshOptions'] as const
const PAGE_META_KEYS = ['navigationBar', 'pullToRefresh'] as const
function initGlobalStyle() {
return JSON.parse(JSON.stringify(__uniConfig.globalStyle || {}))
......@@ -32,3 +33,18 @@ export function mergePageMeta(
})
return res
}
export function normalizePullToRefreshRpx(
pullToRefresh: UniApp.PageRefreshOptions
) {
if (pullToRefresh.offset) {
pullToRefresh.offset = rpx2px(pullToRefresh.offset)
}
if (pullToRefresh.height) {
pullToRefresh.height = rpx2px(pullToRefresh.height)
}
if (pullToRefresh.range) {
pullToRefresh.range = rpx2px(pullToRefresh.range)
}
return pullToRefresh
}
......@@ -9,7 +9,7 @@ import {
LOCALE_ZH_HANT,
} from '@dcloudio/uni-i18n'
import { useI18n } from './useI18n'
const i18n = /*#__PURE__*/ useI18n()
function normalizeMessages(
namespace: string,
messages: Record<string, string>
......@@ -22,19 +22,19 @@ function normalizeMessages(
export const initI18nAppMsgsOnce = /*#__PURE__*/ once(() => {
const name = 'uni.app.'
if (__UNI_FEATURE_I18N_EN__) {
i18n.add(
useI18n().add(
LOCALE_EN,
normalizeMessages(name, { quit: 'Press back button again to exit' })
)
}
if (__UNI_FEATURE_I18N_ES__) {
i18n.add(
useI18n().add(
LOCALE_ES,
normalizeMessages(name, { quit: 'Pulse otra vez para salir' })
)
}
if (__UNI_FEATURE_I18N_FR__) {
i18n.add(
useI18n().add(
LOCALE_FR,
normalizeMessages(name, {
quit: "Appuyez à nouveau pour quitter l'application",
......@@ -42,13 +42,13 @@ export const initI18nAppMsgsOnce = /*#__PURE__*/ once(() => {
)
}
if (__UNI_FEATURE_I18N_ZH_HANS__) {
i18n.add(
useI18n().add(
LOCALE_ZH_HANS,
normalizeMessages(name, { quit: '再按一次退出应用' })
)
}
if (__UNI_FEATURE_I18N_ZH_HANT__) {
i18n.add(
useI18n().add(
LOCALE_ZH_HANT,
normalizeMessages(name, { quit: '再按一次退出應用' })
)
......@@ -57,7 +57,7 @@ export const initI18nAppMsgsOnce = /*#__PURE__*/ once(() => {
export const initI18nAsyncMsgsOnce = /*#__PURE__*/ once(() => {
const name = 'uni.async.'
if (__UNI_FEATURE_I18N_EN__) {
i18n.add(
useI18n().add(
LOCALE_EN,
normalizeMessages(name, {
error: 'The connection timed out, click the screen to try again.',
......@@ -65,7 +65,7 @@ export const initI18nAsyncMsgsOnce = /*#__PURE__*/ once(() => {
)
}
if (__UNI_FEATURE_I18N_ES__) {
i18n.add(
useI18n().add(
LOCALE_ES,
normalizeMessages(name, {
error:
......@@ -74,7 +74,7 @@ export const initI18nAsyncMsgsOnce = /*#__PURE__*/ once(() => {
)
}
if (__UNI_FEATURE_I18N_FR__) {
i18n.add(
useI18n().add(
LOCALE_FR,
normalizeMessages(name, {
error: "La connexion a expiré, cliquez sur l'écran pour réessayer.",
......@@ -82,13 +82,13 @@ export const initI18nAsyncMsgsOnce = /*#__PURE__*/ once(() => {
)
}
if (__UNI_FEATURE_I18N_ZH_HANS__) {
i18n.add(
useI18n().add(
LOCALE_ZH_HANS,
normalizeMessages(name, { error: '连接服务器超时,点击屏幕重试' })
)
}
if (__UNI_FEATURE_I18N_ZH_HANT__) {
i18n.add(
useI18n().add(
LOCALE_ZH_HANT,
normalizeMessages(name, { error: '連接服務器超時,點擊屏幕重試' })
)
......@@ -97,25 +97,25 @@ export const initI18nAsyncMsgsOnce = /*#__PURE__*/ once(() => {
export const initI18nShowActionSheetMsgsOnce = /*#__PURE__*/ once(() => {
const name = 'uni.showActionSheet.'
if (__UNI_FEATURE_I18N_EN__) {
i18n.add(LOCALE_EN, normalizeMessages(name, { cancel: 'Cancel' }))
useI18n().add(LOCALE_EN, normalizeMessages(name, { cancel: 'Cancel' }))
}
if (__UNI_FEATURE_I18N_ES__) {
i18n.add(LOCALE_ES, normalizeMessages(name, { cancel: 'Cancelar' }))
useI18n().add(LOCALE_ES, normalizeMessages(name, { cancel: 'Cancelar' }))
}
if (__UNI_FEATURE_I18N_FR__) {
i18n.add(LOCALE_FR, normalizeMessages(name, { cancel: 'Annuler' }))
useI18n().add(LOCALE_FR, normalizeMessages(name, { cancel: 'Annuler' }))
}
if (__UNI_FEATURE_I18N_ZH_HANS__) {
i18n.add(LOCALE_ZH_HANS, normalizeMessages(name, { cancel: '取消' }))
useI18n().add(LOCALE_ZH_HANS, normalizeMessages(name, { cancel: '取消' }))
}
if (__UNI_FEATURE_I18N_ZH_HANT__) {
i18n.add(LOCALE_ZH_HANT, normalizeMessages(name, { cancel: '取消' }))
useI18n().add(LOCALE_ZH_HANT, normalizeMessages(name, { cancel: '取消' }))
}
})
export const initI18nShowToastMsgsOnce = /*#__PURE__*/ once(() => {
const name = 'uni.showToast.'
if (__UNI_FEATURE_I18N_EN__) {
i18n.add(
useI18n().add(
LOCALE_EN,
normalizeMessages(name, {
unpaired: 'Please note showToast must be paired with hideToast',
......@@ -123,7 +123,7 @@ export const initI18nShowToastMsgsOnce = /*#__PURE__*/ once(() => {
)
}
if (__UNI_FEATURE_I18N_ES__) {
i18n.add(
useI18n().add(
LOCALE_ES,
normalizeMessages(name, {
unpaired:
......@@ -132,7 +132,7 @@ export const initI18nShowToastMsgsOnce = /*#__PURE__*/ once(() => {
)
}
if (__UNI_FEATURE_I18N_FR__) {
i18n.add(
useI18n().add(
LOCALE_FR,
normalizeMessages(name, {
unpaired: 'Veuillez noter que showToast doit être associé à hideToast',
......@@ -140,7 +140,7 @@ export const initI18nShowToastMsgsOnce = /*#__PURE__*/ once(() => {
)
}
if (__UNI_FEATURE_I18N_ZH_HANS__) {
i18n.add(
useI18n().add(
LOCALE_ZH_HANS,
normalizeMessages(name, {
unpaired: '请注意 showToast 与 hideToast 必须配对使用',
......@@ -148,7 +148,7 @@ export const initI18nShowToastMsgsOnce = /*#__PURE__*/ once(() => {
)
}
if (__UNI_FEATURE_I18N_ZH_HANT__) {
i18n.add(
useI18n().add(
LOCALE_ZH_HANT,
normalizeMessages(name, {
unpaired: '請注意 showToast 與 hideToast 必須配對使用',
......@@ -159,7 +159,7 @@ export const initI18nShowToastMsgsOnce = /*#__PURE__*/ once(() => {
export const initI18nShowLoadingMsgsOnce = /*#__PURE__*/ once(() => {
const name = 'uni.showLoading.'
if (__UNI_FEATURE_I18N_EN__) {
i18n.add(
useI18n().add(
LOCALE_EN,
normalizeMessages(name, {
unpaired: 'Please note showLoading must be paired with hideLoading',
......@@ -167,7 +167,7 @@ export const initI18nShowLoadingMsgsOnce = /*#__PURE__*/ once(() => {
)
}
if (__UNI_FEATURE_I18N_ES__) {
i18n.add(
useI18n().add(
LOCALE_ES,
normalizeMessages(name, {
unpaired:
......@@ -176,7 +176,7 @@ export const initI18nShowLoadingMsgsOnce = /*#__PURE__*/ once(() => {
)
}
if (__UNI_FEATURE_I18N_FR__) {
i18n.add(
useI18n().add(
LOCALE_FR,
normalizeMessages(name, {
unpaired:
......@@ -185,7 +185,7 @@ export const initI18nShowLoadingMsgsOnce = /*#__PURE__*/ once(() => {
)
}
if (__UNI_FEATURE_I18N_ZH_HANS__) {
i18n.add(
useI18n().add(
LOCALE_ZH_HANS,
normalizeMessages(name, {
unpaired: '请注意 showLoading 与 hideLoading 必须配对使用',
......@@ -193,7 +193,7 @@ export const initI18nShowLoadingMsgsOnce = /*#__PURE__*/ once(() => {
)
}
if (__UNI_FEATURE_I18N_ZH_HANT__) {
i18n.add(
useI18n().add(
LOCALE_ZH_HANT,
normalizeMessages(name, {
unpaired: '請注意 showLoading 與 hideLoading 必須配對使用',
......@@ -204,31 +204,31 @@ export const initI18nShowLoadingMsgsOnce = /*#__PURE__*/ once(() => {
export const initI18nShowModalMsgsOnce = /*#__PURE__*/ once(() => {
const name = 'uni.showModal.'
if (__UNI_FEATURE_I18N_EN__) {
i18n.add(
useI18n().add(
LOCALE_EN,
normalizeMessages(name, { cancel: 'Cancel', confirm: 'OK' })
)
}
if (__UNI_FEATURE_I18N_ES__) {
i18n.add(
useI18n().add(
LOCALE_ES,
normalizeMessages(name, { cancel: 'Cancelar', confirm: 'OK' })
)
}
if (__UNI_FEATURE_I18N_FR__) {
i18n.add(
useI18n().add(
LOCALE_FR,
normalizeMessages(name, { cancel: 'Annuler', confirm: 'OK' })
)
}
if (__UNI_FEATURE_I18N_ZH_HANS__) {
i18n.add(
useI18n().add(
LOCALE_ZH_HANS,
normalizeMessages(name, { cancel: '取消', confirm: '确定' })
)
}
if (__UNI_FEATURE_I18N_ZH_HANT__) {
i18n.add(
useI18n().add(
LOCALE_ZH_HANT,
normalizeMessages(name, { cancel: '取消', confirm: '確定' })
)
......@@ -237,7 +237,7 @@ export const initI18nShowModalMsgsOnce = /*#__PURE__*/ once(() => {
export const initI18nChooseImageMsgsOnce = /*#__PURE__*/ once(() => {
const name = 'uni.chooseImage.'
if (__UNI_FEATURE_I18N_EN__) {
i18n.add(
useI18n().add(
LOCALE_EN,
normalizeMessages(name, {
cancel: 'Cancel',
......@@ -247,7 +247,7 @@ export const initI18nChooseImageMsgsOnce = /*#__PURE__*/ once(() => {
)
}
if (__UNI_FEATURE_I18N_ES__) {
i18n.add(
useI18n().add(
LOCALE_ES,
normalizeMessages(name, {
cancel: 'Cancelar',
......@@ -257,7 +257,7 @@ export const initI18nChooseImageMsgsOnce = /*#__PURE__*/ once(() => {
)
}
if (__UNI_FEATURE_I18N_FR__) {
i18n.add(
useI18n().add(
LOCALE_FR,
normalizeMessages(name, {
cancel: 'Annuler',
......@@ -267,7 +267,7 @@ export const initI18nChooseImageMsgsOnce = /*#__PURE__*/ once(() => {
)
}
if (__UNI_FEATURE_I18N_ZH_HANS__) {
i18n.add(
useI18n().add(
LOCALE_ZH_HANS,
normalizeMessages(name, {
cancel: '取消',
......@@ -277,7 +277,7 @@ export const initI18nChooseImageMsgsOnce = /*#__PURE__*/ once(() => {
)
}
if (__UNI_FEATURE_I18N_ZH_HANT__) {
i18n.add(
useI18n().add(
LOCALE_ZH_HANT,
normalizeMessages(name, {
cancel: '取消',
......@@ -290,7 +290,7 @@ export const initI18nChooseImageMsgsOnce = /*#__PURE__*/ once(() => {
export const initI18nChooseVideoMsgsOnce = /*#__PURE__*/ once(() => {
const name = 'uni.chooseVideo.'
if (__UNI_FEATURE_I18N_EN__) {
i18n.add(
useI18n().add(
LOCALE_EN,
normalizeMessages(name, {
cancel: 'Cancel',
......@@ -300,7 +300,7 @@ export const initI18nChooseVideoMsgsOnce = /*#__PURE__*/ once(() => {
)
}
if (__UNI_FEATURE_I18N_ES__) {
i18n.add(
useI18n().add(
LOCALE_ES,
normalizeMessages(name, {
cancel: 'Cancelar',
......@@ -310,7 +310,7 @@ export const initI18nChooseVideoMsgsOnce = /*#__PURE__*/ once(() => {
)
}
if (__UNI_FEATURE_I18N_FR__) {
i18n.add(
useI18n().add(
LOCALE_FR,
normalizeMessages(name, {
cancel: 'Annuler',
......@@ -320,7 +320,7 @@ export const initI18nChooseVideoMsgsOnce = /*#__PURE__*/ once(() => {
)
}
if (__UNI_FEATURE_I18N_ZH_HANS__) {
i18n.add(
useI18n().add(
LOCALE_ZH_HANS,
normalizeMessages(name, {
cancel: '取消',
......@@ -330,7 +330,7 @@ export const initI18nChooseVideoMsgsOnce = /*#__PURE__*/ once(() => {
)
}
if (__UNI_FEATURE_I18N_ZH_HANT__) {
i18n.add(
useI18n().add(
LOCALE_ZH_HANT,
normalizeMessages(name, {
cancel: '取消',
......@@ -343,7 +343,7 @@ export const initI18nChooseVideoMsgsOnce = /*#__PURE__*/ once(() => {
export const initI18nPreviewImageMsgsOnce = /*#__PURE__*/ once(() => {
const name = 'uni.previewImage.'
if (__UNI_FEATURE_I18N_EN__) {
i18n.add(
useI18n().add(
LOCALE_EN,
normalizeMessages(name, {
cancel: 'Cancel',
......@@ -354,7 +354,7 @@ export const initI18nPreviewImageMsgsOnce = /*#__PURE__*/ once(() => {
)
}
if (__UNI_FEATURE_I18N_ES__) {
i18n.add(
useI18n().add(
LOCALE_ES,
normalizeMessages(name, {
cancel: 'Cancelar',
......@@ -365,7 +365,7 @@ export const initI18nPreviewImageMsgsOnce = /*#__PURE__*/ once(() => {
)
}
if (__UNI_FEATURE_I18N_FR__) {
i18n.add(
useI18n().add(
LOCALE_FR,
normalizeMessages(name, {
cancel: 'Annuler',
......@@ -376,7 +376,7 @@ export const initI18nPreviewImageMsgsOnce = /*#__PURE__*/ once(() => {
)
}
if (__UNI_FEATURE_I18N_ZH_HANS__) {
i18n.add(
useI18n().add(
LOCALE_ZH_HANS,
normalizeMessages(name, {
cancel: '取消',
......@@ -387,7 +387,7 @@ export const initI18nPreviewImageMsgsOnce = /*#__PURE__*/ once(() => {
)
}
if (__UNI_FEATURE_I18N_ZH_HANT__) {
i18n.add(
useI18n().add(
LOCALE_ZH_HANT,
normalizeMessages(name, {
cancel: '取消',
......@@ -401,28 +401,40 @@ export const initI18nPreviewImageMsgsOnce = /*#__PURE__*/ once(() => {
export const initI18nSetClipboardDataMsgsOnce = /*#__PURE__*/ once(() => {
const name = 'uni.setClipboardData.'
if (__UNI_FEATURE_I18N_EN__) {
i18n.add(LOCALE_EN, normalizeMessages(name, { success: 'Content copied' }))
useI18n().add(
LOCALE_EN,
normalizeMessages(name, { success: 'Content copied' })
)
}
if (__UNI_FEATURE_I18N_ES__) {
i18n.add(
useI18n().add(
LOCALE_ES,
normalizeMessages(name, { success: 'Contenido copiado' })
)
}
if (__UNI_FEATURE_I18N_FR__) {
i18n.add(LOCALE_FR, normalizeMessages(name, { success: 'Contenu copié' }))
useI18n().add(
LOCALE_FR,
normalizeMessages(name, { success: 'Contenu copié' })
)
}
if (__UNI_FEATURE_I18N_ZH_HANS__) {
i18n.add(LOCALE_ZH_HANS, normalizeMessages(name, { success: '内容已复制' }))
useI18n().add(
LOCALE_ZH_HANS,
normalizeMessages(name, { success: '内容已复制' })
)
}
if (__UNI_FEATURE_I18N_ZH_HANT__) {
i18n.add(LOCALE_ZH_HANT, normalizeMessages(name, { success: '內容已復制' }))
useI18n().add(
LOCALE_ZH_HANT,
normalizeMessages(name, { success: '內容已復制' })
)
}
})
export const initI18nScanCodeMsgsOnce = /*#__PURE__*/ once(() => {
const name = 'uni.scanCode.'
if (__UNI_FEATURE_I18N_EN__) {
i18n.add(
useI18n().add(
LOCALE_EN,
normalizeMessages(name, {
title: 'Scan code',
......@@ -434,7 +446,7 @@ export const initI18nScanCodeMsgsOnce = /*#__PURE__*/ once(() => {
)
}
if (__UNI_FEATURE_I18N_ES__) {
i18n.add(
useI18n().add(
LOCALE_ES,
normalizeMessages(name, {
title: 'Código de escaneo',
......@@ -446,7 +458,7 @@ export const initI18nScanCodeMsgsOnce = /*#__PURE__*/ once(() => {
)
}
if (__UNI_FEATURE_I18N_FR__) {
i18n.add(
useI18n().add(
LOCALE_FR,
normalizeMessages(name, {
title: 'Code d’analyse',
......@@ -458,7 +470,7 @@ export const initI18nScanCodeMsgsOnce = /*#__PURE__*/ once(() => {
)
}
if (__UNI_FEATURE_I18N_ZH_HANS__) {
i18n.add(
useI18n().add(
LOCALE_ZH_HANS,
normalizeMessages(name, {
title: '扫码',
......@@ -470,7 +482,7 @@ export const initI18nScanCodeMsgsOnce = /*#__PURE__*/ once(() => {
)
}
if (__UNI_FEATURE_I18N_ZH_HANT__) {
i18n.add(
useI18n().add(
LOCALE_ZH_HANT,
normalizeMessages(name, {
title: '掃碼',
......@@ -486,13 +498,13 @@ export const initI18nStartSoterAuthenticationMsgsOnce = /*#__PURE__*/ once(
() => {
const name = 'uni.startSoterAuthentication.'
if (__UNI_FEATURE_I18N_EN__) {
i18n.add(
useI18n().add(
LOCALE_EN,
normalizeMessages(name, { authContent: 'Fingerprint recognition' })
)
}
if (__UNI_FEATURE_I18N_ES__) {
i18n.add(
useI18n().add(
LOCALE_ES,
normalizeMessages(name, {
authContent: 'Reconocimiento de huellas dactilares',
......@@ -500,7 +512,7 @@ export const initI18nStartSoterAuthenticationMsgsOnce = /*#__PURE__*/ once(
)
}
if (__UNI_FEATURE_I18N_FR__) {
i18n.add(
useI18n().add(
LOCALE_FR,
normalizeMessages(name, {
authContent: "Reconnaissance de l'empreinte digitale",
......@@ -508,13 +520,13 @@ export const initI18nStartSoterAuthenticationMsgsOnce = /*#__PURE__*/ once(
)
}
if (__UNI_FEATURE_I18N_ZH_HANS__) {
i18n.add(
useI18n().add(
LOCALE_ZH_HANS,
normalizeMessages(name, { authContent: '指纹识别中...' })
)
}
if (__UNI_FEATURE_I18N_ZH_HANT__) {
i18n.add(
useI18n().add(
LOCALE_ZH_HANT,
normalizeMessages(name, { authContent: '指紋識別中...' })
)
......@@ -524,31 +536,31 @@ export const initI18nStartSoterAuthenticationMsgsOnce = /*#__PURE__*/ once(
export const initI18nPickerMsgsOnce = /*#__PURE__*/ once(() => {
const name = 'uni.picker.'
if (__UNI_FEATURE_I18N_EN__) {
i18n.add(
useI18n().add(
LOCALE_EN,
normalizeMessages(name, { done: 'Done', cancel: 'Cancel' })
)
}
if (__UNI_FEATURE_I18N_ES__) {
i18n.add(
useI18n().add(
LOCALE_ES,
normalizeMessages(name, { done: 'OK', cancel: 'Cancelar' })
)
}
if (__UNI_FEATURE_I18N_FR__) {
i18n.add(
useI18n().add(
LOCALE_FR,
normalizeMessages(name, { done: 'OK', cancel: 'Annuler' })
)
}
if (__UNI_FEATURE_I18N_ZH_HANS__) {
i18n.add(
useI18n().add(
LOCALE_ZH_HANS,
normalizeMessages(name, { done: '完成', cancel: '取消' })
)
}
if (__UNI_FEATURE_I18N_ZH_HANT__) {
i18n.add(
useI18n().add(
LOCALE_ZH_HANT,
normalizeMessages(name, { done: '完成', cancel: '取消' })
)
......@@ -557,31 +569,31 @@ export const initI18nPickerMsgsOnce = /*#__PURE__*/ once(() => {
export const initI18nVideoMsgsOnce = /*#__PURE__*/ once(() => {
const name = 'uni.video.'
if (__UNI_FEATURE_I18N_EN__) {
i18n.add(
useI18n().add(
LOCALE_EN,
normalizeMessages(name, { danmu: 'Danmu', volume: 'Volume' })
)
}
if (__UNI_FEATURE_I18N_ES__) {
i18n.add(
useI18n().add(
LOCALE_ES,
normalizeMessages(name, { danmu: 'Danmu', volume: 'Volumen' })
)
}
if (__UNI_FEATURE_I18N_FR__) {
i18n.add(
useI18n().add(
LOCALE_FR,
normalizeMessages(name, { danmu: 'Danmu', volume: 'Le Volume' })
)
}
if (__UNI_FEATURE_I18N_ZH_HANS__) {
i18n.add(
useI18n().add(
LOCALE_ZH_HANS,
normalizeMessages(name, { danmu: '弹幕', volume: '音量' })
)
}
if (__UNI_FEATURE_I18N_ZH_HANT__) {
i18n.add(
useI18n().add(
LOCALE_ZH_HANT,
normalizeMessages(name, { danmu: '彈幕', volume: '音量' })
)
......@@ -590,7 +602,7 @@ export const initI18nVideoMsgsOnce = /*#__PURE__*/ once(() => {
export const initI18nButtonMsgsOnce = /*#__PURE__*/ once(() => {
const name = 'uni.button.'
if (__UNI_FEATURE_I18N_EN__) {
i18n.add(
useI18n().add(
LOCALE_EN,
normalizeMessages(name, {
'feedback.title': 'feedback',
......@@ -599,7 +611,7 @@ export const initI18nButtonMsgsOnce = /*#__PURE__*/ once(() => {
)
}
if (__UNI_FEATURE_I18N_ES__) {
i18n.add(
useI18n().add(
LOCALE_ES,
normalizeMessages(name, {
'feedback.title': 'realimentación',
......@@ -608,7 +620,7 @@ export const initI18nButtonMsgsOnce = /*#__PURE__*/ once(() => {
)
}
if (__UNI_FEATURE_I18N_FR__) {
i18n.add(
useI18n().add(
LOCALE_FR,
normalizeMessages(name, {
'feedback.title': "retour d'information",
......@@ -617,7 +629,7 @@ export const initI18nButtonMsgsOnce = /*#__PURE__*/ once(() => {
)
}
if (__UNI_FEATURE_I18N_ZH_HANS__) {
i18n.add(
useI18n().add(
LOCALE_ZH_HANS,
normalizeMessages(name, {
'feedback.title': '问题反馈',
......@@ -626,7 +638,7 @@ export const initI18nButtonMsgsOnce = /*#__PURE__*/ once(() => {
)
}
if (__UNI_FEATURE_I18N_ZH_HANT__) {
i18n.add(
useI18n().add(
LOCALE_ZH_HANT,
normalizeMessages(name, {
'feedback.title': '問題反饋',
......
......@@ -228,20 +228,19 @@ function _sfc_render$1(_ctx, _cache, $props, $setup, $data, $options) {
], 16, ["id", "controls"]);
}
_sfc_main$1.render = _sfc_render$1;
let i18n$1;
let i18n;
function useI18n() {
if (!i18n$1) {
if (!i18n) {
let language;
{
{
language = uniShared.getEnvLocale();
}
}
i18n$1 = uniI18n.initVueI18n(language);
i18n = uniI18n.initVueI18n(language);
}
return i18n$1;
return i18n;
}
const i18n = /* @__PURE__ */ useI18n();
function normalizeMessages(namespace, messages) {
return Object.keys(messages).reduce((res, name) => {
res[namespace + name] = messages[name];
......@@ -251,61 +250,61 @@ function normalizeMessages(namespace, messages) {
const initI18nAsyncMsgsOnce = /* @__PURE__ */ uniShared.once(() => {
const name = "uni.async.";
if (__UNI_FEATURE_I18N_EN__) {
i18n.add(uniI18n.LOCALE_EN, normalizeMessages(name, {
useI18n().add(uniI18n.LOCALE_EN, normalizeMessages(name, {
error: "The connection timed out, click the screen to try again."
}));
}
if (__UNI_FEATURE_I18N_ES__) {
i18n.add(uniI18n.LOCALE_ES, normalizeMessages(name, {
useI18n().add(uniI18n.LOCALE_ES, normalizeMessages(name, {
error: "Se agot\xF3 el tiempo de conexi\xF3n, haga clic en la pantalla para volver a intentarlo."
}));
}
if (__UNI_FEATURE_I18N_FR__) {
i18n.add(uniI18n.LOCALE_FR, normalizeMessages(name, {
useI18n().add(uniI18n.LOCALE_FR, normalizeMessages(name, {
error: "La connexion a expir\xE9, cliquez sur l'\xE9cran pour r\xE9essayer."
}));
}
if (__UNI_FEATURE_I18N_ZH_HANS__) {
i18n.add(uniI18n.LOCALE_ZH_HANS, normalizeMessages(name, { error: "\u8FDE\u63A5\u670D\u52A1\u5668\u8D85\u65F6\uFF0C\u70B9\u51FB\u5C4F\u5E55\u91CD\u8BD5" }));
useI18n().add(uniI18n.LOCALE_ZH_HANS, normalizeMessages(name, { error: "\u8FDE\u63A5\u670D\u52A1\u5668\u8D85\u65F6\uFF0C\u70B9\u51FB\u5C4F\u5E55\u91CD\u8BD5" }));
}
if (__UNI_FEATURE_I18N_ZH_HANT__) {
i18n.add(uniI18n.LOCALE_ZH_HANT, normalizeMessages(name, { error: "\u9023\u63A5\u670D\u52D9\u5668\u8D85\u6642\uFF0C\u9EDE\u64CA\u5C4F\u5E55\u91CD\u8A66" }));
useI18n().add(uniI18n.LOCALE_ZH_HANT, normalizeMessages(name, { error: "\u9023\u63A5\u670D\u52D9\u5668\u8D85\u6642\uFF0C\u9EDE\u64CA\u5C4F\u5E55\u91CD\u8A66" }));
}
});
const initI18nPickerMsgsOnce = /* @__PURE__ */ uniShared.once(() => {
const name = "uni.picker.";
if (__UNI_FEATURE_I18N_EN__) {
i18n.add(uniI18n.LOCALE_EN, normalizeMessages(name, { done: "Done", cancel: "Cancel" }));
useI18n().add(uniI18n.LOCALE_EN, normalizeMessages(name, { done: "Done", cancel: "Cancel" }));
}
if (__UNI_FEATURE_I18N_ES__) {
i18n.add(uniI18n.LOCALE_ES, normalizeMessages(name, { done: "OK", cancel: "Cancelar" }));
useI18n().add(uniI18n.LOCALE_ES, normalizeMessages(name, { done: "OK", cancel: "Cancelar" }));
}
if (__UNI_FEATURE_I18N_FR__) {
i18n.add(uniI18n.LOCALE_FR, normalizeMessages(name, { done: "OK", cancel: "Annuler" }));
useI18n().add(uniI18n.LOCALE_FR, normalizeMessages(name, { done: "OK", cancel: "Annuler" }));
}
if (__UNI_FEATURE_I18N_ZH_HANS__) {
i18n.add(uniI18n.LOCALE_ZH_HANS, normalizeMessages(name, { done: "\u5B8C\u6210", cancel: "\u53D6\u6D88" }));
useI18n().add(uniI18n.LOCALE_ZH_HANS, normalizeMessages(name, { done: "\u5B8C\u6210", cancel: "\u53D6\u6D88" }));
}
if (__UNI_FEATURE_I18N_ZH_HANT__) {
i18n.add(uniI18n.LOCALE_ZH_HANT, normalizeMessages(name, { done: "\u5B8C\u6210", cancel: "\u53D6\u6D88" }));
useI18n().add(uniI18n.LOCALE_ZH_HANT, normalizeMessages(name, { done: "\u5B8C\u6210", cancel: "\u53D6\u6D88" }));
}
});
const initI18nVideoMsgsOnce = /* @__PURE__ */ uniShared.once(() => {
const name = "uni.video.";
if (__UNI_FEATURE_I18N_EN__) {
i18n.add(uniI18n.LOCALE_EN, normalizeMessages(name, { danmu: "Danmu", volume: "Volume" }));
useI18n().add(uniI18n.LOCALE_EN, normalizeMessages(name, { danmu: "Danmu", volume: "Volume" }));
}
if (__UNI_FEATURE_I18N_ES__) {
i18n.add(uniI18n.LOCALE_ES, normalizeMessages(name, { danmu: "Danmu", volume: "Volumen" }));
useI18n().add(uniI18n.LOCALE_ES, normalizeMessages(name, { danmu: "Danmu", volume: "Volumen" }));
}
if (__UNI_FEATURE_I18N_FR__) {
i18n.add(uniI18n.LOCALE_FR, normalizeMessages(name, { danmu: "Danmu", volume: "Le Volume" }));
useI18n().add(uniI18n.LOCALE_FR, normalizeMessages(name, { danmu: "Danmu", volume: "Le Volume" }));
}
if (__UNI_FEATURE_I18N_ZH_HANS__) {
i18n.add(uniI18n.LOCALE_ZH_HANS, normalizeMessages(name, { danmu: "\u5F39\u5E55", volume: "\u97F3\u91CF" }));
useI18n().add(uniI18n.LOCALE_ZH_HANS, normalizeMessages(name, { danmu: "\u5F39\u5E55", volume: "\u97F3\u91CF" }));
}
if (__UNI_FEATURE_I18N_ZH_HANT__) {
i18n.add(uniI18n.LOCALE_ZH_HANT, normalizeMessages(name, { danmu: "\u5F48\u5E55", volume: "\u97F3\u91CF" }));
useI18n().add(uniI18n.LOCALE_ZH_HANT, normalizeMessages(name, { danmu: "\u5F48\u5E55", volume: "\u97F3\u91CF" }));
}
});
const E = function() {
......@@ -426,7 +425,7 @@ function createSvgIconVNode(path, color = "#000", size = 27) {
function useCurrentPageId() {
return vue.getCurrentInstance().root.proxy.$page.id;
}
const PAGE_META_KEYS = ["navigationBar", "refreshOptions"];
const PAGE_META_KEYS = ["navigationBar", "pullToRefresh"];
function initGlobalStyle() {
return JSON.parse(JSON.stringify(__uniConfig.globalStyle || {}));
}
......@@ -438,6 +437,18 @@ function mergePageMeta(id, pageMeta) {
});
return res;
}
function normalizePullToRefreshRpx(pullToRefresh) {
if (pullToRefresh.offset) {
pullToRefresh.offset = rpx2px(pullToRefresh.offset);
}
if (pullToRefresh.height) {
pullToRefresh.height = rpx2px(pullToRefresh.height);
}
if (pullToRefresh.range) {
pullToRefresh.range = rpx2px(pullToRefresh.range);
}
return pullToRefresh;
}
function getRealRoute(fromRoute, toRoute) {
if (toRoute.indexOf("/") === 0) {
return toRoute;
......@@ -6547,23 +6558,19 @@ function normalizePageMeta(pageMeta) {
if (__UNI_FEATURE_PULL_DOWN_REFRESH__) {
const { enablePullDownRefresh, navigationBar } = pageMeta;
if (enablePullDownRefresh) {
const refreshOptions = shared.extend({
const pullToRefresh = normalizePullToRefreshRpx(shared.extend({
support: true,
color: "#2BD009",
style: "circle",
height: 70,
range: 150,
offset: 0
}, pageMeta.refreshOptions);
let offset = rpx2px(refreshOptions.offset);
const { type } = navigationBar;
if (type !== "transparent" && type !== "none") {
offset += uniShared.NAVBAR_HEIGHT + 0;
}, pageMeta.pullToRefresh));
const { type, style } = navigationBar;
if (style !== "custom" && type !== "transparent") {
pullToRefresh.offset += uniShared.NAVBAR_HEIGHT + 0;
}
refreshOptions.offset = offset;
refreshOptions.height = rpx2px(refreshOptions.height);
refreshOptions.range = rpx2px(refreshOptions.range);
pageMeta.refreshOptions = refreshOptions;
pageMeta.pullToRefresh = pullToRefresh;
}
}
if (__UNI_FEATURE_NAVIGATIONBAR__) {
......@@ -6571,9 +6578,8 @@ function normalizePageMeta(pageMeta) {
const { titleSize, titleColor, backgroundColor } = navigationBar;
navigationBar.titleText = navigationBar.titleText || "";
navigationBar.type = navigationBar.type || "default";
navigationBar.backButton = pageMeta.isQuit ? false : true;
navigationBar.titleSize = titleSize || "16px";
navigationBar.titleColor = titleColor || "#fff";
navigationBar.titleColor = titleColor || "#ffffff";
navigationBar.backgroundColor = backgroundColor || "#F7F7F7";
}
return pageMeta;
......@@ -10278,7 +10284,7 @@ function createBackButtonTsx(pageMeta) {
navigationBar,
isQuit
} = pageMeta;
if (navigationBar.backButton && !isQuit) {
if (!isQuit) {
return vue.createVNode("div", {
"class": "uni-page-head-btn",
"onClick": onPageHeadBackButton
......@@ -10570,10 +10576,10 @@ function usePageHeadSearchInput({
var _sfc_main = {
name: "PageRefresh",
setup() {
const { refreshOptions } = usePageMeta();
const { pullToRefresh } = usePageMeta();
return {
offset: refreshOptions.offset,
color: refreshOptions.color
offset: pullToRefresh.offset,
color: pullToRefresh.color
};
}
};
......
......@@ -225,20 +225,19 @@ function _sfc_render$1(_ctx, _cache, $props, $setup, $data, $options) {
], 16, ["id", "controls"]);
}
_sfc_main$1.render = _sfc_render$1;
let i18n$1;
let i18n;
function useI18n() {
if (!i18n$1) {
if (!i18n) {
let language;
{
{
language = navigator.language;
}
}
i18n$1 = initVueI18n(language);
i18n = initVueI18n(language);
}
return i18n$1;
return i18n;
}
const i18n = /* @__PURE__ */ useI18n();
function normalizeMessages(namespace, messages) {
return Object.keys(messages).reduce((res, name) => {
res[namespace + name] = messages[name];
......@@ -248,69 +247,69 @@ function normalizeMessages(namespace, messages) {
const initI18nAsyncMsgsOnce = /* @__PURE__ */ once(() => {
const name = "uni.async.";
if (__UNI_FEATURE_I18N_EN__) {
i18n.add(LOCALE_EN, normalizeMessages(name, {
useI18n().add(LOCALE_EN, normalizeMessages(name, {
error: "The connection timed out, click the screen to try again."
}));
}
if (__UNI_FEATURE_I18N_ES__) {
i18n.add(LOCALE_ES, normalizeMessages(name, {
useI18n().add(LOCALE_ES, normalizeMessages(name, {
error: "Se agot\xF3 el tiempo de conexi\xF3n, haga clic en la pantalla para volver a intentarlo."
}));
}
if (__UNI_FEATURE_I18N_FR__) {
i18n.add(LOCALE_FR, normalizeMessages(name, {
useI18n().add(LOCALE_FR, normalizeMessages(name, {
error: "La connexion a expir\xE9, cliquez sur l'\xE9cran pour r\xE9essayer."
}));
}
if (__UNI_FEATURE_I18N_ZH_HANS__) {
i18n.add(LOCALE_ZH_HANS, normalizeMessages(name, { error: "\u8FDE\u63A5\u670D\u52A1\u5668\u8D85\u65F6\uFF0C\u70B9\u51FB\u5C4F\u5E55\u91CD\u8BD5" }));
useI18n().add(LOCALE_ZH_HANS, normalizeMessages(name, { error: "\u8FDE\u63A5\u670D\u52A1\u5668\u8D85\u65F6\uFF0C\u70B9\u51FB\u5C4F\u5E55\u91CD\u8BD5" }));
}
if (__UNI_FEATURE_I18N_ZH_HANT__) {
i18n.add(LOCALE_ZH_HANT, normalizeMessages(name, { error: "\u9023\u63A5\u670D\u52D9\u5668\u8D85\u6642\uFF0C\u9EDE\u64CA\u5C4F\u5E55\u91CD\u8A66" }));
useI18n().add(LOCALE_ZH_HANT, normalizeMessages(name, { error: "\u9023\u63A5\u670D\u52D9\u5668\u8D85\u6642\uFF0C\u9EDE\u64CA\u5C4F\u5E55\u91CD\u8A66" }));
}
});
const initI18nShowActionSheetMsgsOnce = /* @__PURE__ */ once(() => {
const name = "uni.showActionSheet.";
if (__UNI_FEATURE_I18N_EN__) {
i18n.add(LOCALE_EN, normalizeMessages(name, { cancel: "Cancel" }));
useI18n().add(LOCALE_EN, normalizeMessages(name, { cancel: "Cancel" }));
}
if (__UNI_FEATURE_I18N_ES__) {
i18n.add(LOCALE_ES, normalizeMessages(name, { cancel: "Cancelar" }));
useI18n().add(LOCALE_ES, normalizeMessages(name, { cancel: "Cancelar" }));
}
if (__UNI_FEATURE_I18N_FR__) {
i18n.add(LOCALE_FR, normalizeMessages(name, { cancel: "Annuler" }));
useI18n().add(LOCALE_FR, normalizeMessages(name, { cancel: "Annuler" }));
}
if (__UNI_FEATURE_I18N_ZH_HANS__) {
i18n.add(LOCALE_ZH_HANS, normalizeMessages(name, { cancel: "\u53D6\u6D88" }));
useI18n().add(LOCALE_ZH_HANS, normalizeMessages(name, { cancel: "\u53D6\u6D88" }));
}
if (__UNI_FEATURE_I18N_ZH_HANT__) {
i18n.add(LOCALE_ZH_HANT, normalizeMessages(name, { cancel: "\u53D6\u6D88" }));
useI18n().add(LOCALE_ZH_HANT, normalizeMessages(name, { cancel: "\u53D6\u6D88" }));
}
});
const initI18nShowToastMsgsOnce = /* @__PURE__ */ once(() => {
const name = "uni.showToast.";
if (__UNI_FEATURE_I18N_EN__) {
i18n.add(LOCALE_EN, normalizeMessages(name, {
useI18n().add(LOCALE_EN, normalizeMessages(name, {
unpaired: "Please note showToast must be paired with hideToast"
}));
}
if (__UNI_FEATURE_I18N_ES__) {
i18n.add(LOCALE_ES, normalizeMessages(name, {
useI18n().add(LOCALE_ES, normalizeMessages(name, {
unpaired: "Tenga en cuenta que showToast debe estar emparejado con hideToast"
}));
}
if (__UNI_FEATURE_I18N_FR__) {
i18n.add(LOCALE_FR, normalizeMessages(name, {
useI18n().add(LOCALE_FR, normalizeMessages(name, {
unpaired: "Veuillez noter que showToast doit \xEAtre associ\xE9 \xE0 hideToast"
}));
}
if (__UNI_FEATURE_I18N_ZH_HANS__) {
i18n.add(LOCALE_ZH_HANS, normalizeMessages(name, {
useI18n().add(LOCALE_ZH_HANS, normalizeMessages(name, {
unpaired: "\u8BF7\u6CE8\u610F showToast \u4E0E hideToast \u5FC5\u987B\u914D\u5BF9\u4F7F\u7528"
}));
}
if (__UNI_FEATURE_I18N_ZH_HANT__) {
i18n.add(LOCALE_ZH_HANT, normalizeMessages(name, {
useI18n().add(LOCALE_ZH_HANT, normalizeMessages(name, {
unpaired: "\u8ACB\u6CE8\u610F showToast \u8207 hideToast \u5FC5\u9808\u914D\u5C0D\u4F7F\u7528"
}));
}
......@@ -318,27 +317,27 @@ const initI18nShowToastMsgsOnce = /* @__PURE__ */ once(() => {
const initI18nShowLoadingMsgsOnce = /* @__PURE__ */ once(() => {
const name = "uni.showLoading.";
if (__UNI_FEATURE_I18N_EN__) {
i18n.add(LOCALE_EN, normalizeMessages(name, {
useI18n().add(LOCALE_EN, normalizeMessages(name, {
unpaired: "Please note showLoading must be paired with hideLoading"
}));
}
if (__UNI_FEATURE_I18N_ES__) {
i18n.add(LOCALE_ES, normalizeMessages(name, {
useI18n().add(LOCALE_ES, normalizeMessages(name, {
unpaired: "Tenga en cuenta que showLoading debe estar emparejado con hideLoading"
}));
}
if (__UNI_FEATURE_I18N_FR__) {
i18n.add(LOCALE_FR, normalizeMessages(name, {
useI18n().add(LOCALE_FR, normalizeMessages(name, {
unpaired: "Veuillez noter que showLoading doit \xEAtre associ\xE9 \xE0 hideLoading"
}));
}
if (__UNI_FEATURE_I18N_ZH_HANS__) {
i18n.add(LOCALE_ZH_HANS, normalizeMessages(name, {
useI18n().add(LOCALE_ZH_HANS, normalizeMessages(name, {
unpaired: "\u8BF7\u6CE8\u610F showLoading \u4E0E hideLoading \u5FC5\u987B\u914D\u5BF9\u4F7F\u7528"
}));
}
if (__UNI_FEATURE_I18N_ZH_HANT__) {
i18n.add(LOCALE_ZH_HANT, normalizeMessages(name, {
useI18n().add(LOCALE_ZH_HANT, normalizeMessages(name, {
unpaired: "\u8ACB\u6CE8\u610F showLoading \u8207 hideLoading \u5FC5\u9808\u914D\u5C0D\u4F7F\u7528"
}));
}
......@@ -346,55 +345,55 @@ const initI18nShowLoadingMsgsOnce = /* @__PURE__ */ once(() => {
const initI18nShowModalMsgsOnce = /* @__PURE__ */ once(() => {
const name = "uni.showModal.";
if (__UNI_FEATURE_I18N_EN__) {
i18n.add(LOCALE_EN, normalizeMessages(name, { cancel: "Cancel", confirm: "OK" }));
useI18n().add(LOCALE_EN, normalizeMessages(name, { cancel: "Cancel", confirm: "OK" }));
}
if (__UNI_FEATURE_I18N_ES__) {
i18n.add(LOCALE_ES, normalizeMessages(name, { cancel: "Cancelar", confirm: "OK" }));
useI18n().add(LOCALE_ES, normalizeMessages(name, { cancel: "Cancelar", confirm: "OK" }));
}
if (__UNI_FEATURE_I18N_FR__) {
i18n.add(LOCALE_FR, normalizeMessages(name, { cancel: "Annuler", confirm: "OK" }));
useI18n().add(LOCALE_FR, normalizeMessages(name, { cancel: "Annuler", confirm: "OK" }));
}
if (__UNI_FEATURE_I18N_ZH_HANS__) {
i18n.add(LOCALE_ZH_HANS, normalizeMessages(name, { cancel: "\u53D6\u6D88", confirm: "\u786E\u5B9A" }));
useI18n().add(LOCALE_ZH_HANS, normalizeMessages(name, { cancel: "\u53D6\u6D88", confirm: "\u786E\u5B9A" }));
}
if (__UNI_FEATURE_I18N_ZH_HANT__) {
i18n.add(LOCALE_ZH_HANT, normalizeMessages(name, { cancel: "\u53D6\u6D88", confirm: "\u78BA\u5B9A" }));
useI18n().add(LOCALE_ZH_HANT, normalizeMessages(name, { cancel: "\u53D6\u6D88", confirm: "\u78BA\u5B9A" }));
}
});
const initI18nPickerMsgsOnce = /* @__PURE__ */ once(() => {
const name = "uni.picker.";
if (__UNI_FEATURE_I18N_EN__) {
i18n.add(LOCALE_EN, normalizeMessages(name, { done: "Done", cancel: "Cancel" }));
useI18n().add(LOCALE_EN, normalizeMessages(name, { done: "Done", cancel: "Cancel" }));
}
if (__UNI_FEATURE_I18N_ES__) {
i18n.add(LOCALE_ES, normalizeMessages(name, { done: "OK", cancel: "Cancelar" }));
useI18n().add(LOCALE_ES, normalizeMessages(name, { done: "OK", cancel: "Cancelar" }));
}
if (__UNI_FEATURE_I18N_FR__) {
i18n.add(LOCALE_FR, normalizeMessages(name, { done: "OK", cancel: "Annuler" }));
useI18n().add(LOCALE_FR, normalizeMessages(name, { done: "OK", cancel: "Annuler" }));
}
if (__UNI_FEATURE_I18N_ZH_HANS__) {
i18n.add(LOCALE_ZH_HANS, normalizeMessages(name, { done: "\u5B8C\u6210", cancel: "\u53D6\u6D88" }));
useI18n().add(LOCALE_ZH_HANS, normalizeMessages(name, { done: "\u5B8C\u6210", cancel: "\u53D6\u6D88" }));
}
if (__UNI_FEATURE_I18N_ZH_HANT__) {
i18n.add(LOCALE_ZH_HANT, normalizeMessages(name, { done: "\u5B8C\u6210", cancel: "\u53D6\u6D88" }));
useI18n().add(LOCALE_ZH_HANT, normalizeMessages(name, { done: "\u5B8C\u6210", cancel: "\u53D6\u6D88" }));
}
});
const initI18nVideoMsgsOnce = /* @__PURE__ */ once(() => {
const name = "uni.video.";
if (__UNI_FEATURE_I18N_EN__) {
i18n.add(LOCALE_EN, normalizeMessages(name, { danmu: "Danmu", volume: "Volume" }));
useI18n().add(LOCALE_EN, normalizeMessages(name, { danmu: "Danmu", volume: "Volume" }));
}
if (__UNI_FEATURE_I18N_ES__) {
i18n.add(LOCALE_ES, normalizeMessages(name, { danmu: "Danmu", volume: "Volumen" }));
useI18n().add(LOCALE_ES, normalizeMessages(name, { danmu: "Danmu", volume: "Volumen" }));
}
if (__UNI_FEATURE_I18N_FR__) {
i18n.add(LOCALE_FR, normalizeMessages(name, { danmu: "Danmu", volume: "Le Volume" }));
useI18n().add(LOCALE_FR, normalizeMessages(name, { danmu: "Danmu", volume: "Le Volume" }));
}
if (__UNI_FEATURE_I18N_ZH_HANS__) {
i18n.add(LOCALE_ZH_HANS, normalizeMessages(name, { danmu: "\u5F39\u5E55", volume: "\u97F3\u91CF" }));
useI18n().add(LOCALE_ZH_HANS, normalizeMessages(name, { danmu: "\u5F39\u5E55", volume: "\u97F3\u91CF" }));
}
if (__UNI_FEATURE_I18N_ZH_HANT__) {
i18n.add(LOCALE_ZH_HANT, normalizeMessages(name, { danmu: "\u5F48\u5E55", volume: "\u97F3\u91CF" }));
useI18n().add(LOCALE_ZH_HANT, normalizeMessages(name, { danmu: "\u5F48\u5E55", volume: "\u97F3\u91CF" }));
}
});
const E = function() {
......@@ -813,7 +812,7 @@ function getPageIdByVm(vm) {
return rootProxy.$page.id;
}
}
const PAGE_META_KEYS = ["navigationBar", "refreshOptions"];
const PAGE_META_KEYS = ["navigationBar", "pullToRefresh"];
function initGlobalStyle() {
return JSON.parse(JSON.stringify(__uniConfig.globalStyle || {}));
}
......@@ -825,6 +824,18 @@ function mergePageMeta(id2, pageMeta) {
});
return res;
}
function normalizePullToRefreshRpx(pullToRefresh) {
if (pullToRefresh.offset) {
pullToRefresh.offset = rpx2px(pullToRefresh.offset);
}
if (pullToRefresh.height) {
pullToRefresh.height = rpx2px(pullToRefresh.height);
}
if (pullToRefresh.range) {
pullToRefresh.range = rpx2px(pullToRefresh.range);
}
return pullToRefresh;
}
function disableScrollListener(evt) {
evt.preventDefault();
}
......@@ -13021,23 +13032,19 @@ function normalizePageMeta(pageMeta) {
if (__UNI_FEATURE_PULL_DOWN_REFRESH__) {
const { enablePullDownRefresh, navigationBar } = pageMeta;
if (enablePullDownRefresh) {
const refreshOptions = extend({
const pullToRefresh = normalizePullToRefreshRpx(extend({
support: true,
color: "#2BD009",
style: "circle",
height: 70,
range: 150,
offset: 0
}, pageMeta.refreshOptions);
let offset = rpx2px(refreshOptions.offset);
const { type } = navigationBar;
if (type !== "transparent" && type !== "none") {
offset += NAVBAR_HEIGHT + out.top;
}, pageMeta.pullToRefresh));
const { type, style } = navigationBar;
if (style !== "custom" && type !== "transparent") {
pullToRefresh.offset += NAVBAR_HEIGHT + out.top;
}
refreshOptions.offset = offset;
refreshOptions.height = rpx2px(refreshOptions.height);
refreshOptions.range = rpx2px(refreshOptions.range);
pageMeta.refreshOptions = refreshOptions;
pageMeta.pullToRefresh = pullToRefresh;
}
}
if (__UNI_FEATURE_NAVIGATIONBAR__) {
......@@ -13045,9 +13052,8 @@ function normalizePageMeta(pageMeta) {
const { titleSize, titleColor, backgroundColor } = navigationBar;
navigationBar.titleText = navigationBar.titleText || "";
navigationBar.type = navigationBar.type || "default";
navigationBar.backButton = pageMeta.isQuit ? false : true;
navigationBar.titleSize = titleSize || "16px";
navigationBar.titleColor = titleColor || "#fff";
navigationBar.titleColor = titleColor || "#ffffff";
navigationBar.backgroundColor = backgroundColor || "#F7F7F7";
}
if (__UNI_FEATURE_PAGES__ && history.state) {
......@@ -17372,6 +17378,9 @@ var modal = /* @__PURE__ */ defineComponent({
}
});
let showModalState;
const onHidePopupOnce$2 = /* @__PURE__ */ once(() => {
UniServiceJSBridge.on("onHidePopup", () => showModalState.visible = false);
});
let currentShowModalResolve;
function onModalClose(type) {
currentShowModalResolve && currentShowModalResolve({
......@@ -17380,6 +17389,7 @@ function onModalClose(type) {
});
}
const showModal = /* @__PURE__ */ defineAsyncApi(API_SHOW_MODAL, (args, { resolve }) => {
onHidePopupOnce$2();
currentShowModalResolve = resolve;
if (!showModalState) {
showModalState = reactive(args);
......@@ -17488,7 +17498,7 @@ function useToastIcon(props2) {
let showToastState;
let showType = "";
let timeoutId;
const onHidePopupOnce = /* @__PURE__ */ once(() => {
const onHidePopupOnce$1 = /* @__PURE__ */ once(() => {
UniServiceJSBridge.on("onHidePopup", () => hidePopup("onHidePopup"));
});
function createToast(args) {
......@@ -17514,7 +17524,7 @@ function createToast(args) {
timeoutId && clearTimeout(timeoutId);
}
});
onHidePopupOnce();
onHidePopupOnce$1();
}
const showToast = /* @__PURE__ */ defineAsyncApi(API_SHOW_TOAST, (args, { resolve, reject }) => {
createToast(args);
......@@ -17854,6 +17864,9 @@ function initClick(dom) {
let resolveAction;
let rejectAction;
let showActionSheetState;
const onHidePopupOnce = /* @__PURE__ */ once(() => {
UniServiceJSBridge.on("onHidePopup", () => showActionSheetState.visible = false);
});
function onActionSheetClose(tapIndex) {
if (tapIndex === -1) {
rejectAction && rejectAction("cancel");
......@@ -17862,6 +17875,7 @@ function onActionSheetClose(tapIndex) {
}
}
const showActionSheet = /* @__PURE__ */ defineAsyncApi(API_SHOW_ACTION_SHEET, (args, { resolve, reject }) => {
onHidePopupOnce();
resolveAction = resolve;
rejectAction = reject;
if (!showActionSheetState) {
......@@ -20349,7 +20363,7 @@ function createBackButtonTsx(pageMeta) {
navigationBar,
isQuit
} = pageMeta;
if (navigationBar.backButton && !isQuit) {
if (!isQuit) {
return createVNode("div", {
"class": "uni-page-head-btn",
"onClick": onPageHeadBackButton
......@@ -20642,10 +20656,10 @@ function usePageHeadSearchInput({
var _sfc_main = {
name: "PageRefresh",
setup() {
const { refreshOptions } = usePageMeta();
const { pullToRefresh } = usePageMeta();
return {
offset: refreshOptions.offset,
color: refreshOptions.color
offset: pullToRefresh.offset,
color: pullToRefresh.color
};
}
};
......@@ -20709,8 +20723,8 @@ const ABORTING = "aborting";
const REFRESHING = "refreshing";
const RESTORING = "restoring";
function usePageRefresh(refreshRef) {
const { id: id2, refreshOptions } = usePageMeta();
const { range, height } = refreshOptions;
const { id: id2, pullToRefresh } = usePageMeta();
const { range, height } = pullToRefresh;
let refreshContainerElem;
let refreshControllerElem;
let refreshControllerElemStyle;
......
......@@ -40,10 +40,10 @@ import { usePageMeta } from '../../../setup/provide'
export default {
name: 'PageRefresh',
setup() {
const { refreshOptions } = usePageMeta()
const { pullToRefresh } = usePageMeta()
return {
offset: refreshOptions!.offset,
color: refreshOptions!.color,
offset: pullToRefresh!.offset,
color: pullToRefresh!.color,
}
},
}
......
......@@ -32,8 +32,8 @@ const REFRESHING = 'refreshing'
const RESTORING = 'restoring'
export function usePageRefresh(refreshRef: Ref) {
const { id, refreshOptions } = usePageMeta()
const { range, height } = refreshOptions!
const { id, pullToRefresh } = usePageMeta()
const { range, height } = pullToRefresh!
let refreshContainerElem: HTMLDivElement
let refreshControllerElem: HTMLDivElement
let refreshControllerElemStyle: CSSStyleDeclaration
......@@ -231,7 +231,7 @@ export function usePageRefresh(refreshRef: Ref) {
refreshControllerElemStyle.transition = '-webkit-transform 0.2s'
refreshControllerElemStyle.transform =
'translate3d(-50%, ' + height + 'px, 0)'
invokeHook(id, 'onPullDownRefresh')
invokeHook(id!, 'onPullDownRefresh')
}
function restoring(callback: Function) {
......
......@@ -89,7 +89,7 @@ export default /*#__PURE__*/ defineSystemComponent({
function createBackButtonTsx(pageMeta: UniApp.PageRouteMeta) {
const { navigationBar, isQuit } = pageMeta
if (navigationBar.backButton && !isQuit) {
if (!isQuit) {
return (
<div class="uni-page-head-btn" onClick={onPageHeadBackButton}>
{createSvgIconVNode(
......
......@@ -3,7 +3,11 @@ import { reactive, provide, inject } from 'vue'
import { useRoute } from 'vue-router'
import { NAVBAR_HEIGHT, parseQuery } from '@dcloudio/uni-shared'
import { mergePageMeta, PolySymbol, rpx2px } from '@dcloudio/uni-core'
import {
mergePageMeta,
normalizePullToRefreshRpx,
PolySymbol,
} from '@dcloudio/uni-core'
import safeAreaInsets from 'safe-area-insets'
......@@ -64,26 +68,25 @@ function normalizePageMeta(pageMeta: UniApp.PageRouteMeta) {
if (__UNI_FEATURE_PULL_DOWN_REFRESH__) {
const { enablePullDownRefresh, navigationBar } = pageMeta
if (enablePullDownRefresh) {
const refreshOptions = extend(
{
support: true,
color: '#2BD009',
style: 'circle',
height: 70,
range: 150,
offset: 0,
},
pageMeta.refreshOptions
const pullToRefresh = normalizePullToRefreshRpx(
extend(
{
support: true,
color: '#2BD009',
style: 'circle',
height: 70,
range: 150,
offset: 0,
},
pageMeta.pullToRefresh
)
)
let offset = rpx2px(refreshOptions.offset)
const { type } = navigationBar
if (type !== 'transparent' && type !== 'none') {
offset += NAVBAR_HEIGHT + (__NODE_JS__ ? 0 : safeAreaInsets.top)
const { type, style } = navigationBar
if (style !== 'custom' && type !== 'transparent') {
pullToRefresh.offset +=
NAVBAR_HEIGHT + (__NODE_JS__ ? 0 : safeAreaInsets.top)
}
refreshOptions.offset = offset
refreshOptions.height = rpx2px(refreshOptions.height)
refreshOptions.range = rpx2px(refreshOptions.range)
pageMeta.refreshOptions = refreshOptions
pageMeta.pullToRefresh = pullToRefresh
}
}
if (__UNI_FEATURE_NAVIGATIONBAR__) {
......@@ -91,9 +94,8 @@ function normalizePageMeta(pageMeta: UniApp.PageRouteMeta) {
const { titleSize, titleColor, backgroundColor } = navigationBar
navigationBar.titleText = navigationBar.titleText || ''
navigationBar.type = navigationBar.type || 'default'
navigationBar.backButton = pageMeta.isQuit ? false : true
navigationBar.titleSize = titleSize || '16px'
navigationBar.titleColor = titleColor || '#fff'
navigationBar.titleColor = titleColor || '#ffffff'
navigationBar.backgroundColor = backgroundColor || '#F7F7F7'
}
if (!__NODE_JS__ && __UNI_FEATURE_PAGES__ && history.state) {
......
import { cac } from 'cac'
import chalk from 'chalk'
import { extend } from '@vue/shared'
import { LogLevel, createLogger, ServerOptions, BuildOptions } from 'vite'
import { build, buildSSR } from './build'
import { createServer, createSSRServer } from './server'
......@@ -52,7 +53,11 @@ cli
.action(async (options: CliOptions & ServerOptions) => {
initEnv('dev', options)
try {
await (options.ssr ? createSSRServer(options) : createServer(options))
if (options.platform === 'h5') {
await (options.ssr ? createSSRServer(options) : createServer(options))
} else {
await build(extend(options, { watch: true }))
}
} catch (e) {
createLogger(options.logLevel).error(
chalk.red(`error when starting dev server:\n${e.stack}`)
......
......@@ -51,7 +51,7 @@ import {
LOCALE_ZH_HANT,
} from '@dcloudio/uni-i18n'
import { useI18n } from './useI18n'
const i18n = /*#__PURE__*/ useI18n()
function normalizeMessages(
namespace: string,
messages: Record<string, string>
......@@ -83,7 +83,7 @@ ${Object.keys(localeMessages)
function generateI18nModuleLocaleCode(locale, messages) {
locale = locale.toUpperCase().replace('-', '_')
return ` if (__UNI_FEATURE_I18N_${locale}__) {
i18n.add(LOCALE_${locale}, normalizeMessages(name, ${JSON.stringify(
useI18n().add(LOCALE_${locale}, normalizeMessages(name, ${JSON.stringify(
messages
)}))
}
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册