diff --git a/packages/uni-app-plus/dist/index.v3.js b/packages/uni-app-plus/dist/index.v3.js index 13c652dd4445bed122712c1a27bf391efce94ac1..1f38fcc307345f248d6069cd25a35e9f3b543b40 100644 --- a/packages/uni-app-plus/dist/index.v3.js +++ b/packages/uni-app-plus/dist/index.v3.js @@ -1092,13 +1092,478 @@ var serviceContext = (function () { scanCode: scanCode }); + const isObject$1 = (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 text = ''; + while (position < format.length) { + let char = format[position++]; + if (char === '{') { + if (text) { + tokens.push({ type: 'text', value: text }); + } + text = ''; + let sub = ''; + char = format[position++]; + while (char !== undefined && 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 === '%') { + // when found rails i18n syntax, skip text capture + if (format[position] !== '{') { + text += char; + } + } + else { + text += char; + } + } + text && tokens.push({ type: 'text', value: text }); + return tokens; + } + function compile(tokens, values) { + const compiled = []; + let index = 0; + const mode = Array.isArray(values) + ? 'list' + : isObject$1(values) + ? 'named' + : 'unknown'; + if (mode === 'unknown') { + return compiled; + } + while (index < tokens.length) { + const token = tokens[index]; + 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]); + } + else { + if (process.env.NODE_ENV !== 'production') { + console.warn(`Type of token '${token.type}' and format of value '${mode}' don't match!`); + } + } + break; + case 'unknown': + if (process.env.NODE_ENV !== 'production') { + console.warn(`Detect 'unknown' type of token!`); + } + break; + } + index++; + } + return compiled; + } + + const hasOwnProperty$1 = Object.prototype.hasOwnProperty; + const hasOwn$1 = (val, key) => hasOwnProperty$1.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); + } + console.log('normalizeLocale'); + 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 '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, messages, watcher, formater, }) { + this.locale = 'en'; + this.fallbackLocale = 'en'; + this.message = {}; + this.messages = {}; + this.watchers = []; + if (fallbackLocale) { + this.fallbackLocale = fallbackLocale; + } + this.formater = formater || defaultFormatter; + this.messages = messages; + console.log(`--2--${locale}`); + this.setLocale(locale); + if (watcher) { + this.watchLocale(watcher); + } + } + setLocale(locale) { + console.log(`locale:${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 index = this.watchers.push(fn) - 1; + return () => { + this.watchers.splice(index, 1); + }; + } + 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$1(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(appVm, i18n) { + appVm.$i18n && + appVm.$i18n.vm.$watch('locale', (newLocale) => { + console.log('--3--'); + i18n.setLocale(newLocale); + }, { + immediate: true, + }); + } + function getDefaultLocale() { + console.log('getDefaultLocale'); + if (typeof navigator !== 'undefined') { + return navigator.userLanguage || navigator.language; + } + if (typeof plus !== 'undefined') { + // TODO 待调整为最新的获取语言代码 + return plus.os.language; + } + return uni.getSystemInfoSync().language; + } + function initVueI18n(messages, fallbackLocale = 'en', locale) { + const i18n = new I18n({ + locale: locale || fallbackLocale, + fallbackLocale, + messages, + }); + let t = (key, values) => { + if (typeof getApp !== 'function') { + // app-plus view + /* eslint-disable no-func-assign */ + t = function (key, values) { + return i18n.t(key, values); + }; + } + else { + const appVm = getApp().$vm; + if (!appVm.$t || !appVm.$i18n) { + if (!locale) { + console.log('--4--'); + i18n.setLocale(getDefaultLocale()); + } + /* eslint-disable no-func-assign */ + t = function (key, values) { + return i18n.t(key, values); + }; + } + else { + initLocaleWatcher(appVm, i18n); + /* eslint-disable no-func-assign */ + t = function (key, values) { + const $i18n = appVm.$i18n; + const silentTranslationWarn = $i18n.silentTranslationWarn; + $i18n.silentTranslationWarn = true; + const msg = appVm.$t(key, values); + $i18n.silentTranslationWarn = silentTranslationWarn; + if (msg !== key) { + return msg; + } + return i18n.t(key, $i18n.locale, values); + }; + } + } + return t(key, values); + }; + return { + t(key, values) { + return t(key, values); + }, + getLocale() { + return i18n.getLocale(); + }, + setLocale(newLocale) { + console.log(`--1--:${newLocale}`); + return i18n.setLocale(newLocale); + }, + mixin: { + beforeCreate() { + const unwatch = i18n.watchLocale(() => { + this.$forceUpdate(); + }); + this.$once('hook:beforeDestroy', function () { + unwatch(); + }); + }, + methods: { + $$t(key, values) { + return t(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ó el tiempo de conexión, 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": "Álbum", + "uni.chooseImage.sourceType.camera": "Cámara", + "uni.chooseVideo.cancel": "Cancelar", + "uni.chooseVideo.sourceType.album": "Álbum", + "uni.chooseVideo.sourceType.camera": "Cámara", + "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ódigo de escaneo", + "uni.scanCode.album": "Álbum", + "uni.scanCode.fail": "Échec 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ón", + "uni.button.feedback.send": "enviar" + }; + + var fr = { + "uni.app.quit": "Appuyez à nouveau pour quitter l'application", + "uni.async.error": "La connexion a expiré, cliquez sur l'écran pour réessayer.", + "uni.showActionSheet.cancel": "Annuler", + "uni.showToast.unpaired": "Veuillez noter que showToast doit être associé à hideToast", + "uni.showLoading.unpaired": "Veuillez noter que showLoading doit être associé à hideLoading", + "uni.showModal.cancel": "Annuler", + "uni.showModal.confirm": "OK", + "uni.chooseImage.cancel": "Annuler", + "uni.chooseImage.sourceType.album": "Album", + "uni.chooseImage.sourceType.camera": "Caméra", + "uni.chooseVideo.cancel": "Annuler", + "uni.chooseVideo.sourceType.album": "Album", + "uni.chooseVideo.sourceType.camera": "Caméra", + "uni.previewImage.cancel": "Annuler", + "uni.previewImage.button.save": "Guardar imagen", + "uni.previewImage.save.success": "Enregistré avec succès", + "uni.previewImage.save.fail": "Échec de la sauvegarde", + "uni.setClipboardData.success": "Contenu copié", + "uni.scanCode.title": "Code d’analyse", + "uni.scanCode.album": "Album", + "uni.scanCode.fail": "Fallo de reconocimiento", + "uni.scanCode.flash.on": "Appuyez pour activer l'éclairage", + "uni.scanCode.flash.off": "Appuyez pour désactiver l'éclairage", + "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": "再按一次退出应用", + "uni.async.error": "连接服务器超时,点击屏幕重试", + "uni.showActionSheet.cancel": "取消", + "uni.showToast.unpaired": "请注意 showToast 与 hideToast 必须配对使用", + "uni.showLoading.unpaired": "请注意 showLoading 与 hideLoading 必须配对使用", + "uni.showModal.cancel": "取消", + "uni.showModal.confirm": "确定", + "uni.chooseImage.cancel": "取消", + "uni.chooseImage.sourceType.album": "从相册选择", + "uni.chooseImage.sourceType.camera": "拍摄", + "uni.chooseVideo.cancel": "取消", + "uni.chooseVideo.sourceType.album": "从相册选择", + "uni.chooseVideo.sourceType.camera": "拍摄", + "uni.previewImage.cancel": "取消", + "uni.previewImage.button.save": "保存图像", + "uni.previewImage.save.success": "保存图像到相册成功", + "uni.previewImage.save.fail": "保存图像到相册失败", + "uni.setClipboardData.success": "内容已复制", + "uni.scanCode.title": "扫码", + "uni.scanCode.album": "相册", + "uni.scanCode.fail": "识别失败", + "uni.scanCode.flash.on": "轻触照亮", + "uni.scanCode.flash.off": "轻触关闭", + "uni.startSoterAuthentication.authContent": "指纹识别中...", + "uni.picker.done": "完成", + "uni.picker.cancel": "取消", + "uni.video.danmu": "弹幕", + "uni.video.volume": "音量", + "uni.button.feedback.title": "问题反馈", + "uni.button.feedback.send": "发送" + }; + + var zhHant = { + "uni.app.quit": "再按一次退出應用", + "uni.async.error": "連接服務器超時,點擊屏幕重試", + "uni.showActionSheet.cancel": "取消", + "uni.showToast.unpaired": "請注意 showToast 與 hideToast 必須配對使用", + "uni.showLoading.unpaired": "請注意 showLoading 與 hideLoading 必須配對使用", + "uni.showModal.cancel": "取消", + "uni.showModal.confirm": "確定", + "uni.chooseImage.cancel": "取消", + "uni.chooseImage.sourceType.album": "從相冊選擇", + "uni.chooseImage.sourceType.camera": "拍攝", + "uni.chooseVideo.cancel": "取消", + "uni.chooseVideo.sourceType.album": "從相冊選擇", + "uni.chooseVideo.sourceType.camera": "拍攝", + "uni.previewImage.cancel": "取消", + "uni.previewImage.button.save": "保存圖像", + "uni.previewImage.save.success": "保存圖像到相冊成功", + "uni.previewImage.save.fail": "保存圖像到相冊失敗", + "uni.setClipboardData.success": "內容已復制", + "uni.scanCode.title": "掃碼", + "uni.scanCode.album": "相冊", + "uni.scanCode.fail": "識別失敗", + "uni.scanCode.flash.on": "輕觸照亮", + "uni.scanCode.flash.off": "輕觸關閉", + "uni.startSoterAuthentication.authContent": "指紋識別中...", + "uni.picker.done": "完成", + "uni.picker.cancel": "取消", + "uni.video.danmu": "彈幕", + "uni.video.volume": "音量", + "uni.button.feedback.title": "問題反饋", + "uni.button.feedback.send": "發送" + }; + + const messages = { + en, + es, + fr, + 'zh-Hans': zhHans, + 'zh-Hant': zhHant + }; + + const fallbackLocale = 'en'; + + const i18n = initVueI18n( messages , fallbackLocale); + const t = i18n.t; + const getLocale = i18n.getLocale; + const setClipboardData = { beforeSuccess () { - uni.showToast({ - title: '内容已复制', - icon: 'success', - mask: false - }); + const title = t('uni.setClipboardData.success'); + if (title) { + uni.showToast({ + title: t('uni.setClipboardData.success'), + icon: 'success', + mask: false, + style: { + width: undefined + } + }); + } } }; @@ -1456,1048 +1921,723 @@ var serviceContext = (function () { validator (src, params) { params.src = getRealPath(src); } - } - }; - - var require_context_module_0_18 = /*#__PURE__*/Object.freeze({ - __proto__: null, - compressImage: compressImage - }); - - const getImageInfo = { - src: { - type: String, - required: true, - validator (src, params) { - params.src = getRealPath(src); - } - } - }; - - var require_context_module_0_19 = /*#__PURE__*/Object.freeze({ - __proto__: null, - getImageInfo: getImageInfo - }); - - const previewImage = { - urls: { - type: Array, - required: true, - validator (value, params) { - var typeError; - params.urls = value.map(url => { - if (typeof url === 'string') { - return getRealPath(url) - } else { - typeError = true; - } - }); - if (typeError) { - return 'url is not string' - } - } - }, - current: { - type: [String, Number], - validator (value, params) { - if (typeof value === 'number') { - params.current = value > 0 && value < params.urls.length ? value : 0; - } else if (typeof value === 'string' && value) { - params.current = getRealPath(value); - } - }, - default: 0 - } - }; - - var require_context_module_0_20 = /*#__PURE__*/Object.freeze({ - __proto__: null, - previewImage: previewImage - }); - - const saveImageToPhotosAlbum = { - filePath: { - type: String, - required: true, - validator (filePath, params) { - params.filePath = getRealPath(filePath); - } - } - }; - - var require_context_module_0_21 = /*#__PURE__*/Object.freeze({ - __proto__: null, - saveImageToPhotosAlbum: saveImageToPhotosAlbum - }); - - const downloadFile = { - url: { - type: String, - required: true - }, - header: { - type: Object, - validator (value, params) { - params.header = value || {}; - } - } - }; - - var require_context_module_0_22 = /*#__PURE__*/Object.freeze({ - __proto__: null, - downloadFile: downloadFile - }); - - const method = { - OPTIONS: 'OPTIONS', - GET: 'GET', - HEAD: 'HEAD', - POST: 'POST', - PUT: 'PUT', - DELETE: 'DELETE', - TRACE: 'TRACE', - CONNECT: 'CONNECT' - }; - const dataType = { - JSON: 'json' - }; - const responseType = { - TEXT: 'text', - ARRAYBUFFER: 'arraybuffer' - }; - - const encode$1 = encodeURIComponent; - - function stringifyQuery$1 (url, data) { - let str = url.split('#'); - const hash = str[1] || ''; - str = str[0].split('?'); - let query = str[1] || ''; - url = str[0]; - const search = query.split('&').filter(item => item); - query = {}; - search.forEach(item => { - item = item.split('='); - query[item[0]] = item[1]; - }); - for (const key in data) { - if (hasOwn(data, key)) { - let v = data[key]; - if (typeof v === 'undefined' || v === null) { - v = ''; - } else if (isPlainObject(v)) { - v = JSON.stringify(v); - } - query[encode$1(key)] = encode$1(v); - } - } - query = Object.keys(query).map(item => `${item}=${query[item]}`).join('&'); - return url + (query ? '?' + query : '') + (hash ? '#' + hash : '') - } - - const request = { - method: { - type: String, - validator (value, params) { - value = (value || '').toUpperCase(); - params.method = Object.values(method).indexOf(value) < 0 ? method.GET : value; - } - }, - data: { - type: [Object, String, Array, ArrayBuffer], - validator (value, params) { - params.data = value || ''; - } - }, - url: { - type: String, - required: true, - validator (value, params) { - if ( - params.method === method.GET && - isPlainObject(params.data) && - Object.keys(params.data).length - ) { // 将 method,data 校验提前,保证 url 校验时,method,data 已被格式化 - params.url = stringifyQuery$1(value, params.data); - } - } - }, - header: { - type: Object, - validator (value, params) { - const header = params.header = value || {}; - if (params.method !== method.GET) { - if (!Object.keys(header).find(key => key.toLowerCase() === 'content-type')) { - header['Content-Type'] = 'application/json'; - } - } - } - }, - dataType: { - type: String, - validator (value, params) { - params.dataType = (value || dataType.JSON).toLowerCase(); - } - }, - responseType: { - type: String, - validator (value, params) { - value = (value || '').toLowerCase(); - params.responseType = Object.values(responseType).indexOf(value) < 0 ? responseType.TEXT : value; - } - }, - withCredentials: { - type: Boolean - }, - timeout: { - type: Number - } - }; - - var require_context_module_0_23 = /*#__PURE__*/Object.freeze({ - __proto__: null, - request: request - }); - - const method$1 = { - OPTIONS: 'OPTIONS', - GET: 'GET', - HEAD: 'HEAD', - POST: 'POST', - PUT: 'PUT', - DELETE: 'DELETE', - TRACE: 'TRACE', - CONNECT: 'CONNECT' - }; - const connectSocket = { - url: { - type: String, - required: true - }, - header: { - type: Object, - validator (value, params) { - params.header = value || {}; - } - }, - method: { - type: String, - validator (value, params) { - value = (value || '').toUpperCase(); - params.method = Object.values(method$1).indexOf(value) < 0 ? method$1.GET : value; - } - }, - protocols: { - // 微信文档虽然写的是数组,但是可以正常传递字符串 - type: [Array, String], - validator (value, params) { - if (typeof value === 'string') { - value = [value]; - } - params.protocols = (value || []).filter(str => typeof str === 'string'); - } - } - }; - const sendSocketMessage = { - data: { - type: [String, ArrayBuffer] - } - }; - const closeSocket = { - code: { - type: Number - }, - reason: { - type: String - } + } }; - var require_context_module_0_24 = /*#__PURE__*/Object.freeze({ + var require_context_module_0_18 = /*#__PURE__*/Object.freeze({ __proto__: null, - connectSocket: connectSocket, - sendSocketMessage: sendSocketMessage, - closeSocket: closeSocket + compressImage: compressImage }); - // App端可以只使用files不传filePath和name - - const uploadFile = { - url: { - type: String, - required: true - }, - files: { - type: Array - }, - filePath: { - type: String, - validator (value, params) { - if (value) { - params.type = getRealPath(value); - } - } - }, - name: { - type: String - }, - header: { - type: Object, - validator (value, params) { - params.header = value || {}; - } - }, - formData: { - type: Object, - validator (value, params) { - params.formData = value || {}; - } - } + const getImageInfo = { + src: { + type: String, + required: true, + validator (src, params) { + params.src = getRealPath(src); + } + } }; - var require_context_module_0_25 = /*#__PURE__*/Object.freeze({ + var require_context_module_0_19 = /*#__PURE__*/Object.freeze({ __proto__: null, - uploadFile: uploadFile + getImageInfo: getImageInfo }); - const service = { - OAUTH: 'OAUTH', - SHARE: 'SHARE', - PAYMENT: 'PAYMENT', - PUSH: 'PUSH' - }; - - const getProvider = { - service: { - type: String, + const previewImage = { + urls: { + type: Array, required: true, validator (value, params) { - value = (value || '').toUpperCase(); - if (value && Object.values(service).indexOf(value) < 0) { - return 'service error' + var typeError; + params.urls = value.map(url => { + if (typeof url === 'string') { + return getRealPath(url) + } else { + typeError = true; + } + }); + if (typeError) { + return 'url is not string' } } + }, + current: { + type: [String, Number], + validator (value, params) { + if (typeof value === 'number') { + params.current = value > 0 && value < params.urls.length ? value : 0; + } else if (typeof value === 'string' && value) { + params.current = getRealPath(value); + } + }, + default: 0 } }; - var require_context_module_0_26 = /*#__PURE__*/Object.freeze({ + var require_context_module_0_20 = /*#__PURE__*/Object.freeze({ __proto__: null, - getProvider: getProvider + previewImage: previewImage }); - const loadSubPackage = { - root: { + const saveImageToPhotosAlbum = { + filePath: { type: String, required: true, - validator (value, params) { - const subPackages = __uniConfig.subPackages; - if (!Array.isArray(subPackages) || subPackages.length === 0) { - return 'no subPackages' - } - if (!subPackages.find(subPackage => subPackage.root === value)) { - return 'root `' + value + '` is not found' - } + validator (filePath, params) { + params.filePath = getRealPath(filePath); } } }; - var require_context_module_0_27 = /*#__PURE__*/Object.freeze({ + var require_context_module_0_21 = /*#__PURE__*/Object.freeze({ __proto__: null, - loadSubPackage: loadSubPackage + saveImageToPhotosAlbum: saveImageToPhotosAlbum }); - const provider = { - UNIVERIFY: 'univerify' - }; - - const preLogin = { - provider: { + const downloadFile = { + url: { type: String, - required: true, - default: provider.UNIVERIFY, + required: true + }, + header: { + type: Object, validator (value, params) { - if (Object.values(provider).indexOf(value) < 0) { - return 'provider error' - } + params.header = value || {}; } } }; - var require_context_module_0_28 = /*#__PURE__*/Object.freeze({ + var require_context_module_0_22 = /*#__PURE__*/Object.freeze({ __proto__: null, - preLogin: preLogin + downloadFile: downloadFile }); - function encodeQueryString (url) { - if (typeof url !== 'string') { - return url - } - const index = url.indexOf('?'); - - if (index === -1) { - return url - } - - const query = url.substr(index + 1).trim().replace(/^(\?|#|&)/, ''); - - if (!query) { - return url - } - - url = url.substr(0, index); - - const params = []; - - query.split('&').forEach(param => { - const parts = param.replace(/\+/g, ' ').split('='); - const key = parts.shift(); - const val = parts.length > 0 - ? parts.join('=') - : ''; - - params.push(key + '=' + encodeURIComponent(val)); - }); - - return params.length ? url + '?' + params.join('&') : url - } - - function createValidator (type) { - return function validator (url, params) { - // 格式化为绝对路径路由 - url = getRealRoute(url); - - const pagePath = url.split('?')[0]; - // 匹配路由是否存在 - const routeOptions = __uniRoutes.find(({ - path, - alias - }) => path === pagePath || alias === pagePath); - - if (!routeOptions) { - return 'page `' + url + '` is not found' - } - - // 检测不同类型跳转 - if (type === 'navigateTo' || type === 'redirectTo') { - if (routeOptions.meta.isTabBar) { - return `can not ${type} a tabbar page` - } - } else if (type === 'switchTab') { - if (!routeOptions.meta.isTabBar) { - return 'can not switch to no-tabBar page' - } - } - - // switchTab不允许传递参数,reLaunch到一个tabBar页面是可以的 - if ( - (type === 'switchTab' || type === 'preloadPage') && - routeOptions.meta.isTabBar && - params.openType !== 'appLaunch' - ) { - url = pagePath; - } - - // 首页自动格式化为`/` - if (routeOptions.meta.isEntry) { - url = url.replace(routeOptions.alias, '/'); - } - - // 参数格式化 - params.url = encodeQueryString(url); - if (type === 'unPreloadPage') { - return - } else if (type === 'preloadPage') { - { - if (!routeOptions.meta.isNVue) { - return 'can not preload vue page' - } - } - if (routeOptions.meta.isTabBar) { - const pages = getCurrentPages(true); - const tabBarPagePath = (routeOptions.alias || routeOptions.path).substr(1); - if (pages.find(page => page.route === tabBarPagePath)) { - return 'tabBar page `' + tabBarPagePath + '` already exists' - } - } - return - } - - // 主要拦截目标为用户快速点击时触发的多次跳转,该情况,通常前后 url 是一样的 - if (navigatorLock === url && params.openType !== 'appLaunch') { - return `${navigatorLock} locked` - } - // 至少 onLaunch 之后,再启用lock逻辑(onLaunch之前可能开发者手动调用路由API,来提前跳转) - // enableNavigatorLock 临时开关(不对外开放),避免该功能上线后,有部分情况异常,可以让开发者临时关闭 lock 功能 - if (__uniConfig.ready && __uniConfig.enableNavigatorLock !== false) { - navigatorLock = url; - } - } - } - - let navigatorLock; + const method = { + OPTIONS: 'OPTIONS', + GET: 'GET', + HEAD: 'HEAD', + POST: 'POST', + PUT: 'PUT', + DELETE: 'DELETE', + TRACE: 'TRACE', + CONNECT: 'CONNECT' + }; + const dataType = { + JSON: 'json' + }; + const responseType = { + TEXT: 'text', + ARRAYBUFFER: 'arraybuffer' + }; - function createProtocol (type, extras = {}) { - return Object.assign({ - url: { - type: String, - required: true, - validator: createValidator(type) - }, - beforeAll () { - navigatorLock = ''; - } - }, extras) - } + const encode$1 = encodeURIComponent; - function createAnimationProtocol (animationTypes) { - return { - animationType: { - type: String, - validator (type) { - if (type && animationTypes.indexOf(type) === -1) { - return '`' + type + '` is not supported for `animationType` (supported values are: `' + animationTypes.join( - '`|`') + '`)' - } + function stringifyQuery$1 (url, data) { + let str = url.split('#'); + const hash = str[1] || ''; + str = str[0].split('?'); + let query = str[1] || ''; + url = str[0]; + const search = query.split('&').filter(item => item); + query = {}; + search.forEach(item => { + item = item.split('='); + query[item[0]] = item[1]; + }); + for (const key in data) { + if (hasOwn(data, key)) { + let v = data[key]; + if (typeof v === 'undefined' || v === null) { + v = ''; + } else if (isPlainObject(v)) { + v = JSON.stringify(v); } - }, - animationDuration: { - type: Number + query[encode$1(key)] = encode$1(v); } } + query = Object.keys(query).map(item => `${item}=${query[item]}`).join('&'); + return url + (query ? '?' + query : '') + (hash ? '#' + hash : '') } - const redirectTo = createProtocol('redirectTo'); - - const reLaunch = createProtocol('reLaunch'); - - const navigateTo = createProtocol('navigateTo', createAnimationProtocol( - [ - 'slide-in-right', - 'slide-in-left', - 'slide-in-top', - 'slide-in-bottom', - 'fade-in', - 'zoom-out', - 'zoom-fade-out', - 'pop-in', - 'none' - ] - )); - - const switchTab = createProtocol('switchTab'); - - const navigateBack = Object.assign({ - delta: { - type: Number, - validator (delta, params) { - delta = parseInt(delta) || 1; - params.delta = Math.min(getCurrentPages().length - 1, delta); + const request = { + method: { + type: String, + validator (value, params) { + value = (value || '').toUpperCase(); + params.method = Object.values(method).indexOf(value) < 0 ? method.GET : value; } - } - }, createAnimationProtocol( - [ - 'slide-out-right', - 'slide-out-left', - 'slide-out-top', - 'slide-out-bottom', - 'fade-out', - 'zoom-in', - 'zoom-fade-in', - 'pop-out', - 'none' - ] - )); - - const preloadPage = { + }, + data: { + type: [Object, String, Array, ArrayBuffer], + validator (value, params) { + params.data = value || ''; + } + }, url: { type: String, required: true, - validator: createValidator('preloadPage') - } - }; - - const unPreloadPage = { - url: { + validator (value, params) { + if ( + params.method === method.GET && + isPlainObject(params.data) && + Object.keys(params.data).length + ) { // 将 method,data 校验提前,保证 url 校验时,method,data 已被格式化 + params.url = stringifyQuery$1(value, params.data); + } + } + }, + header: { + type: Object, + validator (value, params) { + const header = params.header = value || {}; + if (params.method !== method.GET) { + if (!Object.keys(header).find(key => key.toLowerCase() === 'content-type')) { + header['Content-Type'] = 'application/json'; + } + } + } + }, + dataType: { type: String, - required: true, - validator: createValidator('unPreloadPage') + validator (value, params) { + params.dataType = (value || dataType.JSON).toLowerCase(); + } + }, + responseType: { + type: String, + validator (value, params) { + value = (value || '').toLowerCase(); + params.responseType = Object.values(responseType).indexOf(value) < 0 ? responseType.TEXT : value; + } + }, + withCredentials: { + type: Boolean + }, + timeout: { + type: Number } }; - var require_context_module_0_29 = /*#__PURE__*/Object.freeze({ + var require_context_module_0_23 = /*#__PURE__*/Object.freeze({ __proto__: null, - redirectTo: redirectTo, - reLaunch: reLaunch, - navigateTo: navigateTo, - switchTab: switchTab, - navigateBack: navigateBack, - preloadPage: preloadPage, - unPreloadPage: unPreloadPage + request: request }); - const getStorage = { - key: { - type: String, - required: true - } - }; - - const getStorageSync = [{ - name: 'key', - type: String, - required: true - }]; - - const setStorage = { - key: { - type: String, - required: true - }, - data: { - required: true - } - }; - - const setStorageSync = [{ - name: 'key', - type: String, - required: true - }, { - name: 'data', - required: true - }]; - - const removeStorage = getStorage; - const removeStorageSync = getStorageSync; + const method$1 = { + OPTIONS: 'OPTIONS', + GET: 'GET', + HEAD: 'HEAD', + POST: 'POST', + PUT: 'PUT', + DELETE: 'DELETE', + TRACE: 'TRACE', + CONNECT: 'CONNECT' + }; + const connectSocket = { + url: { + type: String, + required: true + }, + header: { + type: Object, + validator (value, params) { + params.header = value || {}; + } + }, + method: { + type: String, + validator (value, params) { + value = (value || '').toUpperCase(); + params.method = Object.values(method$1).indexOf(value) < 0 ? method$1.GET : value; + } + }, + protocols: { + // 微信文档虽然写的是数组,但是可以正常传递字符串 + type: [Array, String], + validator (value, params) { + if (typeof value === 'string') { + value = [value]; + } + params.protocols = (value || []).filter(str => typeof str === 'string'); + } + } + }; + const sendSocketMessage = { + data: { + type: [String, ArrayBuffer] + } + }; + const closeSocket = { + code: { + type: Number + }, + reason: { + type: String + } + }; - var require_context_module_0_30 = /*#__PURE__*/Object.freeze({ + var require_context_module_0_24 = /*#__PURE__*/Object.freeze({ __proto__: null, - getStorage: getStorage, - getStorageSync: getStorageSync, - setStorage: setStorage, - setStorageSync: setStorageSync, - removeStorage: removeStorage, - removeStorageSync: removeStorageSync + connectSocket: connectSocket, + sendSocketMessage: sendSocketMessage, + closeSocket: closeSocket }); - const loadFontFace = { - family: { + // App端可以只使用files不传filePath和name + + const uploadFile = { + url: { type: String, required: true }, - source: { - type: String, - required: true + files: { + type: Array }, - desc: { - type: Object, - required: false + filePath: { + type: String, + validator (value, params) { + if (value) { + params.type = getRealPath(value); + } + } }, - success: { - type: Function, - required: false + name: { + type: String }, - fail: { - type: Function, - required: false + header: { + type: Object, + validator (value, params) { + params.header = value || {}; + } }, - complete: { - type: Function, - required: false + formData: { + type: Object, + validator (value, params) { + params.formData = value || {}; + } } }; - var require_context_module_0_31 = /*#__PURE__*/Object.freeze({ + var require_context_module_0_25 = /*#__PURE__*/Object.freeze({ __proto__: null, - loadFontFace: loadFontFace + uploadFile: uploadFile }); - const FRONT_COLORS = ['#ffffff', '#000000']; - const setNavigationBarColor = { - frontColor: { + const service = { + OAUTH: 'OAUTH', + SHARE: 'SHARE', + PAYMENT: 'PAYMENT', + PUSH: 'PUSH' + }; + + const getProvider = { + service: { + type: String, + required: true, + validator (value, params) { + value = (value || '').toUpperCase(); + if (value && Object.values(service).indexOf(value) < 0) { + return 'service error' + } + } + } + }; + + var require_context_module_0_26 = /*#__PURE__*/Object.freeze({ + __proto__: null, + getProvider: getProvider + }); + + const loadSubPackage = { + root: { type: String, required: true, - validator (frontColor, params) { - if (FRONT_COLORS.indexOf(frontColor) === -1) { - return `invalid frontColor "${frontColor}"` + validator (value, params) { + const subPackages = __uniConfig.subPackages; + if (!Array.isArray(subPackages) || subPackages.length === 0) { + return 'no subPackages' } - } - }, - backgroundColor: { - type: String, - required: true - }, - animation: { - type: Object, - default () { - return { - duration: 0, - timingFunc: 'linear' + if (!subPackages.find(subPackage => subPackage.root === value)) { + return 'root `' + value + '` is not found' } - }, - validator (animation = {}, params) { - params.animation = { - duration: animation.duration || 0, - timingFunc: animation.timingFunc || 'linear' - }; } } - }; - const setNavigationBarTitle = { - title: { - type: String, - required: true - } }; - var require_context_module_0_32 = /*#__PURE__*/Object.freeze({ + var require_context_module_0_27 = /*#__PURE__*/Object.freeze({ __proto__: null, - setNavigationBarColor: setNavigationBarColor, - setNavigationBarTitle: setNavigationBarTitle + loadSubPackage: loadSubPackage }); - const pageScrollTo = { - scrollTop: { - type: Number, - required: true - }, - duration: { - type: Number, - default: 300, - validator (duration, params) { - params.duration = Math.max(0, duration); - } - } + const provider = { + UNIVERIFY: 'univerify' }; - var require_context_module_0_33 = /*#__PURE__*/Object.freeze({ + const preLogin = { + provider: { + type: String, + required: true, + default: provider.UNIVERIFY, + validator (value, params) { + if (Object.values(provider).indexOf(value) < 0) { + return 'provider error' + } + } + } + }; + + var require_context_module_0_28 = /*#__PURE__*/Object.freeze({ __proto__: null, - pageScrollTo: pageScrollTo + preLogin: preLogin }); - const isObject$1 = (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 text = ''; - while (position < format.length) { - let char = format[position++]; - if (char === '{') { - if (text) { - tokens.push({ type: 'text', value: text }); - } - text = ''; - let sub = ''; - char = format[position++]; - while (char !== undefined && 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 === '%') { - // when found rails i18n syntax, skip text capture - if (format[position] !== '{') { - text += char; - } - } - else { - text += char; - } - } - text && tokens.push({ type: 'text', value: text }); - return tokens; - } - function compile(tokens, values) { - const compiled = []; - let index = 0; - const mode = Array.isArray(values) - ? 'list' - : isObject$1(values) - ? 'named' - : 'unknown'; - if (mode === 'unknown') { - return compiled; - } - while (index < tokens.length) { - const token = tokens[index]; - 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]); - } - else { - if (process.env.NODE_ENV !== 'production') { - console.warn(`Type of token '${token.type}' and format of value '${mode}' don't match!`); - } - } - break; - case 'unknown': - if (process.env.NODE_ENV !== 'production') { - console.warn(`Detect 'unknown' type of token!`); - } - break; - } - index++; - } - return compiled; - } - - const hasOwnProperty$1 = Object.prototype.hasOwnProperty; - const hasOwn$1 = (val, key) => hasOwnProperty$1.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 encodeQueryString (url) { + if (typeof url !== 'string') { + return url + } + const index = url.indexOf('?'); + + if (index === -1) { + return url + } + + const query = url.substr(index + 1).trim().replace(/^(\?|#|&)/, ''); + + if (!query) { + return url + } + + url = url.substr(0, index); + + const params = []; + + query.split('&').forEach(param => { + const parts = param.replace(/\+/g, ' ').split('='); + const key = parts.shift(); + const val = parts.length > 0 + ? parts.join('=') + : ''; + + params.push(key + '=' + encodeURIComponent(val)); + }); + + return params.length ? url + '?' + params.join('&') : url } - function normalizeLocale(locale, messages) { - if (!locale) { - return; + + function createValidator (type) { + return function validator (url, params) { + // 格式化为绝对路径路由 + url = getRealRoute(url); + + const pagePath = url.split('?')[0]; + // 匹配路由是否存在 + const routeOptions = __uniRoutes.find(({ + path, + alias + }) => path === pagePath || alias === pagePath); + + if (!routeOptions) { + return 'page `' + url + '` is not found' } - locale = locale.trim().replace(/_/g, '-'); - if (messages[locale]) { - return locale; + + // 检测不同类型跳转 + if (type === 'navigateTo' || type === 'redirectTo') { + if (routeOptions.meta.isTabBar) { + return `can not ${type} a tabbar page` + } + } else if (type === 'switchTab') { + if (!routeOptions.meta.isTabBar) { + return 'can not switch to no-tabBar page' + } } - 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'; + + // switchTab不允许传递参数,reLaunch到一个tabBar页面是可以的 + if ( + (type === 'switchTab' || type === 'preloadPage') && + routeOptions.meta.isTabBar && + params.openType !== 'appLaunch' + ) { + url = pagePath; } - const lang = startsWith(locale, ['en', 'fr', 'es']); - if (lang) { - return lang; + + // 首页自动格式化为`/` + if (routeOptions.meta.isEntry) { + url = url.replace(routeOptions.alias, '/'); } - } - class I18n { - constructor({ locale, fallbackLocale, messages, watcher, formater, }) { - this.locale = 'en'; - this.fallbackLocale = 'en'; - this.message = {}; - this.messages = {}; - this.watchers = []; - if (fallbackLocale) { - this.fallbackLocale = fallbackLocale; + + // 参数格式化 + params.url = encodeQueryString(url); + if (type === 'unPreloadPage') { + return + } else if (type === 'preloadPage') { + { + if (!routeOptions.meta.isNVue) { + return 'can not preload vue page' } - this.formater = formater || defaultFormatter; - this.messages = messages; - this.setLocale(locale); - if (watcher) { - this.watchLocale(watcher); + } + if (routeOptions.meta.isTabBar) { + const pages = getCurrentPages(true); + const tabBarPagePath = (routeOptions.alias || routeOptions.path).substr(1); + if (pages.find(page => page.route === tabBarPagePath)) { + return 'tabBar page `' + tabBarPagePath + '` already exists' } + } + return } - 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); - }); + + // 主要拦截目标为用户快速点击时触发的多次跳转,该情况,通常前后 url 是一样的 + if (navigatorLock === url && params.openType !== 'appLaunch') { + return `${navigatorLock} locked` } - getLocale() { - return this.locale; + // 至少 onLaunch 之后,再启用lock逻辑(onLaunch之前可能开发者手动调用路由API,来提前跳转) + // enableNavigatorLock 临时开关(不对外开放),避免该功能上线后,有部分情况异常,可以让开发者临时关闭 lock 功能 + if (__uniConfig.ready && __uniConfig.enableNavigatorLock !== false) { + navigatorLock = url; } - watchLocale(fn) { - const index = this.watchers.push(fn) - 1; - return () => { - this.watchers.splice(index, 1); - }; + } + } + + let navigatorLock; + + function createProtocol (type, extras = {}) { + return Object.assign({ + url: { + type: String, + required: true, + validator: createValidator(type) + }, + beforeAll () { + navigatorLock = ''; } - t(key, values) { - if (!hasOwn$1(this.message, key)) { - console.warn(`Cannot translate the value of keypath ${key}. Use the value of keypath as default.`); - return key; + }, extras) + } + + function createAnimationProtocol (animationTypes) { + return { + animationType: { + type: String, + validator (type) { + if (type && animationTypes.indexOf(type) === -1) { + return '`' + type + '` is not supported for `animationType` (supported values are: `' + animationTypes.join( + '`|`') + '`)' } - return this.formater.interpolate(this.message[key], values).join(''); + } + }, + animationDuration: { + type: Number } - } + } + } + + const redirectTo = createProtocol('redirectTo'); + + const reLaunch = createProtocol('reLaunch'); + + const navigateTo = createProtocol('navigateTo', createAnimationProtocol( + [ + 'slide-in-right', + 'slide-in-left', + 'slide-in-top', + 'slide-in-bottom', + 'fade-in', + 'zoom-out', + 'zoom-fade-out', + 'pop-in', + 'none' + ] + )); + + const switchTab = createProtocol('switchTab'); + + const navigateBack = Object.assign({ + delta: { + type: Number, + validator (delta, params) { + delta = parseInt(delta) || 1; + params.delta = Math.min(getCurrentPages().length - 1, delta); + } + } + }, createAnimationProtocol( + [ + 'slide-out-right', + 'slide-out-left', + 'slide-out-top', + 'slide-out-bottom', + 'fade-out', + 'zoom-in', + 'zoom-fade-in', + 'pop-out', + 'none' + ] + )); + + const preloadPage = { + url: { + type: String, + required: true, + validator: createValidator('preloadPage') + } + }; + + const unPreloadPage = { + url: { + type: String, + required: true, + validator: createValidator('unPreloadPage') + } + }; + + var require_context_module_0_29 = /*#__PURE__*/Object.freeze({ + __proto__: null, + redirectTo: redirectTo, + reLaunch: reLaunch, + navigateTo: navigateTo, + switchTab: switchTab, + navigateBack: navigateBack, + preloadPage: preloadPage, + unPreloadPage: unPreloadPage + }); + + const getStorage = { + key: { + type: String, + required: true + } + }; + + const getStorageSync = [{ + name: 'key', + type: String, + required: true + }]; + + const setStorage = { + key: { + type: String, + required: true + }, + data: { + required: true + } + }; + + const setStorageSync = [{ + name: 'key', + type: String, + required: true + }, { + name: 'data', + required: true + }]; + + const removeStorage = getStorage; + const removeStorageSync = getStorageSync; - function initLocaleWatcher(appVm, i18n) { - appVm.$i18n && - appVm.$i18n.vm.$watch('locale', (newLocale) => { - i18n.setLocale(newLocale); - }, { - immediate: true, - }); - } - function getDefaultLocale() { - if (typeof navigator !== 'undefined') { - return navigator.userLanguage || navigator.language; - } - if (typeof plus !== 'undefined') { - // TODO 待调整为最新的获取语言代码 - return plus.os.language; - } - return uni.getSystemInfoSync().language; - } - function initVueI18n(messages, fallbackLocale = 'en', locale) { - const i18n = new I18n({ - locale: locale || fallbackLocale, - fallbackLocale, - messages, - }); - let t = (key, values) => { - if (typeof getApp !== 'function') { - // app-plus view - /* eslint-disable no-func-assign */ - t = function (key, values) { - return i18n.t(key, values); - }; - } - else { - const appVm = getApp().$vm; - if (!appVm.$t || !appVm.$i18n) { - if (!locale) { - i18n.setLocale(getDefaultLocale()); - } - /* eslint-disable no-func-assign */ - t = function (key, values) { - return i18n.t(key, values); - }; - } - else { - initLocaleWatcher(appVm, i18n); - /* eslint-disable no-func-assign */ - t = function (key, values) { - const $i18n = appVm.$i18n; - const silentTranslationWarn = $i18n.silentTranslationWarn; - $i18n.silentTranslationWarn = true; - const msg = appVm.$t(key, values); - $i18n.silentTranslationWarn = silentTranslationWarn; - if (msg !== key) { - return msg; - } - return i18n.t(key, values); - }; - } - } - return t(key, values); - }; - return { - t(key, values) { - return t(key, values); - }, - setLocale(newLocale) { - return i18n.setLocale(newLocale); - }, - mixin: { - beforeCreate() { - const unwatch = i18n.watchLocale(() => { - this.$forceUpdate(); - }); - this.$once('hook:beforeDestroy', function () { - unwatch(); - }); - }, - methods: { - $$t(key, values) { - return t(key, values); - }, - }, - }, - }; - } + var require_context_module_0_30 = /*#__PURE__*/Object.freeze({ + __proto__: null, + getStorage: getStorage, + getStorageSync: getStorageSync, + setStorage: setStorage, + setStorageSync: setStorageSync, + removeStorage: removeStorage, + removeStorageSync: removeStorageSync + }); - var en = { - "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": "confirm", - "uni.button.feedback.title": "feedback", - "uni.button.feedback.send": "send" + const loadFontFace = { + family: { + type: String, + required: true + }, + source: { + type: String, + required: true + }, + desc: { + type: Object, + required: false + }, + success: { + type: Function, + required: false + }, + fail: { + type: Function, + required: false + }, + complete: { + type: Function, + required: false + } }; - var es = { - "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": "confirmar", - "uni.button.feedback.title": "realimentación", - "uni.button.feedback.send": "enviar" - }; + var require_context_module_0_31 = /*#__PURE__*/Object.freeze({ + __proto__: null, + loadFontFace: loadFontFace + }); - var fr = { - "uni.showActionSheet.cancel": "Annuler", - "uni.showToast.unpaired": "Veuillez noter que showToast doit être associé à hideToast", - "uni.showLoading.unpaired": "Veuillez noter que showLoading doit être associé à hideLoading", - "uni.showModal.cancel": "Annuler", - "uni.showModal.confirm": "confirmer", - "uni.button.feedback.title": "retour d'information", - "uni.button.feedback.send": "envoyer" + const FRONT_COLORS = ['#ffffff', '#000000']; + const setNavigationBarColor = { + frontColor: { + type: String, + required: true, + validator (frontColor, params) { + if (FRONT_COLORS.indexOf(frontColor) === -1) { + return `invalid frontColor "${frontColor}"` + } + } + }, + backgroundColor: { + type: String, + required: true + }, + animation: { + type: Object, + default () { + return { + duration: 0, + timingFunc: 'linear' + } + }, + validator (animation = {}, params) { + params.animation = { + duration: animation.duration || 0, + timingFunc: animation.timingFunc || 'linear' + }; + } + } + }; + const setNavigationBarTitle = { + title: { + type: String, + required: true + } }; - var zhHans = { - "uni.showActionSheet.cancel": "取消", - "uni.showToast.unpaired": "请注意 showToast 与 hideToast 必须配对使用", - "uni.showLoading.unpaired": "请注意 showLoading 与 hideLoading 必须配对使用", - "uni.showModal.cancel": "取消", - "uni.showModal.confirm": "确认", - "uni.button.feedback.title": "问题反馈", - "uni.button.feedback.send": "发送" - }; + var require_context_module_0_32 = /*#__PURE__*/Object.freeze({ + __proto__: null, + setNavigationBarColor: setNavigationBarColor, + setNavigationBarTitle: setNavigationBarTitle + }); - var zhHant = { - "uni.showActionSheet.cancel": "取消", - "uni.showToast.unpaired": "請注意 showToast 與 hideToast 必須配對使用", - "uni.showLoading.unpaired": "請注意 showLoading 與 hideLoading 必須配對使用", - "uni.showModal.cancel": "取消", - "uni.showModal.confirm": "確認", - "uni.button.feedback.title": "問題反饋", - "uni.button.feedback.send": "發送" + const pageScrollTo = { + scrollTop: { + type: Number, + required: true + }, + duration: { + type: Number, + default: 300, + validator (duration, params) { + params.duration = Math.max(0, duration); + } + } }; - const messages = { - en, - es, - fr, - 'zh-Hans': zhHans, - 'zh-Hant': zhHant - }; - - const fallbackLocale = 'en'; - - const i18n = initVueI18n( messages , fallbackLocale); - const t = i18n.t; + var require_context_module_0_33 = /*#__PURE__*/Object.freeze({ + __proto__: null, + pageScrollTo: pageScrollTo + }); const showModal = { title: { @@ -4314,6 +4454,36 @@ var serviceContext = (function () { }, getScale (ctx, cbs) { return invokeVmMethodWithoutArgs(ctx, 'getScale', cbs) + }, + addCustomLayer (ctx, args) { + return invokeVmMethod(ctx, 'addCustomLayer', args) + }, + removeCustomLayer (ctx, args) { + return invokeVmMethod(ctx, 'removeCustomLayer', args) + }, + addGroundOverlay (ctx, args) { + return invokeVmMethod(ctx, 'addGroundOverlay', args) + }, + removeGroundOverlay (ctx, args) { + return invokeVmMethod(ctx, 'removeGroundOverlay', args) + }, + updateGroundOverlay (ctx, args) { + return invokeVmMethod(ctx, 'updateGroundOverlay', args) + }, + initMarkerCluster (ctx, args) { + return invokeVmMethod(ctx, 'initMarkerCluster', args) + }, + addMarkers (ctx, args) { + return invokeVmMethod(ctx, 'addMarkers', args) + }, + removeMarkers (ctx, args) { + return invokeVmMethod(ctx, 'removeMarkers', args) + }, + moveAlong (ctx, args) { + return invokeVmMethod(ctx, 'moveAlong', args) + }, + openMapApp (ctx, args) { + return invokeVmMethod(ctx, 'openMapApp', args) } }; @@ -4444,7 +4614,7 @@ var serviceContext = (function () { function createLivePusherContext (id, vm) { if (!vm) { - return console.warn('uni.createLivePusherContext 必须传入第二个参数,即当前 vm 对象(this)') + return console.warn('uni.createLivePusherContext: 2 arguments required, but only 1 present') } const elm = findElmById(id, vm); if (!elm) { @@ -4948,7 +5118,7 @@ var serviceContext = (function () { */ function registerPlusMessage (type, callback, keepAlive = true) { if (callbacks$1[type]) { - return console.warn(`${type} 已注册:` + (callbacks$1[type].toString())) + return console.warn(`'${type}' registered: ` + (callbacks$1[type].toString())) } callback.keepAlive = !!keepAlive; callbacks$1[type] = callback; @@ -5029,7 +5199,7 @@ var serviceContext = (function () { if (!onlyFromCamera) { buttons.push({ float: 'right', - text: '相册', + text: t('uni.scanCode.album'), fontSize: '17px', width: '60px', onclick: function () { @@ -5045,11 +5215,13 @@ var serviceContext = (function () { }; webview.close('auto'); }, () => { - plus.nativeUI.toast('识别失败'); + plus.nativeUI.toast(t('uni.scanCode.fail')); }, filters, autoDecodeCharSet); }, err => { - if (err.code !== 12) { - plus.nativeUI.toast('选择失败'); + // iOS {"code":-2,"message":"用户取消,https://ask.dcloud.net.cn/article/282"} + // Android {"code":12,"message":"User cancelled"} + if (err.code !== (plus.os.name === 'Android' ? 12 : -2)) { + plus.nativeUI.toast(t('uni.scanCode.fail')); } }, { multiple: false, @@ -5067,7 +5239,7 @@ var serviceContext = (function () { type: 'float', backgroundColor: 'rgba(0,0,0,0)', titleColor: '#ffffff', - titleText: '扫码', + titleText: t('uni.scanCode.title'), titleSize: '17px', buttons }, @@ -5078,6 +5250,7 @@ var serviceContext = (function () { __uniapp_dark: isDark, __uniapp_scan_type: filters, __uniapp_auto_decode_char_set: autoDecodeCharSet, + __uniapp_locale: getLocale(), 'uni-app': 'none' }); const waiting = plus.nativeUI.showWaiting(); @@ -5276,17 +5449,23 @@ var serviceContext = (function () { let result; const page = showPage({ url: '__uniappscan', - data: options, + data: Object.assign({}, options, { + messages: { + fail: t('uni.scanCode.fail'), + 'flash.on': t('uni.scanCode.flash.on'), + 'flash.off': t('uni.scanCode.flash.off') + } + }), style: { animationType: options.animationType || 'pop-in', titleNView: { autoBackButton: true, type: 'float', - titleText: options.titleText || '扫码', + titleText: options.titleText || t('uni.scanCode.title'), titleColor: '#ffffff', backgroundColor: 'rgba(0,0,0,0)', buttons: !options.onlyFromCamera ? [{ - text: options.albumText || '相册', + text: options.albumText || t('uni.scanCode.album'), fontSize: '17px', width: '60px', onclick: () => { @@ -5471,7 +5650,7 @@ var serviceContext = (function () { const realAuthMode = enrolledRequestAuthMode[0]; if (realAuthMode === 'fingerPrint') { if (plus.os.name.toLowerCase() === 'android') { - plus.nativeUI.showWaiting(authContent || '指纹识别中...').onclose = function () { + plus.nativeUI.showWaiting(authContent || t('uni.startSoterAuthentication.authContent')).onclose = function () { plus.fingerprint.cancel(); }; } @@ -5971,7 +6150,7 @@ var serviceContext = (function () { }); }, err => { invoke$1(callbackId, { - errMsg: 'openDocument:fail 文件[' + filePath + ']读取失败:' + err.message + errMsg: 'openDocument:fail ' + err.message }); }); } @@ -6482,11 +6661,11 @@ var serviceContext = (function () { } } plus.nativeUI.actionSheet({ - cancel: '取消', + cancel: t('uni.chooseImage.cancel'), buttons: [{ - title: '拍摄' + title: t('uni.chooseImage.sourceType.camera') }, { - title: '从手机相册选择' + title: t('uni.chooseImage.sourceType.album') }] }, (e) => { switch (e.index) { @@ -6559,11 +6738,11 @@ var serviceContext = (function () { } } plus.nativeUI.actionSheet({ - cancel: '取消', + cancel: t('uni.chooseVideo.cancel'), buttons: [{ - title: '拍摄' + title: t('uni.chooseVideo.sourceType.camera') }, { - title: '从手机相册选择' + title: t('uni.chooseVideo.sourceType.album') }] }, e => { switch (e.index) { @@ -6627,7 +6806,7 @@ var serviceContext = (function () { let title = ''; const hasLongPressActions = longPressActions && longPressActions.callbackId; if (!hasLongPressActions) { - itemList = ['保存相册']; + itemList = [t('uni.previewImage.button.save')]; itemColor = '#000000'; title = ''; } else { @@ -6641,14 +6820,11 @@ var serviceContext = (function () { title: item, color: itemColor })), - cancel: '' + cancel: t('uni.previewImage.cancel') }; if (title) { options.title = title; } - // if (plus.os.name === 'iOS') { - // options.cancel = '取消' - // } plus.nativeUI.actionSheet(options, (e) => { if (e.index > 0) { if (hasLongPressActions) { @@ -6660,9 +6836,9 @@ var serviceContext = (function () { return } plus.gallery.save(res.url, function (GallerySaveEvent) { - plus.nativeUI.toast('保存图片到相册成功'); + plus.nativeUI.toast(t('uni.previewImage.save.success')); }, function () { - plus.nativeUI.toast('保存图片到相册失败'); + plus.nativeUI.toast(t('uni.previewImage.save.fail')); }); } else if (hasLongPressActions) { publish(longPressActions.callbackId, { @@ -6724,14 +6900,14 @@ var serviceContext = (function () { pause () { if (recorder$1) { publishRecorderStateChange('error', { - errMsg: '暂不支持录音pause操作' + errMsg: 'Unsupported operation: pause' }); } }, resume () { if (recorder$1) { publishRecorderStateChange('error', { - errMsg: '暂不支持录音resume操作' + errMsg: 'Unsupported operation: resume' }); } } @@ -7320,7 +7496,7 @@ var serviceContext = (function () { }); } else { invoke$1(callbackId, { - errMsg: 'getProvider:fail 服务[' + service + ']不支持' + errMsg: 'getProvider:fail service not found' }); } } @@ -7414,7 +7590,7 @@ var serviceContext = (function () { }, errorCallback); }).catch(() => { invoke$1(callbackId, { - errMsg: 'operateWXData:fail:请先调用 uni.login' + errMsg: 'operateWXData:fail 请先调用 uni.login' }); }); } @@ -7454,7 +7630,7 @@ var serviceContext = (function () { }) => id === provider); if (!service) { invoke$1(callbackId, { - errMsg: 'requestPayment:fail 支付服务[' + provider + ']不存在' + errMsg: 'requestPayment:fail service not found' }); } else { plus.payment.request(service, params.orderInfo, res => { @@ -7491,7 +7667,7 @@ var serviceContext = (function () { return clientInfo } else { return { - errMsg: 'subscribePush:fail:请确保当前运行环境已包含 push 模块' + errMsg: 'subscribePush:fail 请确保当前运行环境已包含 push 模块' } } } @@ -7506,7 +7682,7 @@ var serviceContext = (function () { function onPush () { if (!isListening) { return { - errMsg: 'onPush:fail:请先调用 uni.subscribePush' + errMsg: 'onPush:fail 请先调用 uni.subscribePush' } } if (plus.push.getClientInfo()) { @@ -7516,7 +7692,7 @@ var serviceContext = (function () { } } return { - errMsg: 'onPush:fail:请确保当前运行环境已包含 push 模块' + errMsg: 'onPush:fail 请确保当前运行环境已包含 push 模块' } } @@ -7674,7 +7850,7 @@ var serviceContext = (function () { }) => id === provider); if (!service) { invoke$1(callbackId, { - errMsg: method + ':fail 分享服务[' + provider + ']不存在' + errMsg: method + ':fail service not found' }); } else { if (service.authenticated) { @@ -8283,7 +8459,7 @@ var serviceContext = (function () { delete style.type; if (isPopup && !subNVue.id) { - console.warn('subNVue[' + subNVue.path + '] 尚未配置 id'); + console.warn('subNVue[' + subNVue.path + '] is missing id'); } // TODO lazyload @@ -8603,7 +8779,7 @@ var serviceContext = (function () { plus.navigator.closeSplashscreen(); } if (!isAppLaunch && todoNavigator) { - return console.error(`已存在待跳转页面${todoNavigator.path},请不要连续多次跳转页面${path}`) + return console.error(`Waiting to navigate to: ${todoNavigator.path}, do not operate continuously: ${path}.`) } if (__uniConfig.renderer === 'native') { // 纯原生无需wait逻辑 // 如果是首页还未初始化,需要等一等,其他无需等待 @@ -8728,7 +8904,7 @@ var serviceContext = (function () { function quit () { if (!firstBackTime) { firstBackTime = Date.now(); - plus.nativeUI.toast('再按一次退出应用'); + plus.nativeUI.toast(t('uni.app.quit')); setTimeout(() => { firstBackTime = null; }, 2000); @@ -9876,7 +10052,8 @@ var serviceContext = (function () { duration = 1500, mask = false, position = '', - type = 'toast' + type = 'toast', + style } = {}) { hide(null); toastType = type; @@ -9924,7 +10101,7 @@ var serviceContext = (function () { } } - toast = plus.nativeUI.showWaiting(title, waitingOptions); + toast = plus.nativeUI.showWaiting(title, Object.assign(waitingOptions, style)); } timeout = setTimeout(() => { @@ -10000,7 +10177,7 @@ var serviceContext = (function () { options.title = title; } - options.cancel = ''; + options.cancel = t('uni.showActionSheet.cancel'); plus.nativeUI.actionSheet(Object.assign(options, { popover @@ -17926,9 +18103,7 @@ var serviceContext = (function () { a = a >= 0 ? a : 255; return [n, o, r, a] } - console.group('非法颜色: ' + e); - console.error('不支持颜色:' + e); - console.groupEnd(); + console.error('unsupported color:' + e); return [0, 0, 0, 255] } @@ -18623,7 +18798,22 @@ var serviceContext = (function () { callback.invoke(callbackId, data); }); - const methods = ['getCenterLocation', 'moveToLocation', 'getScale', 'getRegion', 'includePoints', 'translateMarker']; + const methods = ['getCenterLocation', + 'moveToLocation', + 'getScale', + 'getRegion', + 'includePoints', + 'translateMarker', + 'addCustomLayer', + 'removeCustomLayer', + 'addGroundOverlay', + 'removeGroundOverlay', + 'updateGroundOverlay', + 'initMarkerCluster', + 'addMarkers', + 'removeMarkers', + 'moveAlong', + 'openMapApp']; class MapContext { constructor (id, pageVm) { @@ -19017,7 +19207,7 @@ var serviceContext = (function () { function onUIStyleChange (callbackId) { callbacks$7.push(callbackId); - console.log('API uni.onUIStyleChange 已过时,请使用 uni.onThemeChange,详情:https://uniapp.dcloud.net.cn/api/system/theme'); + console.warn('The "uni.onUIStyleChange" API is deprecated, please use "uni.onThemeChange". Learn more: https://uniapp.dcloud.net.cn/api/system/theme.'); } var require_context_module_1_12 = /*#__PURE__*/Object.freeze({ @@ -20670,7 +20860,7 @@ var serviceContext = (function () { return defaultApp } console.error( - '[warn]: getApp() 操作失败,v3模式加速了首页 nvue 的启动速度,当在首页 nvue 中使用 getApp() 不一定可以获取真正的 App 对象。详情请参考:https://uniapp.dcloud.io/collocation/frame/window?id=getapp' + '[warn]: getApp() failed. Learn more: https://uniapp.dcloud.io/collocation/frame/window?id=getapp.' ); }