diff --git a/dist/static/logo.png b/dist/static/logo.png deleted file mode 100644 index b5771e209bb677e2ebd5ff766ad5ee11790f305a..0000000000000000000000000000000000000000 Binary files a/dist/static/logo.png and /dev/null differ diff --git a/packages/global.d.ts b/packages/global.d.ts index 01d82e52290035b7eaa24d8707b6d09b77407318..2a79722629b92747bfd41e13dd334d00c2bd6725 100644 --- a/packages/global.d.ts +++ b/packages/global.d.ts @@ -32,6 +32,11 @@ declare var __UNI_FEATURE_NAVIGATIONBAR__: boolean declare var __UNI_FEATURE_NAVIGATIONBAR_BUTTONS__: boolean declare var __UNI_FEATURE_NAVIGATIONBAR_SEARCHINPUT__: boolean declare var __UNI_FEATURE_NAVIGATIONBAR_TRANSPARENT__: boolean +declare var __UNI_FEATURE_I18N_EN__: boolean +declare var __UNI_FEATURE_I18N_ES__: boolean +declare var __UNI_FEATURE_I18N_FR__: boolean +declare var __UNI_FEATURE_I18N_ZH_HANS__: boolean +declare var __UNI_FEATURE_I18N_ZH_HANT__: boolean // TODO declare var __uniRoutes: UniApp.UniRoutes declare var __uniConfig: UniApp.UniConfig diff --git a/packages/uni-api/src/helpers/api/index.ts b/packages/uni-api/src/helpers/api/index.ts index e37b4d33bb5e5a12d4e70411486917c16b0097fb..e14c51443cc8b29c7a908c899edf2ac5cc2363e7 100644 --- a/packages/uni-api/src/helpers/api/index.ts +++ b/packages/uni-api/src/helpers/api/index.ts @@ -1,4 +1,10 @@ -import { extend, isString, isPlainObject } from '@vue/shared' +import { + extend, + hasOwn, + isString, + isFunction, + isPlainObject, +} from '@vue/shared' import { API_TYPE_ON_PROTOCOLS, validateProtocols } from '../protocol' import { invokeCallback, @@ -24,7 +30,15 @@ function formatApiArgs( } const formatArgs = options.formatArgs! Object.keys(formatArgs).forEach((name) => { - formatArgs[name]!(args[0][name], params) + const formatterOrDefaultValue = formatArgs[name]! + if (isFunction(formatterOrDefaultValue)) { + formatterOrDefaultValue(args[0][name], params) + } else { + // defaultValue + if (!hasOwn(params, name)) { + params[name] = formatterOrDefaultValue + } + } }) return args } diff --git a/packages/uni-api/src/index.ts b/packages/uni-api/src/index.ts index d0dd7a82b98ba5f72a5b37afd64ba247b082c83b..443d6c9b865f9163b984fd2e93207470e8bc21c0 100644 --- a/packages/uni-api/src/index.ts +++ b/packages/uni-api/src/index.ts @@ -31,6 +31,7 @@ export * from './protocols/network/uploadFile' export * from './protocols/route/route' export * from './protocols/ui/navigationBar' +export * from './protocols/ui/popup' export * from './protocols/ui/tabBar' // helpers export { diff --git a/packages/uni-api/src/protocols/network/downloadFile.ts b/packages/uni-api/src/protocols/network/downloadFile.ts index 97820ae38c7390817637841c48d3a609ae5fec26..bad7d27406b770402815f9469db1a2ece5066cd5 100644 --- a/packages/uni-api/src/protocols/network/downloadFile.ts +++ b/packages/uni-api/src/protocols/network/downloadFile.ts @@ -2,7 +2,7 @@ export const API_DOWNLOAD_FILE = 'downloadFile' export type API_TYPE_DOWNLOAD_FILE = typeof uni.downloadFile export const DownloadFileOptions: ApiOptions = { formatArgs: { - header(value, params) { + header(value: Record, params: Record) { params.header = value || {} }, }, diff --git a/packages/uni-api/src/protocols/network/request.ts b/packages/uni-api/src/protocols/network/request.ts index 7c42bc612c1e161b4760a3c7312a3090bd93b63c..6f33c5df58fcc2c78c5e8102b03fd6868c5fa8e0 100644 --- a/packages/uni-api/src/protocols/network/request.ts +++ b/packages/uni-api/src/protocols/network/request.ts @@ -43,28 +43,16 @@ function stringifyQuery(url: string, data: Record) { } export const RequestProtocol: ApiProtocol = { - method: { - type: String as any, - }, - data: { - type: [Object, String, Array, ArrayBuffer], - }, + method: String as any, + data: [Object, String, Array, ArrayBuffer], url: { type: String, required: true, }, - header: { - type: Object, - }, - dataType: { - type: String, - }, - responseType: { - type: String, - }, - withCredentials: { - type: Boolean, - }, + header: Object, + dataType: String, + responseType: String, + withCredentials: Boolean, } export const RequestOptions: ApiOptions = { @@ -88,7 +76,7 @@ export const RequestOptions: ApiOptions = { params.url = stringifyQuery(value, params.data) } }, - header(value, params) { + header(value: Record, params: Record) { const header = (params.header = value || {}) if (params.method !== HTTP_METHODS[0]) { if ( diff --git a/packages/uni-api/src/protocols/network/uploadFile.ts b/packages/uni-api/src/protocols/network/uploadFile.ts index ab2e6bcda2a2d875650f31339bee9eff88a0d059..89d8d1b5e3b9a649a995c2ef94e39d09979e7dc2 100644 --- a/packages/uni-api/src/protocols/network/uploadFile.ts +++ b/packages/uni-api/src/protocols/network/uploadFile.ts @@ -2,10 +2,10 @@ export const API_UPLOAD_FILE = 'uploadFile' export type API_TYPE_UPLOAD_FILE = typeof uni.uploadFile export const UploadFileOptions: ApiOptions = { formatArgs: { - header(value, params) { + header(value: Record, params: Record) { params.header = value || {} }, - formData(value, params) { + formData(value: Record, params: Record) { params.formData = value || {} }, }, @@ -16,9 +16,7 @@ export const UploadFileProtocol: ApiProtocol = { type: String, required: true, }, - files: { - type: Array, - }, + files: Array, filePath: String, name: String, header: Object, diff --git a/packages/uni-api/src/protocols/ui/popup.js b/packages/uni-api/src/protocols/ui/popup.js deleted file mode 100644 index 3fcca2630cb4a7336d9197d2c9e8b1e38f9d880f..0000000000000000000000000000000000000000 --- a/packages/uni-api/src/protocols/ui/popup.js +++ /dev/null @@ -1,117 +0,0 @@ -import getRealPath from 'uni-platform/helpers/get-real-path' - -export const showModal = { - title: { - type: String, - default: '' - }, - content: { - type: String, - default: '' - }, - showCancel: { - type: Boolean, - default: true - }, - cancelText: { - type: String, - default: '取消' - }, - cancelColor: { - type: String, - default: '#000000' - }, - confirmText: { - type: String, - default: '确定' - }, - confirmColor: { - type: String, - default: '#007aff' - }, - visible: { - type: Boolean, - default: true - } -} - -export const showToast = { - title: { - type: String, - default: '' - }, - icon: { - default: 'success', - validator(icon, params) { - if (['success', 'loading', 'none'].indexOf(icon) === -1) { - params.icon = 'success' - } - } - }, - image: { - type: String, - default: '', - validator(image, params) { - if (image) { - params.image = getRealPath(image) - } - } - }, - duration: { - type: Number, - default: 1500 - }, - mask: { - type: Boolean, - default: false - }, - visible: { - type: Boolean, - default: true - } -} -export const showLoading = { - title: { - type: String, - default: '' - }, - icon: { - type: String, - default: 'loading' - }, - duration: { - type: Number, - default: 100000000 // 简单处理 showLoading,直接设置个大值 - }, - mask: { - type: Boolean, - default: false - }, - visible: { - type: Boolean, - default: true - } -} - -export const showActionSheet = { - itemList: { - type: Array, - required: true, - validator(itemList, params) { - if (!itemList.length) { - return 'parameter.itemList should have at least 1 item' - } - } - }, - itemColor: { - type: String, - default: '#000000' - }, - visible: { - type: Boolean, - default: true - }, - popover: { - type: Object - } -} diff --git a/packages/uni-api/src/protocols/ui/popup.ts b/packages/uni-api/src/protocols/ui/popup.ts new file mode 100644 index 0000000000000000000000000000000000000000..e74604027be56da316c498c3730f6f0c62de9dff --- /dev/null +++ b/packages/uni-api/src/protocols/ui/popup.ts @@ -0,0 +1,104 @@ +import { hasOwn } from '@vue/shared' +import { useI18n, initI18nShowModalMsgs } from '@dcloudio/uni-core' +import { PRIMARY_COLOR } from '@dcloudio//uni-shared' +import { getRealPath } from '@dcloudio/uni-platform' +export const API_SHOW_MODAL = 'showModal' +export type API_TYPE_SHOW_MODAL = typeof uni.showModal + +const { t } = useI18n() + +export const ShowModalProtocol: ApiProtocol = { + title: String, + content: String, + showCancel: Boolean, + cancelText: String, + cancelColor: String, + confirmText: String, + confirmColor: String, +} +let isInitI18nShowModalMsgs = false +export const ShowModalOptions: ApiOptions = { + beforeInvoke() { + // dynamic init (tree shaking) + if (isInitI18nShowModalMsgs) { + return + } + isInitI18nShowModalMsgs = true + initI18nShowModalMsgs() + }, + formatArgs: { + title: '', + content: '', + showCancel: true, + cancelText(_value, params) { + if (!hasOwn(params, 'cancelText')) { + params.cancelText = t('uni.showModal.cancel') + } + }, + cancelColor: '#000', + confirmText(_value, params) { + if (!hasOwn(params, 'confirmText')) { + params.confirmText = t('uni.showModal.confirm') + } + }, + confirmColor: PRIMARY_COLOR, + }, +} +export const API_SHOW_TOAST = 'showToast' +export type API_TYPE_SHOW_TOAST = typeof uni.showToast +export const ShowToastProtocol: ApiProtocol = { + title: String, + icon: String as any, + image: String, + duration: Number, + mask: Boolean, +} +export const ShowToastOptions: ApiOptions = { + formatArgs: { + title: '', + icon(value, params) { + if (['success', 'loading', 'none'].indexOf(value!) === -1) { + params.icon = 'success' + } + }, + image(value, params) { + if (value) { + params.image = getRealPath(value) + } + }, + duration: 1500, + mask: false, + }, +} +export const API_SHOW_LOADING = 'showLoading' +export type API_TYPE_SHOW_LOADING = typeof uni.showLoading +export const ShowLoadingProtocol: ApiProtocol = { + title: String, + mask: Boolean, +} +export const ShowLoadingOptions: ApiOptions = { + formatArgs: { + title: '', + mask: false, + }, +} + +export const API_SHOW_ACTION_SHEET = 'showActionSheet' +export type API_TYPE_SHOW_ACTION_SHEET = typeof uni.showActionSheet +export const ShowActionSheetProtocol: ApiProtocol = { + itemList: { + type: Array, + required: true, + }, + itemColor: String, +} +export const ShowActionSheetOptions: ApiOptions = { + formatArgs: { + itemColor: '#000', + }, +} + +export const API_HIDE_TOAST = 'hideToast' +export type API_TYPE_HIDE_TOAST = typeof uni.hideToast +export const API_HIDE_LOADING = 'hideLoading' +export type API_TYPE_HIDE_LOADING = typeof uni.hideLoading diff --git a/packages/uni-api/src/type.ts b/packages/uni-api/src/type.ts index af31f3cd4ed1e13a4c48f7283c21cb9bc8ae52e6..2744a6670993fa15a4eb3a8c43dfc8bcbc56f899 100644 --- a/packages/uni-api/src/type.ts +++ b/packages/uni-api/src/type.ts @@ -22,7 +22,7 @@ interface ApiOptions> { beforeAll?: (res: unknown) => void beforeSuccess?: (res: unknown) => void formatArgs?: { - [K in keyof P]?: ApiArgsValidator + [K in keyof P]?: ApiArgsValidator | P[K] } } diff --git a/packages/uni-components/src/components/button/index.tsx b/packages/uni-components/src/components/button/index.tsx index 433a2647333d5cd990cd55bff6ab25853b5fc5ee..26a3afc859e62b1f8e20121dae3ee3789bfb1184 100644 --- a/packages/uni-components/src/components/button/index.tsx +++ b/packages/uni-components/src/components/button/index.tsx @@ -1,9 +1,13 @@ import { defineComponent, inject } from 'vue' -import { useI18n } from '@dcloudio/uni-core' +import { useI18n, initI18nButtonMsgs } from '@dcloudio/uni-core' import { useHover } from '../../helpers/useHover' import { useBooleanAttr } from '../../helpers/useBooleanAttr' import { UniFormCtx, uniFormKey } from '../form' +if (__PLATFORM__ === 'app-plus') { + initI18nButtonMsgs() +} + export default defineComponent({ name: 'Button', props: { diff --git a/packages/uni-core/src/helpers/i18n/index.ts b/packages/uni-core/src/helpers/i18n/index.ts deleted file mode 100644 index 12cb581e5fa6bd3d6bb939e34551764e3c1c68f3..0000000000000000000000000000000000000000 --- a/packages/uni-core/src/helpers/i18n/index.ts +++ /dev/null @@ -1,26 +0,0 @@ -import { initVueI18n } from '@dcloudio/uni-i18n' - -import en from './en.json' -import es from './es.json' -import fr from './fr.json' -import zhHans from './zh-Hans.json' -import zhHant from './zh-Hant.json' - -const messages = { - en, - es, - fr, - 'zh-Hans': zhHans, - 'zh-Hant': zhHant, -} - -const fallbackLocale = 'en' - -const i18n = /*#__PURE__*/ initVueI18n( - __PLATFORM__ === 'app-plus' || __PLATFORM__ === 'h5' ? messages : {}, - fallbackLocale -) - -export function useI18n() { - return i18n -} diff --git a/packages/uni-core/src/helpers/index.ts b/packages/uni-core/src/helpers/index.ts index 5516b9994405a71f14c56034eac300d69ebb4872..44af56a36823079db8c8a15866f2c6f5aeb5ac07 100644 --- a/packages/uni-core/src/helpers/index.ts +++ b/packages/uni-core/src/helpers/index.ts @@ -1,5 +1,4 @@ export * from './util' export * from './icon' -export * from './i18n' export * from './getRealRoute' export * from './getWindowOffset' diff --git a/packages/uni-core/src/helpers/i18n/en.json b/packages/uni-core/src/i18n/en.json similarity index 100% rename from packages/uni-core/src/helpers/i18n/en.json rename to packages/uni-core/src/i18n/en.json diff --git a/packages/uni-core/src/helpers/i18n/es.json b/packages/uni-core/src/i18n/es.json similarity index 100% rename from packages/uni-core/src/helpers/i18n/es.json rename to packages/uni-core/src/i18n/es.json diff --git a/packages/uni-core/src/helpers/i18n/fr.json b/packages/uni-core/src/i18n/fr.json similarity index 100% rename from packages/uni-core/src/helpers/i18n/fr.json rename to packages/uni-core/src/i18n/fr.json diff --git a/packages/uni-core/src/i18n/index.ts b/packages/uni-core/src/i18n/index.ts new file mode 100644 index 0000000000000000000000000000000000000000..d9fe7511025079db440d760b582f13197e0b2406 --- /dev/null +++ b/packages/uni-core/src/i18n/index.ts @@ -0,0 +1,2 @@ +export * from './useI18n' +export * from './messages' diff --git a/packages/uni-core/src/i18n/messages.ts b/packages/uni-core/src/i18n/messages.ts new file mode 100644 index 0000000000000000000000000000000000000000..8598ea1373b865d9ca70571804741ab6878c02eb --- /dev/null +++ b/packages/uni-core/src/i18n/messages.ts @@ -0,0 +1,634 @@ +// This file is created by scripts/i18n.js +// Do not modify this file!!!!!!!!! +import { + LOCALE_EN, + LOCALE_ES, + LOCALE_FR, + LOCALE_ZH_HANS, + LOCALE_ZH_HANT, +} from '@dcloudio/uni-i18n' +import { useI18n } from './useI18n' +const i18n = useI18n() +function normalizeMessages( + namespace: string, + messages: Record +) { + return Object.keys(messages).reduce>((res, name) => { + res[namespace + name] = messages[name] + return res + }, {}) +} +export function initI18nAppMsgs() { + const name = 'uni.app.' + if (__UNI_FEATURE_I18N_EN__) { + i18n.add( + LOCALE_EN, + normalizeMessages(name, { quit: 'Press back button again to exit' }) + ) + } + if (__UNI_FEATURE_I18N_ES__) { + i18n.add( + LOCALE_ES, + normalizeMessages(name, { quit: 'Pulse otra vez para salir' }) + ) + } + if (__UNI_FEATURE_I18N_FR__) { + i18n.add( + LOCALE_FR, + normalizeMessages(name, { + quit: "Appuyez à nouveau pour quitter l'application", + }) + ) + } + if (__UNI_FEATURE_I18N_ZH_HANS__) { + i18n.add( + LOCALE_ZH_HANS, + normalizeMessages(name, { quit: '再按一次退出应用' }) + ) + } + if (__UNI_FEATURE_I18N_ZH_HANT__) { + i18n.add( + LOCALE_ZH_HANT, + normalizeMessages(name, { quit: '再按一次退出應用' }) + ) + } +} +export function initI18nAsyncMsgs() { + const name = 'uni.async.' + if (__UNI_FEATURE_I18N_EN__) { + i18n.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, { + error: + 'Se agotó el tiempo de conexión, haga clic en la pantalla para volver a intentarlo.', + }) + ) + } + if (__UNI_FEATURE_I18N_FR__) { + i18n.add( + LOCALE_FR, + normalizeMessages(name, { + error: "La connexion a expiré, cliquez sur l'écran pour réessayer.", + }) + ) + } + if (__UNI_FEATURE_I18N_ZH_HANS__) { + i18n.add( + LOCALE_ZH_HANS, + normalizeMessages(name, { error: '连接服务器超时,点击屏幕重试' }) + ) + } + if (__UNI_FEATURE_I18N_ZH_HANT__) { + i18n.add( + LOCALE_ZH_HANT, + normalizeMessages(name, { error: '連接服務器超時,點擊屏幕重試' }) + ) + } +} +export function initI18nShowActionSheetMsgs() { + const name = 'uni.showActionSheet.' + if (__UNI_FEATURE_I18N_EN__) { + i18n.add(LOCALE_EN, normalizeMessages(name, { cancel: 'Cancel' })) + } + if (__UNI_FEATURE_I18N_ES__) { + i18n.add(LOCALE_ES, normalizeMessages(name, { cancel: 'Cancelar' })) + } + if (__UNI_FEATURE_I18N_FR__) { + i18n.add(LOCALE_FR, normalizeMessages(name, { cancel: 'Annuler' })) + } + if (__UNI_FEATURE_I18N_ZH_HANS__) { + i18n.add(LOCALE_ZH_HANS, normalizeMessages(name, { cancel: '取消' })) + } + if (__UNI_FEATURE_I18N_ZH_HANT__) { + i18n.add(LOCALE_ZH_HANT, normalizeMessages(name, { cancel: '取消' })) + } +} +export function initI18nShowToastMsgs() { + const name = 'uni.showToast.' + if (__UNI_FEATURE_I18N_EN__) { + i18n.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, { + unpaired: + 'Tenga en cuenta que showToast debe estar emparejado con hideToast', + }) + ) + } + if (__UNI_FEATURE_I18N_FR__) { + i18n.add( + LOCALE_FR, + normalizeMessages(name, { + unpaired: 'Veuillez noter que showToast doit être associé à hideToast', + }) + ) + } + if (__UNI_FEATURE_I18N_ZH_HANS__) { + i18n.add( + LOCALE_ZH_HANS, + normalizeMessages(name, { + unpaired: '请注意 showToast 与 hideToast 必须配对使用', + }) + ) + } + if (__UNI_FEATURE_I18N_ZH_HANT__) { + i18n.add( + LOCALE_ZH_HANT, + normalizeMessages(name, { + unpaired: '請注意 showToast 與 hideToast 必須配對使用', + }) + ) + } +} +export function initI18nShowLoadingMsgs() { + const name = 'uni.showLoading.' + if (__UNI_FEATURE_I18N_EN__) { + i18n.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, { + unpaired: + 'Tenga en cuenta que showLoading debe estar emparejado con hideLoading', + }) + ) + } + if (__UNI_FEATURE_I18N_FR__) { + i18n.add( + LOCALE_FR, + normalizeMessages(name, { + unpaired: + 'Veuillez noter que showLoading doit être associé à hideLoading', + }) + ) + } + if (__UNI_FEATURE_I18N_ZH_HANS__) { + i18n.add( + LOCALE_ZH_HANS, + normalizeMessages(name, { + unpaired: '请注意 showLoading 与 hideLoading 必须配对使用', + }) + ) + } + if (__UNI_FEATURE_I18N_ZH_HANT__) { + i18n.add( + LOCALE_ZH_HANT, + normalizeMessages(name, { + unpaired: '請注意 showLoading 與 hideLoading 必須配對使用', + }) + ) + } +} +export function initI18nShowModalMsgs() { + const name = 'uni.showModal.' + if (__UNI_FEATURE_I18N_EN__) { + i18n.add( + LOCALE_EN, + normalizeMessages(name, { cancel: 'Cancel', confirm: 'OK' }) + ) + } + if (__UNI_FEATURE_I18N_ES__) { + i18n.add( + LOCALE_ES, + normalizeMessages(name, { cancel: 'Cancelar', confirm: 'OK' }) + ) + } + if (__UNI_FEATURE_I18N_FR__) { + i18n.add( + LOCALE_FR, + normalizeMessages(name, { cancel: 'Annuler', confirm: 'OK' }) + ) + } + if (__UNI_FEATURE_I18N_ZH_HANS__) { + i18n.add( + LOCALE_ZH_HANS, + normalizeMessages(name, { cancel: '取消', confirm: '确定' }) + ) + } + if (__UNI_FEATURE_I18N_ZH_HANT__) { + i18n.add( + LOCALE_ZH_HANT, + normalizeMessages(name, { cancel: '取消', confirm: '確定' }) + ) + } +} +export function initI18nChooseImageMsgs() { + const name = 'uni.chooseImage.' + if (__UNI_FEATURE_I18N_EN__) { + i18n.add( + LOCALE_EN, + normalizeMessages(name, { + cancel: 'Cancel', + 'sourceType.album': 'Album', + 'sourceType.camera': 'Camera', + }) + ) + } + if (__UNI_FEATURE_I18N_ES__) { + i18n.add( + LOCALE_ES, + normalizeMessages(name, { + cancel: 'Cancelar', + 'sourceType.album': 'Álbum', + 'sourceType.camera': 'Cámara', + }) + ) + } + if (__UNI_FEATURE_I18N_FR__) { + i18n.add( + LOCALE_FR, + normalizeMessages(name, { + cancel: 'Annuler', + 'sourceType.album': 'Album', + 'sourceType.camera': 'Caméra', + }) + ) + } + if (__UNI_FEATURE_I18N_ZH_HANS__) { + i18n.add( + LOCALE_ZH_HANS, + normalizeMessages(name, { + cancel: '取消', + 'sourceType.album': '从相册选择', + 'sourceType.camera': '拍摄', + }) + ) + } + if (__UNI_FEATURE_I18N_ZH_HANT__) { + i18n.add( + LOCALE_ZH_HANT, + normalizeMessages(name, { + cancel: '取消', + 'sourceType.album': '從相冊選擇', + 'sourceType.camera': '拍攝', + }) + ) + } +} +export function initI18nChooseVideoMsgs() { + const name = 'uni.chooseVideo.' + if (__UNI_FEATURE_I18N_EN__) { + i18n.add( + LOCALE_EN, + normalizeMessages(name, { + cancel: 'Cancel', + 'sourceType.album': 'Album', + 'sourceType.camera': 'Camera', + }) + ) + } + if (__UNI_FEATURE_I18N_ES__) { + i18n.add( + LOCALE_ES, + normalizeMessages(name, { + cancel: 'Cancelar', + 'sourceType.album': 'Álbum', + 'sourceType.camera': 'Cámara', + }) + ) + } + if (__UNI_FEATURE_I18N_FR__) { + i18n.add( + LOCALE_FR, + normalizeMessages(name, { + cancel: 'Annuler', + 'sourceType.album': 'Album', + 'sourceType.camera': 'Caméra', + }) + ) + } + if (__UNI_FEATURE_I18N_ZH_HANS__) { + i18n.add( + LOCALE_ZH_HANS, + normalizeMessages(name, { + cancel: '取消', + 'sourceType.album': '从相册选择', + 'sourceType.camera': '拍摄', + }) + ) + } + if (__UNI_FEATURE_I18N_ZH_HANT__) { + i18n.add( + LOCALE_ZH_HANT, + normalizeMessages(name, { + cancel: '取消', + 'sourceType.album': '從相冊選擇', + 'sourceType.camera': '拍攝', + }) + ) + } +} +export function initI18nPreviewImageMsgs() { + const name = 'uni.previewImage.' + if (__UNI_FEATURE_I18N_EN__) { + i18n.add( + LOCALE_EN, + normalizeMessages(name, { + cancel: 'Cancel', + 'button.save': 'Save Image', + 'save.success': 'Saved successfully', + 'save.fail': 'Save failed', + }) + ) + } + if (__UNI_FEATURE_I18N_ES__) { + i18n.add( + LOCALE_ES, + normalizeMessages(name, { + cancel: 'Cancelar', + 'button.save': 'Guardar imagen', + 'save.success': 'Guardado exitosamente', + 'save.fail': 'Error al guardar', + }) + ) + } + if (__UNI_FEATURE_I18N_FR__) { + i18n.add( + LOCALE_FR, + normalizeMessages(name, { + cancel: 'Annuler', + 'button.save': 'Guardar imagen', + 'save.success': 'Enregistré avec succès', + 'save.fail': 'Échec de la sauvegarde', + }) + ) + } + if (__UNI_FEATURE_I18N_ZH_HANS__) { + i18n.add( + LOCALE_ZH_HANS, + normalizeMessages(name, { + cancel: '取消', + 'button.save': '保存图像', + 'save.success': '保存图像到相册成功', + 'save.fail': '保存图像到相册失败', + }) + ) + } + if (__UNI_FEATURE_I18N_ZH_HANT__) { + i18n.add( + LOCALE_ZH_HANT, + normalizeMessages(name, { + cancel: '取消', + 'button.save': '保存圖像', + 'save.success': '保存圖像到相冊成功', + 'save.fail': '保存圖像到相冊失敗', + }) + ) + } +} +export function initI18nSetClipboardDataMsgs() { + const name = 'uni.setClipboardData.' + if (__UNI_FEATURE_I18N_EN__) { + i18n.add(LOCALE_EN, normalizeMessages(name, { success: 'Content copied' })) + } + if (__UNI_FEATURE_I18N_ES__) { + i18n.add( + LOCALE_ES, + normalizeMessages(name, { success: 'Contenido copiado' }) + ) + } + if (__UNI_FEATURE_I18N_FR__) { + i18n.add(LOCALE_FR, normalizeMessages(name, { success: 'Contenu copié' })) + } + if (__UNI_FEATURE_I18N_ZH_HANS__) { + i18n.add(LOCALE_ZH_HANS, normalizeMessages(name, { success: '内容已复制' })) + } + if (__UNI_FEATURE_I18N_ZH_HANT__) { + i18n.add(LOCALE_ZH_HANT, normalizeMessages(name, { success: '內容已復制' })) + } +} +export function initI18nScanCodeMsgs() { + const name = 'uni.scanCode.' + if (__UNI_FEATURE_I18N_EN__) { + i18n.add( + LOCALE_EN, + normalizeMessages(name, { + title: 'Scan code', + album: 'Album', + fail: 'Recognition failure', + 'flash.on': 'Tap to turn light on', + 'flash.off': 'Tap to turn light off', + }) + ) + } + if (__UNI_FEATURE_I18N_ES__) { + i18n.add( + LOCALE_ES, + normalizeMessages(name, { + title: 'Código de escaneo', + album: 'Álbum', + fail: 'Échec de la reconnaissance', + 'flash.on': 'Toque para encender la luz', + 'flash.off': 'Toque para apagar la luz', + }) + ) + } + if (__UNI_FEATURE_I18N_FR__) { + i18n.add( + LOCALE_FR, + normalizeMessages(name, { + title: 'Code d’analyse', + album: 'Album', + fail: 'Fallo de reconocimiento', + 'flash.on': "Appuyez pour activer l'éclairage", + 'flash.off': "Appuyez pour désactiver l'éclairage", + }) + ) + } + if (__UNI_FEATURE_I18N_ZH_HANS__) { + i18n.add( + LOCALE_ZH_HANS, + normalizeMessages(name, { + title: '扫码', + album: '相册', + fail: '识别失败', + 'flash.on': '轻触照亮', + 'flash.off': '轻触关闭', + }) + ) + } + if (__UNI_FEATURE_I18N_ZH_HANT__) { + i18n.add( + LOCALE_ZH_HANT, + normalizeMessages(name, { + title: '掃碼', + album: '相冊', + fail: '識別失敗', + 'flash.on': '輕觸照亮', + 'flash.off': '輕觸關閉', + }) + ) + } +} +export function initI18nStartSoterAuthenticationMsgs() { + const name = 'uni.startSoterAuthentication.' + if (__UNI_FEATURE_I18N_EN__) { + i18n.add( + LOCALE_EN, + normalizeMessages(name, { authContent: 'Fingerprint recognition' }) + ) + } + if (__UNI_FEATURE_I18N_ES__) { + i18n.add( + LOCALE_ES, + normalizeMessages(name, { + authContent: 'Reconocimiento de huellas dactilares', + }) + ) + } + if (__UNI_FEATURE_I18N_FR__) { + i18n.add( + LOCALE_FR, + normalizeMessages(name, { + authContent: "Reconnaissance de l'empreinte digitale", + }) + ) + } + if (__UNI_FEATURE_I18N_ZH_HANS__) { + i18n.add( + LOCALE_ZH_HANS, + normalizeMessages(name, { authContent: '指纹识别中...' }) + ) + } + if (__UNI_FEATURE_I18N_ZH_HANT__) { + i18n.add( + LOCALE_ZH_HANT, + normalizeMessages(name, { authContent: '指紋識別中...' }) + ) + } +} +export function initI18nPickerMsgs() { + const name = 'uni.picker.' + if (__UNI_FEATURE_I18N_EN__) { + i18n.add( + LOCALE_EN, + normalizeMessages(name, { done: 'Done', cancel: 'Cancel' }) + ) + } + if (__UNI_FEATURE_I18N_ES__) { + i18n.add( + LOCALE_ES, + normalizeMessages(name, { done: 'OK', cancel: 'Cancelar' }) + ) + } + if (__UNI_FEATURE_I18N_FR__) { + i18n.add( + LOCALE_FR, + normalizeMessages(name, { done: 'OK', cancel: 'Annuler' }) + ) + } + if (__UNI_FEATURE_I18N_ZH_HANS__) { + i18n.add( + LOCALE_ZH_HANS, + normalizeMessages(name, { done: '完成', cancel: '取消' }) + ) + } + if (__UNI_FEATURE_I18N_ZH_HANT__) { + i18n.add( + LOCALE_ZH_HANT, + normalizeMessages(name, { done: '完成', cancel: '取消' }) + ) + } +} +export function initI18nVideoMsgs() { + const name = 'uni.video.' + if (__UNI_FEATURE_I18N_EN__) { + i18n.add( + LOCALE_EN, + normalizeMessages(name, { danmu: 'Danmu', volume: 'Volume' }) + ) + } + if (__UNI_FEATURE_I18N_ES__) { + i18n.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' }) + ) + } + if (__UNI_FEATURE_I18N_ZH_HANS__) { + i18n.add( + LOCALE_ZH_HANS, + normalizeMessages(name, { danmu: '弹幕', volume: '音量' }) + ) + } + if (__UNI_FEATURE_I18N_ZH_HANT__) { + i18n.add( + LOCALE_ZH_HANT, + normalizeMessages(name, { danmu: '彈幕', volume: '音量' }) + ) + } +} +export function initI18nButtonMsgs() { + const name = 'uni.button.' + if (__UNI_FEATURE_I18N_EN__) { + i18n.add( + LOCALE_EN, + normalizeMessages(name, { + 'feedback.title': 'feedback', + 'feedback.send': 'send', + }) + ) + } + if (__UNI_FEATURE_I18N_ES__) { + i18n.add( + LOCALE_ES, + normalizeMessages(name, { + 'feedback.title': 'realimentación', + 'feedback.send': 'enviar', + }) + ) + } + if (__UNI_FEATURE_I18N_FR__) { + i18n.add( + LOCALE_FR, + normalizeMessages(name, { + 'feedback.title': "retour d'information", + 'feedback.send': 'envoyer', + }) + ) + } + if (__UNI_FEATURE_I18N_ZH_HANS__) { + i18n.add( + LOCALE_ZH_HANS, + normalizeMessages(name, { + 'feedback.title': '问题反馈', + 'feedback.send': '发送', + }) + ) + } + if (__UNI_FEATURE_I18N_ZH_HANT__) { + i18n.add( + LOCALE_ZH_HANT, + normalizeMessages(name, { + 'feedback.title': '問題反饋', + 'feedback.send': '發送', + }) + ) + } +} diff --git a/packages/uni-core/src/i18n/useI18n.ts b/packages/uni-core/src/i18n/useI18n.ts new file mode 100644 index 0000000000000000000000000000000000000000..1e1c183b542635a1ba18af3b9cbb7700b3eca6bc --- /dev/null +++ b/packages/uni-core/src/i18n/useI18n.ts @@ -0,0 +1,6 @@ +import { initVueI18n } from '@dcloudio/uni-i18n' +const i18n = initVueI18n() + +export function useI18n() { + return i18n +} diff --git a/packages/uni-core/src/helpers/i18n/zh-Hans.json b/packages/uni-core/src/i18n/zh-Hans.json similarity index 100% rename from packages/uni-core/src/helpers/i18n/zh-Hans.json rename to packages/uni-core/src/i18n/zh-Hans.json diff --git a/packages/uni-core/src/helpers/i18n/zh-Hant.json b/packages/uni-core/src/i18n/zh-Hant.json similarity index 100% rename from packages/uni-core/src/helpers/i18n/zh-Hant.json rename to packages/uni-core/src/i18n/zh-Hant.json diff --git a/packages/uni-core/src/index.ts b/packages/uni-core/src/index.ts index bf4b07117b7e8c4b48962096d66d8d55a851b8df..9df09ed2d70c80e2f348609f321cfc2ab2393d99 100644 --- a/packages/uni-core/src/index.ts +++ b/packages/uni-core/src/index.ts @@ -1,3 +1,4 @@ +export * from './i18n' export * from './view' export * from './service' export * from './helpers' diff --git a/packages/uni-h5-vue/dist/vue.runtime.esm.js b/packages/uni-h5-vue/dist/vue.runtime.esm.js index 9ba6001fdb7eb2bd0c6bbeba31f6364b02df59aa..052a3bc5f4caa1ed046d0f207a477c03d99cba04 100644 --- a/packages/uni-h5-vue/dist/vue.runtime.esm.js +++ b/packages/uni-h5-vue/dist/vue.runtime.esm.js @@ -6982,7 +6982,6 @@ function applyOptions$1(instance, options, deferredData = [], deferredWatch = [] } } } -// fixed by xxxxxx function callSyncHook(name, type, options, instance, globalMixins) { for (let i = 0; i < globalMixins.length; i++) { callHookWithMixinAndExtends(name, type, globalMixins[i], instance); @@ -9491,4 +9490,4 @@ function initApp(app) { } } -export { BaseTransition, Comment, Fragment, KeepAlive, Static, Suspense, Teleport, Text, Transition, TransitionGroup, callSyncHook, callWithAsyncErrorHandling, callWithErrorHandling, cloneVNode, compile$1 as compile, computed$1 as computed, createApp, createBlock, createCommentVNode, createHook, createHydrationRenderer, createRenderer, createSSRApp, createSlots, createStaticVNode, createTextVNode, createVNode, createApp as createVueApp, createSSRApp as createVueSSRApp, customRef, defineAsyncComponent, defineComponent, defineEmit, defineProps, devtools, getCurrentInstance, getTransitionRawChildren, h, handleError, hydrate, initApp, initCustomFormatter, inject, injectHook, isInSSRComponentSetup, isProxy, isReactive, isReadonly, isRef, isRuntimeOnly, isVNode, markRaw, mergeProps, nextTick, onActivated, onAddToFavorites, onBackPress, onBeforeActivate, onBeforeDeactivate, onBeforeMount, onBeforeUnmount, onBeforeUpdate, onDeactivated, onError, onErrorCaptured, onHide, onLaunch, onMounted, onNavigationBarButtonTap, onNavigationBarSearchInputChanged, onNavigationBarSearchInputClicked, onNavigationBarSearchInputConfirmed, onNavigationBarSearchInputFocusChanged, onPageNotFound, onPageScroll, onPullDownRefresh, onReachBottom, onReady, onRenderTracked, onRenderTriggered, onResize, onShareAppMessage, onShareTimeline, onShow, onTabItemTap, onThemeChange, onUnhandledRejection, onUnload, onUnmounted, onUpdated, openBlock, popScopeId, provide, proxyRefs, pushScopeId, queuePostFlushCb, reactive, readonly, ref, registerRuntimeCompiler, render, renderList, renderSlot, resolveComponent, resolveDirective, resolveDynamicComponent, resolveTransitionHooks, setBlockTracking, setDevtoolsHook, setTransitionHooks, shallowReactive, shallowReadonly, shallowRef, ssrContextKey, ssrUtils, toHandlers, toRaw, toRef, toRefs, transformVNodeArgs, triggerRef, unref, useContext, useCssModule, useCssVars, useSSRContext, useTransitionState, vModelCheckbox, vModelDynamic, vModelRadio, vModelSelect, vModelText, vShow, version, warn, watch, watchEffect, withCtx, withDirectives, withKeys, withModifiers, withScopeId }; +export { BaseTransition, Comment, Fragment, KeepAlive, Static, Suspense, Teleport, Text, Transition, TransitionGroup, callWithAsyncErrorHandling, callWithErrorHandling, cloneVNode, compile$1 as compile, computed$1 as computed, createApp, createBlock, createCommentVNode, createHook, createHydrationRenderer, createRenderer, createSSRApp, createSlots, createStaticVNode, createTextVNode, createVNode, createApp as createVueApp, createSSRApp as createVueSSRApp, customRef, defineAsyncComponent, defineComponent, defineEmit, defineProps, devtools, getCurrentInstance, getTransitionRawChildren, h, handleError, hydrate, initApp, initCustomFormatter, inject, injectHook, isInSSRComponentSetup, isProxy, isReactive, isReadonly, isRef, isRuntimeOnly, isVNode, markRaw, mergeProps, nextTick, onActivated, onAddToFavorites, onBackPress, onBeforeActivate, onBeforeDeactivate, onBeforeMount, onBeforeUnmount, onBeforeUpdate, onDeactivated, onError, onErrorCaptured, onHide, onLaunch, onMounted, onNavigationBarButtonTap, onNavigationBarSearchInputChanged, onNavigationBarSearchInputClicked, onNavigationBarSearchInputConfirmed, onNavigationBarSearchInputFocusChanged, onPageNotFound, onPageScroll, onPullDownRefresh, onReachBottom, onReady, onRenderTracked, onRenderTriggered, onResize, onShareAppMessage, onShareTimeline, onShow, onTabItemTap, onThemeChange, onUnhandledRejection, onUnload, onUnmounted, onUpdated, openBlock, popScopeId, provide, proxyRefs, pushScopeId, queuePostFlushCb, reactive, readonly, ref, registerRuntimeCompiler, render, renderList, renderSlot, resolveComponent, resolveDirective, resolveDynamicComponent, resolveTransitionHooks, setBlockTracking, setDevtoolsHook, setTransitionHooks, shallowReactive, shallowReadonly, shallowRef, ssrContextKey, ssrUtils, toHandlers, toRaw, toRef, toRefs, transformVNodeArgs, triggerRef, unref, useContext, useCssModule, useCssVars, useSSRContext, useTransitionState, vModelCheckbox, vModelDynamic, vModelRadio, vModelSelect, vModelText, vShow, version, warn, watch, watchEffect, withCtx, withDirectives, withKeys, withModifiers, withScopeId }; diff --git a/packages/uni-h5-vue/lib/vue.runtime.esm.js b/packages/uni-h5-vue/lib/vue.runtime.esm.js index c1fac394ba5189b381410104dcf0d0c4bc5fea8a..2afff7026d8dc29920a1b3efb11eb221e17356de 100644 --- a/packages/uni-h5-vue/lib/vue.runtime.esm.js +++ b/packages/uni-h5-vue/lib/vue.runtime.esm.js @@ -6982,7 +6982,6 @@ function applyOptions(instance, options, deferredData = [], deferredWatch = [], } } } -// fixed by xxxxxx function callSyncHook(name, type, options, instance, globalMixins) { for (let i = 0; i < globalMixins.length; i++) { callHookWithMixinAndExtends(name, type, globalMixins[i], instance); @@ -9405,4 +9404,4 @@ const compile$1 = () => { } }; -export { BaseTransition, Comment, Fragment, KeepAlive, Static, Suspense, Teleport, Text, Transition, TransitionGroup, callSyncHook, callWithAsyncErrorHandling, callWithErrorHandling, cloneVNode, compile$1 as compile, computed$1 as computed, createApp, createBlock, createCommentVNode, createHydrationRenderer, createRenderer, createSSRApp, createSlots, createStaticVNode, createTextVNode, createVNode, createApp as createVueApp, createSSRApp as createVueSSRApp, customRef, defineAsyncComponent, defineComponent, defineEmit, defineProps, devtools, getCurrentInstance, getTransitionRawChildren, h, handleError, hydrate, initCustomFormatter, inject, injectHook, isInSSRComponentSetup, isProxy, isReactive, isReadonly, isRef, isRuntimeOnly, isVNode, markRaw, mergeProps, nextTick, onActivated, onBeforeActivate, onBeforeDeactivate, onBeforeMount, onBeforeUnmount, onBeforeUpdate, onDeactivated, onErrorCaptured, onMounted, onRenderTracked, onRenderTriggered, onUnmounted, onUpdated, openBlock, popScopeId, provide, proxyRefs, pushScopeId, queuePostFlushCb, reactive, readonly, ref, registerRuntimeCompiler, render, renderList, renderSlot, resolveComponent, resolveDirective, resolveDynamicComponent, resolveTransitionHooks, setBlockTracking, setDevtoolsHook, setTransitionHooks, shallowReactive, shallowReadonly, shallowRef, ssrContextKey, ssrUtils, toHandlers, toRaw, toRef, toRefs, transformVNodeArgs, triggerRef, unref, useContext, useCssModule, useCssVars, useSSRContext, useTransitionState, vModelCheckbox, vModelDynamic, vModelRadio, vModelSelect, vModelText, vShow, version, warn, watch, watchEffect, withCtx, withDirectives, withKeys, withModifiers, withScopeId }; +export { BaseTransition, Comment, Fragment, KeepAlive, Static, Suspense, Teleport, Text, Transition, TransitionGroup, callWithAsyncErrorHandling, callWithErrorHandling, cloneVNode, compile$1 as compile, computed$1 as computed, createApp, createBlock, createCommentVNode, createHydrationRenderer, createRenderer, createSSRApp, createSlots, createStaticVNode, createTextVNode, createVNode, createApp as createVueApp, createSSRApp as createVueSSRApp, customRef, defineAsyncComponent, defineComponent, defineEmit, defineProps, devtools, getCurrentInstance, getTransitionRawChildren, h, handleError, hydrate, initCustomFormatter, inject, injectHook, isInSSRComponentSetup, isProxy, isReactive, isReadonly, isRef, isRuntimeOnly, isVNode, markRaw, mergeProps, nextTick, onActivated, onBeforeActivate, onBeforeDeactivate, onBeforeMount, onBeforeUnmount, onBeforeUpdate, onDeactivated, onErrorCaptured, onMounted, onRenderTracked, onRenderTriggered, onUnmounted, onUpdated, openBlock, popScopeId, provide, proxyRefs, pushScopeId, queuePostFlushCb, reactive, readonly, ref, registerRuntimeCompiler, render, renderList, renderSlot, resolveComponent, resolveDirective, resolveDynamicComponent, resolveTransitionHooks, setBlockTracking, setDevtoolsHook, setTransitionHooks, shallowReactive, shallowReadonly, shallowRef, ssrContextKey, ssrUtils, toHandlers, toRaw, toRef, toRefs, transformVNodeArgs, triggerRef, unref, useContext, useCssModule, useCssVars, useSSRContext, useTransitionState, vModelCheckbox, vModelDynamic, vModelRadio, vModelSelect, vModelText, vShow, version, warn, watch, watchEffect, withCtx, withDirectives, withKeys, withModifiers, withScopeId }; diff --git a/packages/uni-h5/dist/uni-h5.esm.js b/packages/uni-h5/dist/uni-h5.esm.js index feb01d373c18b4b5c9da51c8cf8a4d8865f98198..67e55bcd8cac9e78244a02c8804a82d64bd6746f 100644 --- a/packages/uni-h5/dist/uni-h5.esm.js +++ b/packages/uni-h5/dist/uni-h5.esm.js @@ -1,6 +1,6 @@ import {isFunction, extend, isPlainObject, invokeArrayFns, isString, hasOwn as hasOwn$1, hyphenate, isArray, isObject as isObject$1, capitalize, toRawType, makeMap as makeMap$1, isPromise} from "@vue/shared"; import {injectHook, isInSSRComponentSetup, createVNode, inject, provide, reactive, computed, nextTick, getCurrentInstance, onBeforeMount, onMounted, onBeforeActivate, onBeforeDeactivate, openBlock, createBlock, mergeProps, toDisplayString, ref, defineComponent, resolveComponent, toHandlers, renderSlot, createCommentVNode, onBeforeUnmount, withModifiers, withDirectives, vShow, vModelDynamic, createTextVNode, Fragment, renderList, vModelText, watch, withCtx, KeepAlive, resolveDynamicComponent} from "vue"; -import {passive, NAVBAR_HEIGHT, removeLeadingSlash, plusReady, debounce, PRIMARY_COLOR, getLen} from "@dcloudio/uni-shared"; +import {passive, NAVBAR_HEIGHT, removeLeadingSlash, plusReady, debounce, PRIMARY_COLOR as PRIMARY_COLOR$1, getLen} from "@dcloudio/uni-shared"; import {useRoute, createRouter, createWebHistory, createWebHashHistory, isNavigationFailure, RouterView} from "vue-router"; function applyOptions(options, instance2, publicThis) { Object.keys(options).forEach((name) => { @@ -106,6 +106,300 @@ function initApp$1(app) { globalProperties.$applyOptions = applyOptions; } } +const isObject = (val) => val !== null && typeof val === "object"; +class BaseFormatter { + constructor() { + this._caches = Object.create(null); + } + interpolate(message, values) { + if (!values) { + return [message]; + } + let tokens = this._caches[message]; + if (!tokens) { + tokens = parse(message); + this._caches[message] = tokens; + } + return compile(tokens, values); + } +} +const RE_TOKEN_LIST_VALUE = /^(?:\d)+/; +const RE_TOKEN_NAMED_VALUE = /^(?:\w)+/; +function parse(format) { + const tokens = []; + let position = 0; + let text2 = ""; + while (position < format.length) { + let char = format[position++]; + if (char === "{") { + if (text2) { + tokens.push({type: "text", value: text2}); + } + text2 = ""; + let sub = ""; + char = format[position++]; + while (char !== void 0 && char !== "}") { + sub += char; + char = format[position++]; + } + const isClosed = char === "}"; + const type = RE_TOKEN_LIST_VALUE.test(sub) ? "list" : isClosed && RE_TOKEN_NAMED_VALUE.test(sub) ? "named" : "unknown"; + tokens.push({value: sub, type}); + } else if (char === "%") { + if (format[position] !== "{") { + text2 += char; + } + } else { + text2 += char; + } + } + text2 && tokens.push({type: "text", value: text2}); + return tokens; +} +function compile(tokens, values) { + const compiled = []; + let index2 = 0; + const mode = Array.isArray(values) ? "list" : isObject(values) ? "named" : "unknown"; + if (mode === "unknown") { + return compiled; + } + while (index2 < tokens.length) { + const token = tokens[index2]; + switch (token.type) { + case "text": + compiled.push(token.value); + break; + case "list": + compiled.push(values[parseInt(token.value, 10)]); + break; + case "named": + if (mode === "named") { + compiled.push(values[token.value]); + } + break; + } + index2++; + } + return compiled; +} +const LOCALE_ZH_HANS = "zh-Hans"; +const LOCALE_ZH_HANT = "zh-Hant"; +const LOCALE_EN = "en"; +const LOCALE_FR = "fr"; +const LOCALE_ES = "es"; +const hasOwnProperty = Object.prototype.hasOwnProperty; +const hasOwn = (val, key) => hasOwnProperty.call(val, key); +const defaultFormatter = new BaseFormatter(); +function include(str, parts) { + return !!parts.find((part) => str.indexOf(part) !== -1); +} +function startsWith(str, parts) { + return parts.find((part) => str.indexOf(part) === 0); +} +function normalizeLocale(locale, messages) { + if (!locale) { + return; + } + locale = locale.trim().replace(/_/g, "-"); + if (messages[locale]) { + return locale; + } + locale = locale.toLowerCase(); + if (locale.indexOf("zh") === 0) { + if (locale.indexOf("-hans") !== -1) { + return LOCALE_ZH_HANS; + } + if (locale.indexOf("-hant") !== -1) { + return LOCALE_ZH_HANT; + } + if (include(locale, ["-tw", "-hk", "-mo", "-cht"])) { + return LOCALE_ZH_HANT; + } + return LOCALE_ZH_HANS; + } + const lang = startsWith(locale, [LOCALE_EN, LOCALE_FR, LOCALE_ES]); + if (lang) { + return lang; + } +} +class I18n { + constructor({locale, fallbackLocale, messages, watcher, formater}) { + this.locale = LOCALE_EN; + this.fallbackLocale = LOCALE_EN; + this.message = {}; + this.messages = {}; + this.watchers = []; + if (fallbackLocale) { + this.fallbackLocale = fallbackLocale; + } + this.formater = formater || defaultFormatter; + this.messages = messages || {}; + this.setLocale(locale); + if (watcher) { + this.watchLocale(watcher); + } + } + setLocale(locale) { + const oldLocale = this.locale; + this.locale = normalizeLocale(locale, this.messages) || this.fallbackLocale; + this.message = this.messages[this.locale]; + this.watchers.forEach((watcher) => { + watcher(this.locale, oldLocale); + }); + } + getLocale() { + return this.locale; + } + watchLocale(fn) { + const index2 = this.watchers.push(fn) - 1; + return () => { + this.watchers.splice(index2, 1); + }; + } + add(locale, message) { + if (this.messages[locale]) { + Object.assign(this.messages[locale], message); + } else { + this.messages[locale] = message; + } + } + t(key, locale, values) { + let message = this.message; + if (typeof locale === "string") { + locale = normalizeLocale(locale, this.messages); + locale && (message = this.messages[locale]); + } else { + values = locale; + } + if (!hasOwn(message, key)) { + console.warn(`Cannot translate the value of keypath ${key}. Use the value of keypath as default.`); + return key; + } + return this.formater.interpolate(message[key], values).join(""); + } +} +function initLocaleWatcher(appVm2, i18n2) { + appVm2.$i18n && appVm2.$i18n.vm.$watch("locale", (newLocale) => { + i18n2.setLocale(newLocale); + }, { + immediate: true + }); +} +function getDefaultLocale() { + if (typeof navigator !== "undefined") { + return navigator.userLanguage || navigator.language; + } + if (typeof plus !== "undefined") { + return plus.os.language; + } + return uni.getSystemInfoSync().language; +} +function initVueI18n(messages = {}, fallbackLocale = LOCALE_EN, locale) { + const i18n2 = new I18n({ + locale: locale || fallbackLocale, + fallbackLocale, + messages + }); + let t2 = (key, values) => { + if (typeof getApp !== "function") { + t2 = function(key2, values2) { + return i18n2.t(key2, values2); + }; + } else { + const appVm2 = getApp().$vm; + if (!appVm2.$t || !appVm2.$i18n) { + if (!locale) { + i18n2.setLocale(getDefaultLocale()); + } + t2 = function(key2, values2) { + return i18n2.t(key2, values2); + }; + } else { + initLocaleWatcher(appVm2, i18n2); + t2 = function(key2, values2) { + const $i18n = appVm2.$i18n; + const silentTranslationWarn = $i18n.silentTranslationWarn; + $i18n.silentTranslationWarn = true; + const msg = appVm2.$t(key2, values2); + $i18n.silentTranslationWarn = silentTranslationWarn; + if (msg !== key2) { + return msg; + } + return i18n2.t(key2, $i18n.locale, values2); + }; + } + } + return t2(key, values); + }; + return { + i18n: i18n2, + t(key, values) { + return t2(key, values); + }, + add(locale2, message) { + return i18n2.add(locale2, message); + }, + getLocale() { + return i18n2.getLocale(); + }, + setLocale(newLocale) { + return i18n2.setLocale(newLocale); + } + }; +} +const i18n$1 = initVueI18n(); +function useI18n() { + return i18n$1; +} +const i18n = useI18n(); +function normalizeMessages(namespace, messages) { + return Object.keys(messages).reduce((res, name) => { + res[namespace + name] = messages[name]; + return res; + }, {}); +} +function initI18nAsyncMsgs() { + const name = "uni.async."; + if (__UNI_FEATURE_I18N_EN__) { + i18n.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, { + 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, { + 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"})); + } + 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"})); + } +} +function initI18nShowModalMsgs() { + const name = "uni.showModal."; + if (__UNI_FEATURE_I18N_EN__) { + i18n.add(LOCALE_EN, normalizeMessages(name, {cancel: "Cancel", confirm: "OK"})); + } + if (__UNI_FEATURE_I18N_ES__) { + i18n.add(LOCALE_ES, normalizeMessages(name, {cancel: "Cancelar", confirm: "OK"})); + } + if (__UNI_FEATURE_I18N_FR__) { + i18n.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"})); + } + if (__UNI_FEATURE_I18N_ZH_HANT__) { + i18n.add(LOCALE_ZH_HANT, normalizeMessages(name, {cancel: "\u53D6\u6D88", confirm: "\u78BA\u5B9A"})); + } +} function E() { } E.prototype = { @@ -823,426 +1117,6 @@ function createSvgIconVNode(path, color = "#000", size = 27) { }, null, 8, ["d", "fill"]) ], 8, ["width", "height"]); } -const isObject = (val) => val !== null && typeof val === "object"; -class BaseFormatter { - constructor() { - this._caches = Object.create(null); - } - interpolate(message, values) { - if (!values) { - return [message]; - } - let tokens = this._caches[message]; - if (!tokens) { - tokens = parse(message); - this._caches[message] = tokens; - } - return compile(tokens, values); - } -} -const RE_TOKEN_LIST_VALUE = /^(?:\d)+/; -const RE_TOKEN_NAMED_VALUE = /^(?:\w)+/; -function parse(format) { - const tokens = []; - let position = 0; - let text2 = ""; - while (position < format.length) { - let char = format[position++]; - if (char === "{") { - if (text2) { - tokens.push({type: "text", value: text2}); - } - text2 = ""; - let sub = ""; - char = format[position++]; - while (char !== void 0 && char !== "}") { - sub += char; - char = format[position++]; - } - const isClosed = char === "}"; - const type = RE_TOKEN_LIST_VALUE.test(sub) ? "list" : isClosed && RE_TOKEN_NAMED_VALUE.test(sub) ? "named" : "unknown"; - tokens.push({value: sub, type}); - } else if (char === "%") { - if (format[position] !== "{") { - text2 += char; - } - } else { - text2 += char; - } - } - text2 && tokens.push({type: "text", value: text2}); - return tokens; -} -function compile(tokens, values) { - const compiled = []; - let index2 = 0; - const mode = Array.isArray(values) ? "list" : isObject(values) ? "named" : "unknown"; - if (mode === "unknown") { - return compiled; - } - while (index2 < tokens.length) { - const token = tokens[index2]; - switch (token.type) { - case "text": - compiled.push(token.value); - break; - case "list": - compiled.push(values[parseInt(token.value, 10)]); - break; - case "named": - if (mode === "named") { - compiled.push(values[token.value]); - } - break; - } - index2++; - } - return compiled; -} -const hasOwnProperty = Object.prototype.hasOwnProperty; -const hasOwn = (val, key) => hasOwnProperty.call(val, key); -const defaultFormatter = new BaseFormatter(); -function include(str, parts) { - return !!parts.find((part) => str.indexOf(part) !== -1); -} -function startsWith(str, parts) { - return parts.find((part) => str.indexOf(part) === 0); -} -function normalizeLocale(locale, messages2) { - if (!locale) { - return; - } - locale = locale.trim().replace(/_/g, "-"); - if (messages2[locale]) { - return locale; - } - locale = locale.toLowerCase(); - if (locale.indexOf("zh") === 0) { - if (locale.indexOf("-hans") !== -1) { - return "zh-Hans"; - } - if (locale.indexOf("-hant") !== -1) { - return "zh-Hant"; - } - if (include(locale, ["-tw", "-hk", "-mo", "-cht"])) { - return "zh-Hant"; - } - return "zh-Hans"; - } - const lang = startsWith(locale, ["en", "fr", "es"]); - if (lang) { - return lang; - } -} -class I18n { - constructor({locale, fallbackLocale: fallbackLocale2, messages: messages2, watcher, formater}) { - this.locale = "en"; - this.fallbackLocale = "en"; - this.message = {}; - this.messages = {}; - this.watchers = []; - if (fallbackLocale2) { - this.fallbackLocale = fallbackLocale2; - } - this.formater = formater || defaultFormatter; - this.messages = messages2; - this.setLocale(locale); - if (watcher) { - this.watchLocale(watcher); - } - } - setLocale(locale) { - const oldLocale = this.locale; - this.locale = normalizeLocale(locale, this.messages) || this.fallbackLocale; - this.message = this.messages[this.locale]; - this.watchers.forEach((watcher) => { - watcher(this.locale, oldLocale); - }); - } - getLocale() { - return this.locale; - } - watchLocale(fn) { - const index2 = this.watchers.push(fn) - 1; - return () => { - this.watchers.splice(index2, 1); - }; - } - mergeLocaleMessage(locale, message) { - if (this.messages[locale]) { - Object.assign(this.messages[locale], message); - } else { - this.messages[locale] = message; - } - } - t(key, locale, values) { - let message = this.message; - if (typeof locale === "string") { - locale = normalizeLocale(locale, this.messages); - locale && (message = this.messages[locale]); - } else { - values = locale; - } - if (!hasOwn(message, key)) { - console.warn(`Cannot translate the value of keypath ${key}. Use the value of keypath as default.`); - return key; - } - return this.formater.interpolate(message[key], values).join(""); - } -} -function initLocaleWatcher(appVm2, i18n2) { - appVm2.$i18n && appVm2.$i18n.vm.$watch("locale", (newLocale) => { - i18n2.setLocale(newLocale); - }, { - immediate: true - }); -} -function getDefaultLocale() { - if (typeof navigator !== "undefined") { - return navigator.userLanguage || navigator.language; - } - if (typeof plus !== "undefined") { - return plus.os.language; - } - return uni.getSystemInfoSync().language; -} -function initVueI18n(messages2, fallbackLocale2 = "en", locale) { - const i18n2 = new I18n({ - locale: locale || fallbackLocale2, - fallbackLocale: fallbackLocale2, - messages: messages2 - }); - let t2 = (key, values) => { - if (typeof getApp !== "function") { - t2 = function(key2, values2) { - return i18n2.t(key2, values2); - }; - } else { - const appVm2 = getApp().$vm; - if (!appVm2.$t || !appVm2.$i18n) { - if (!locale) { - i18n2.setLocale(getDefaultLocale()); - } - t2 = function(key2, values2) { - return i18n2.t(key2, values2); - }; - } else { - initLocaleWatcher(appVm2, i18n2); - t2 = function(key2, values2) { - const $i18n = appVm2.$i18n; - const silentTranslationWarn = $i18n.silentTranslationWarn; - $i18n.silentTranslationWarn = true; - const msg = appVm2.$t(key2, values2); - $i18n.silentTranslationWarn = silentTranslationWarn; - if (msg !== key2) { - return msg; - } - return i18n2.t(key2, $i18n.locale, values2); - }; - } - } - return t2(key, values); - }; - return { - i18n: i18n2, - t(key, values) { - return t2(key, values); - }, - getLocale() { - return i18n2.getLocale(); - }, - setLocale(newLocale) { - return i18n2.setLocale(newLocale); - }, - mixin: { - beforeCreate() { - const unwatch = i18n2.watchLocale(() => { - this.$forceUpdate(); - }); - this.$once("hook:beforeDestroy", function() { - unwatch(); - }); - }, - methods: { - $$t(key, values) { - return t2(key, values); - } - } - } - }; -} -var en = { - "uni.app.quit": "Press back button again to exit", - "uni.async.error": "The connection timed out, click the screen to try again.", - "uni.showActionSheet.cancel": "Cancel", - "uni.showToast.unpaired": "Please note showToast must be paired with hideToast", - "uni.showLoading.unpaired": "Please note showLoading must be paired with hideLoading", - "uni.showModal.cancel": "Cancel", - "uni.showModal.confirm": "OK", - "uni.chooseImage.cancel": "Cancel", - "uni.chooseImage.sourceType.album": "Album", - "uni.chooseImage.sourceType.camera": "Camera", - "uni.chooseVideo.cancel": "Cancel", - "uni.chooseVideo.sourceType.album": "Album", - "uni.chooseVideo.sourceType.camera": "Camera", - "uni.previewImage.cancel": "Cancel", - "uni.previewImage.button.save": "Save Image", - "uni.previewImage.save.success": "Saved successfully", - "uni.previewImage.save.fail": "Save failed", - "uni.setClipboardData.success": "Content copied", - "uni.scanCode.title": "Scan code", - "uni.scanCode.album": "Album", - "uni.scanCode.fail": "Recognition failure", - "uni.scanCode.flash.on": "Tap to turn light on", - "uni.scanCode.flash.off": "Tap to turn light off", - "uni.startSoterAuthentication.authContent": "Fingerprint recognition", - "uni.picker.done": "Done", - "uni.picker.cancel": "Cancel", - "uni.video.danmu": "Danmu", - "uni.video.volume": "Volume", - "uni.button.feedback.title": "feedback", - "uni.button.feedback.send": "send" -}; -var es = { - "uni.app.quit": "Pulse otra vez para salir", - "uni.async.error": "Se agot\xF3 el tiempo de conexi\xF3n, haga clic en la pantalla para volver a intentarlo.", - "uni.showActionSheet.cancel": "Cancelar", - "uni.showToast.unpaired": "Tenga en cuenta que showToast debe estar emparejado con hideToast", - "uni.showLoading.unpaired": "Tenga en cuenta que showLoading debe estar emparejado con hideLoading", - "uni.showModal.cancel": "Cancelar", - "uni.showModal.confirm": "OK", - "uni.chooseImage.cancel": "Cancelar", - "uni.chooseImage.sourceType.album": "\xC1lbum", - "uni.chooseImage.sourceType.camera": "C\xE1mara", - "uni.chooseVideo.cancel": "Cancelar", - "uni.chooseVideo.sourceType.album": "\xC1lbum", - "uni.chooseVideo.sourceType.camera": "C\xE1mara", - "uni.previewImage.cancel": "Cancelar", - "uni.previewImage.button.save": "Guardar imagen", - "uni.previewImage.save.success": "Guardado exitosamente", - "uni.previewImage.save.fail": "Error al guardar", - "uni.setClipboardData.success": "Contenido copiado", - "uni.scanCode.title": "C\xF3digo de escaneo", - "uni.scanCode.album": "\xC1lbum", - "uni.scanCode.fail": "\xC9chec de la reconnaissance", - "uni.scanCode.flash.on": "Toque para encender la luz", - "uni.scanCode.flash.off": "Toque para apagar la luz", - "uni.startSoterAuthentication.authContent": "Reconocimiento de huellas dactilares", - "uni.picker.done": "OK", - "uni.picker.cancel": "Cancelar", - "uni.video.danmu": "Danmu", - "uni.video.volume": "Volumen", - "uni.button.feedback.title": "realimentaci\xF3n", - "uni.button.feedback.send": "enviar" -}; -var fr = { - "uni.app.quit": "Appuyez \xE0 nouveau pour quitter l'application", - "uni.async.error": "La connexion a expir\xE9, cliquez sur l'\xE9cran pour r\xE9essayer.", - "uni.showActionSheet.cancel": "Annuler", - "uni.showToast.unpaired": "Veuillez noter que showToast doit \xEAtre associ\xE9 \xE0 hideToast", - "uni.showLoading.unpaired": "Veuillez noter que showLoading doit \xEAtre associ\xE9 \xE0 hideLoading", - "uni.showModal.cancel": "Annuler", - "uni.showModal.confirm": "OK", - "uni.chooseImage.cancel": "Annuler", - "uni.chooseImage.sourceType.album": "Album", - "uni.chooseImage.sourceType.camera": "Cam\xE9ra", - "uni.chooseVideo.cancel": "Annuler", - "uni.chooseVideo.sourceType.album": "Album", - "uni.chooseVideo.sourceType.camera": "Cam\xE9ra", - "uni.previewImage.cancel": "Annuler", - "uni.previewImage.button.save": "Guardar imagen", - "uni.previewImage.save.success": "Enregistr\xE9 avec succ\xE8s", - "uni.previewImage.save.fail": "\xC9chec de la sauvegarde", - "uni.setClipboardData.success": "Contenu copi\xE9", - "uni.scanCode.title": "Code d\u2019analyse", - "uni.scanCode.album": "Album", - "uni.scanCode.fail": "Fallo de reconocimiento", - "uni.scanCode.flash.on": "Appuyez pour activer l'\xE9clairage", - "uni.scanCode.flash.off": "Appuyez pour d\xE9sactiver l'\xE9clairage", - "uni.startSoterAuthentication.authContent": "Reconnaissance de l'empreinte digitale", - "uni.picker.done": "OK", - "uni.picker.cancel": "Annuler", - "uni.video.danmu": "Danmu", - "uni.video.volume": "Le Volume", - "uni.button.feedback.title": "retour d'information", - "uni.button.feedback.send": "envoyer" -}; -var zhHans = { - "uni.app.quit": "\u518D\u6309\u4E00\u6B21\u9000\u51FA\u5E94\u7528", - "uni.async.error": "\u8FDE\u63A5\u670D\u52A1\u5668\u8D85\u65F6\uFF0C\u70B9\u51FB\u5C4F\u5E55\u91CD\u8BD5", - "uni.showActionSheet.cancel": "\u53D6\u6D88", - "uni.showToast.unpaired": "\u8BF7\u6CE8\u610F showToast \u4E0E hideToast \u5FC5\u987B\u914D\u5BF9\u4F7F\u7528", - "uni.showLoading.unpaired": "\u8BF7\u6CE8\u610F showLoading \u4E0E hideLoading \u5FC5\u987B\u914D\u5BF9\u4F7F\u7528", - "uni.showModal.cancel": "\u53D6\u6D88", - "uni.showModal.confirm": "\u786E\u5B9A", - "uni.chooseImage.cancel": "\u53D6\u6D88", - "uni.chooseImage.sourceType.album": "\u4ECE\u76F8\u518C\u9009\u62E9", - "uni.chooseImage.sourceType.camera": "\u62CD\u6444", - "uni.chooseVideo.cancel": "\u53D6\u6D88", - "uni.chooseVideo.sourceType.album": "\u4ECE\u76F8\u518C\u9009\u62E9", - "uni.chooseVideo.sourceType.camera": "\u62CD\u6444", - "uni.previewImage.cancel": "\u53D6\u6D88", - "uni.previewImage.button.save": "\u4FDD\u5B58\u56FE\u50CF", - "uni.previewImage.save.success": "\u4FDD\u5B58\u56FE\u50CF\u5230\u76F8\u518C\u6210\u529F", - "uni.previewImage.save.fail": "\u4FDD\u5B58\u56FE\u50CF\u5230\u76F8\u518C\u5931\u8D25", - "uni.setClipboardData.success": "\u5185\u5BB9\u5DF2\u590D\u5236", - "uni.scanCode.title": "\u626B\u7801", - "uni.scanCode.album": "\u76F8\u518C", - "uni.scanCode.fail": "\u8BC6\u522B\u5931\u8D25", - "uni.scanCode.flash.on": "\u8F7B\u89E6\u7167\u4EAE", - "uni.scanCode.flash.off": "\u8F7B\u89E6\u5173\u95ED", - "uni.startSoterAuthentication.authContent": "\u6307\u7EB9\u8BC6\u522B\u4E2D...", - "uni.picker.done": "\u5B8C\u6210", - "uni.picker.cancel": "\u53D6\u6D88", - "uni.video.danmu": "\u5F39\u5E55", - "uni.video.volume": "\u97F3\u91CF", - "uni.button.feedback.title": "\u95EE\u9898\u53CD\u9988", - "uni.button.feedback.send": "\u53D1\u9001" -}; -var zhHant = { - "uni.app.quit": "\u518D\u6309\u4E00\u6B21\u9000\u51FA\u61C9\u7528", - "uni.async.error": "\u9023\u63A5\u670D\u52D9\u5668\u8D85\u6642\uFF0C\u9EDE\u64CA\u5C4F\u5E55\u91CD\u8A66", - "uni.showActionSheet.cancel": "\u53D6\u6D88", - "uni.showToast.unpaired": "\u8ACB\u6CE8\u610F showToast \u8207 hideToast \u5FC5\u9808\u914D\u5C0D\u4F7F\u7528", - "uni.showLoading.unpaired": "\u8ACB\u6CE8\u610F showLoading \u8207 hideLoading \u5FC5\u9808\u914D\u5C0D\u4F7F\u7528", - "uni.showModal.cancel": "\u53D6\u6D88", - "uni.showModal.confirm": "\u78BA\u5B9A", - "uni.chooseImage.cancel": "\u53D6\u6D88", - "uni.chooseImage.sourceType.album": "\u5F9E\u76F8\u518A\u9078\u64C7", - "uni.chooseImage.sourceType.camera": "\u62CD\u651D", - "uni.chooseVideo.cancel": "\u53D6\u6D88", - "uni.chooseVideo.sourceType.album": "\u5F9E\u76F8\u518A\u9078\u64C7", - "uni.chooseVideo.sourceType.camera": "\u62CD\u651D", - "uni.previewImage.cancel": "\u53D6\u6D88", - "uni.previewImage.button.save": "\u4FDD\u5B58\u5716\u50CF", - "uni.previewImage.save.success": "\u4FDD\u5B58\u5716\u50CF\u5230\u76F8\u518A\u6210\u529F", - "uni.previewImage.save.fail": "\u4FDD\u5B58\u5716\u50CF\u5230\u76F8\u518A\u5931\u6557", - "uni.setClipboardData.success": "\u5167\u5BB9\u5DF2\u5FA9\u5236", - "uni.scanCode.title": "\u6383\u78BC", - "uni.scanCode.album": "\u76F8\u518A", - "uni.scanCode.fail": "\u8B58\u5225\u5931\u6557", - "uni.scanCode.flash.on": "\u8F15\u89F8\u7167\u4EAE", - "uni.scanCode.flash.off": "\u8F15\u89F8\u95DC\u9589", - "uni.startSoterAuthentication.authContent": "\u6307\u7D0B\u8B58\u5225\u4E2D...", - "uni.picker.done": "\u5B8C\u6210", - "uni.picker.cancel": "\u53D6\u6D88", - "uni.video.danmu": "\u5F48\u5E55", - "uni.video.volume": "\u97F3\u91CF", - "uni.button.feedback.title": "\u554F\u984C\u53CD\u994B", - "uni.button.feedback.send": "\u767C\u9001" -}; -const messages = { - en, - es, - fr, - "zh-Hans": zhHans, - "zh-Hant": zhHant -}; -const fallbackLocale = "en"; -const i18n = /* @__PURE__ */ initVueI18n(messages, fallbackLocale); -function useI18n() { - return i18n; -} function getRealRoute(fromRoute, toRoute) { if (!toRoute) { toRoute = fromRoute; @@ -3850,11 +3724,11 @@ const CANCEL_COLOR = "#f43530"; const ICONS = { success: { d: ICON_PATH_SUCCESS, - c: PRIMARY_COLOR + c: PRIMARY_COLOR$1 }, success_no_circle: { d: ICON_PATH_SUCCESS_NO_CIRCLE, - c: PRIMARY_COLOR + c: PRIMARY_COLOR$1 }, info: { d: ICON_PATH_INFO, @@ -3874,7 +3748,7 @@ const ICONS = { }, download: { d: ICON_PATH_DOWNLOAD, - c: PRIMARY_COLOR + c: PRIMARY_COLOR$1 }, search: { d: ICON_PATH_SEARCH, @@ -4372,7 +4246,14 @@ function formatApiArgs(args, options) { } const formatArgs = options.formatArgs; Object.keys(formatArgs).forEach((name) => { - formatArgs[name](args[0][name], params); + const formatterOrDefaultValue = formatArgs[name]; + if (isFunction(formatterOrDefaultValue)) { + formatterOrDefaultValue(args[0][name], params); + } else { + if (!hasOwn$1(params, name)) { + params[name] = formatterOrDefaultValue; + } + } }); return args; } @@ -4776,28 +4657,16 @@ function stringifyQuery(url, data) { return url + (query ? "?" + query : "") + (hash ? "#" + hash : ""); } const RequestProtocol = { - method: { - type: String - }, - data: { - type: [Object, String, Array, ArrayBuffer] - }, + method: String, + data: [Object, String, Array, ArrayBuffer], url: { type: String, required: true }, - header: { - type: Object - }, - dataType: { - type: String - }, - responseType: { - type: String - }, - withCredentials: { - type: Boolean - } + header: Object, + dataType: String, + responseType: String, + withCredentials: Boolean }; const RequestOptions = { formatArgs: { @@ -4863,9 +4732,7 @@ const UploadFileProtocol = { type: String, required: true }, - files: { - type: Array - }, + files: Array, filePath: String, name: String, header: Object, @@ -5064,6 +4931,96 @@ const SetNavigationBarTitleProtocol = { }; const API_SHOW_NAVIGATION_BAR_LOADING = "showNavigationBarLoading"; const API_HIDE_NAVIGATION_BAR_LOADING = "hideNavigationBarLoading"; +const PRIMARY_COLOR = "#007aff"; +const API_SHOW_MODAL = "showModal"; +const {t: t$1} = useI18n(); +const ShowModalProtocol = { + title: String, + content: String, + showCancel: Boolean, + cancelText: String, + cancelColor: String, + confirmText: String, + confirmColor: String +}; +let isInitI18nShowModalMsgs = false; +const ShowModalOptions = { + beforeInvoke() { + if (isInitI18nShowModalMsgs) { + return; + } + isInitI18nShowModalMsgs = true; + initI18nShowModalMsgs(); + }, + formatArgs: { + title: "", + content: "", + showCancel: true, + cancelText(_value, params) { + if (!hasOwn$1(params, "cancelText")) { + params.cancelText = t$1("uni.showModal.cancel"); + } + }, + cancelColor: "#000", + confirmText(_value, params) { + if (!hasOwn$1(params, "confirmText")) { + params.confirmText = t$1("uni.showModal.confirm"); + } + }, + confirmColor: PRIMARY_COLOR + } +}; +const API_SHOW_TOAST = "showToast"; +const ShowToastProtocol = { + title: String, + icon: String, + image: String, + duration: Number, + mask: Boolean +}; +const ShowToastOptions = { + formatArgs: { + title: "", + icon(value, params) { + if (["success", "loading", "none"].indexOf(value) === -1) { + params.icon = "success"; + } + }, + image(value, params) { + if (value) { + params.image = getRealPath(value); + } + }, + duration: 1500, + mask: false + } +}; +const API_SHOW_LOADING = "showLoading"; +const ShowLoadingProtocol = { + title: String, + mask: Boolean +}; +const ShowLoadingOptions = { + formatArgs: { + title: "", + mask: false + } +}; +const API_SHOW_ACTION_SHEET = "showActionSheet"; +const ShowActionSheetProtocol = { + itemList: { + type: Array, + required: true + }, + itemColor: String +}; +const ShowActionSheetOptions = { + formatArgs: { + itemColor: "#000" + } +}; +const API_HIDE_TOAST = "hideToast"; +const API_HIDE_LOADING = "hideLoading"; const IndexProtocol = { index: { type: Number, @@ -11186,6 +11143,18 @@ const hideNavigationBarLoading = /* @__PURE__ */ defineAsyncApi(API_HIDE_NAVIGAT const setNavigationBarTitle = /* @__PURE__ */ defineAsyncApi(API_SET_NAVIGATION_BAR_TITLE, (args, {resolve, reject}) => { setNavigationBar(getCurrentPageMeta(), API_SET_NAVIGATION_BAR_TITLE, args, resolve, reject); }, SetNavigationBarTitleProtocol); +const showModal = /* @__PURE__ */ defineAsyncApi(API_SHOW_MODAL, () => { +}, ShowModalProtocol, ShowModalOptions); +const showToast = /* @__PURE__ */ defineAsyncApi(API_SHOW_TOAST, () => { +}, ShowToastProtocol, ShowToastOptions); +const hideToast = /* @__PURE__ */ defineAsyncApi(API_HIDE_TOAST, () => { +}); +const showLoading = /* @__PURE__ */ defineAsyncApi(API_SHOW_LOADING, () => { +}, ShowLoadingProtocol, ShowLoadingOptions); +const hideLoading = /* @__PURE__ */ defineAsyncApi(API_HIDE_LOADING, () => { +}); +const showActionSheet = /* @__PURE__ */ defineAsyncApi(API_SHOW_ACTION_SHEET, () => { +}, ShowActionSheetProtocol, ShowActionSheetOptions); let tabBar; function useTabBar() { if (!tabBar) { @@ -11328,6 +11297,12 @@ var api = /* @__PURE__ */ Object.freeze({ showNavigationBarLoading, hideNavigationBarLoading, setNavigationBarTitle, + showModal, + showToast, + hideToast, + showLoading, + hideLoading, + showActionSheet, setTabBarItem, setTabBarStyle, hideTabBar, @@ -12345,6 +12320,7 @@ function createPageBodyVNode(ctx) { }); } var index_vue_vue_type_style_index_0_lang$1 = "\n.uni-async-error {\r\n position: absolute;\r\n left: 0;\r\n right: 0;\r\n top: 0;\r\n bottom: 0;\r\n color: #999;\r\n padding: 100px 10px;\r\n text-align: center;\n}\r\n"; +initI18nAsyncMsgs(); const _sfc_main$1 = { name: "AsyncError", setup() { @@ -12376,4 +12352,4 @@ function _sfc_render(_ctx, _cache, $props, $setup, $data, $options) { ]); } _sfc_main.render = _sfc_render; -export {_sfc_main$1 as AsyncErrorComponent, _sfc_main as AsyncLoadingComponent, _sfc_main$n as Audio, index$4 as Button, _sfc_main$m as Canvas, _sfc_main$l as Checkbox, _sfc_main$k as CheckboxGroup, _sfc_main$j as Editor, index$5 as Form, index$3 as Icon, _sfc_main$h as Image, _sfc_main$g as Input, _sfc_main$f as Label, LayoutComponent, _sfc_main$e as MovableView, _sfc_main$d as Navigator, index as PageComponent, _sfc_main$c as Progress, _sfc_main$b as Radio, _sfc_main$a as RadioGroup, _sfc_main$i as ResizeSensor, _sfc_main$9 as RichText, _sfc_main$8 as ScrollView, _sfc_main$7 as Slider, _sfc_main$6 as SwiperItem, _sfc_main$5 as Switch, index$2 as Text, _sfc_main$4 as Textarea, UniServiceJSBridge$1 as UniServiceJSBridge, UniViewJSBridge$1 as UniViewJSBridge, _sfc_main$3 as Video, index$1 as View, addInterceptor, arrayBufferToBase64, base64ToArrayBuffer, canIUse, createIntersectionObserver, createSelectorQuery, createVideoContext, cssBackdropFilter, cssConstant, cssEnv, cssVar, downloadFile, getApp$1 as getApp, getCurrentPages$1 as getCurrentPages, getImageInfo, getNetworkType, getSystemInfo, getSystemInfoSync, hideNavigationBarLoading, hideTabBar, hideTabBarRedDot, makePhoneCall, navigateBack, navigateTo, offNetworkStatusChange, onNetworkStatusChange, onTabBarMidButtonTap, openDocument, index$6 as plugin, promiseInterceptor, reLaunch, redirectTo, removeInterceptor, removeTabBarBadge, request, setNavigationBarColor, setNavigationBarTitle, setTabBarBadge, setTabBarItem, setTabBarStyle, setupApp, setupPage, showNavigationBarLoading, showTabBar, showTabBarRedDot, switchTab, uni$1 as uni, uploadFile, upx2px, useSubscribe}; +export {_sfc_main$1 as AsyncErrorComponent, _sfc_main as AsyncLoadingComponent, _sfc_main$n as Audio, index$4 as Button, _sfc_main$m as Canvas, _sfc_main$l as Checkbox, _sfc_main$k as CheckboxGroup, _sfc_main$j as Editor, index$5 as Form, index$3 as Icon, _sfc_main$h as Image, _sfc_main$g as Input, _sfc_main$f as Label, LayoutComponent, _sfc_main$e as MovableView, _sfc_main$d as Navigator, index as PageComponent, _sfc_main$c as Progress, _sfc_main$b as Radio, _sfc_main$a as RadioGroup, _sfc_main$i as ResizeSensor, _sfc_main$9 as RichText, _sfc_main$8 as ScrollView, _sfc_main$7 as Slider, _sfc_main$6 as SwiperItem, _sfc_main$5 as Switch, index$2 as Text, _sfc_main$4 as Textarea, UniServiceJSBridge$1 as UniServiceJSBridge, UniViewJSBridge$1 as UniViewJSBridge, _sfc_main$3 as Video, index$1 as View, addInterceptor, arrayBufferToBase64, base64ToArrayBuffer, canIUse, createIntersectionObserver, createSelectorQuery, createVideoContext, cssBackdropFilter, cssConstant, cssEnv, cssVar, downloadFile, getApp$1 as getApp, getCurrentPages$1 as getCurrentPages, getImageInfo, getNetworkType, getSystemInfo, getSystemInfoSync, hideLoading, hideNavigationBarLoading, hideTabBar, hideTabBarRedDot, hideToast, makePhoneCall, navigateBack, navigateTo, offNetworkStatusChange, onNetworkStatusChange, onTabBarMidButtonTap, openDocument, index$6 as plugin, promiseInterceptor, reLaunch, redirectTo, removeInterceptor, removeTabBarBadge, request, setNavigationBarColor, setNavigationBarTitle, setTabBarBadge, setTabBarItem, setTabBarStyle, setupApp, setupPage, showActionSheet, showLoading, showModal, showNavigationBarLoading, showTabBar, showTabBarRedDot, showToast, switchTab, uni$1 as uni, uploadFile, upx2px, useSubscribe}; diff --git a/packages/uni-h5/src/framework/components/async-error/index.vue b/packages/uni-h5/src/framework/components/async-error/index.vue index f8ce25b693b95c5f6d46e1de0afd589abdec0d37..ba8da857e78d2a39b2459d82d18e9037f6df941f 100644 --- a/packages/uni-h5/src/framework/components/async-error/index.vue +++ b/packages/uni-h5/src/framework/components/async-error/index.vue @@ -15,9 +15,10 @@