diff --git a/packages/shims-uni-app.d.ts b/packages/shims-uni-app.d.ts index d5515d14a0ca2ca5a09a461d4935579c25d6e11d..962a18df4ca4205f42784542975d1c89f0af0a29 100644 --- a/packages/shims-uni-app.d.ts +++ b/packages/shims-uni-app.d.ts @@ -188,6 +188,7 @@ declare namespace UniApp { interface PageRouteMeta extends PagesJsonPageStyle { id?: number route: string + i18n?: boolean isQuit?: boolean isEntry?: boolean isTabBar?: boolean diff --git a/packages/uni-app-plus/dist/uni-app-service.es.js b/packages/uni-app-plus/dist/uni-app-service.es.js index 05ed80f1caee2554bc570d761cc28d7288136216..87baa8da91c871ebd122be764a1ff1634616a3df 100644 --- a/packages/uni-app-plus/dist/uni-app-service.es.js +++ b/packages/uni-app-plus/dist/uni-app-service.es.js @@ -107,7 +107,7 @@ var serviceContext = (function (vue) { const extend = Object.assign; const hasOwnProperty$1 = Object.prototype.hasOwnProperty; const hasOwn$1 = (val, key) => hasOwnProperty$1.call(val, key); - const isArray = Array.isArray; + const isArray$1 = Array.isArray; const isFunction = (val) => typeof val === 'function'; const isString = (val) => typeof val === 'string'; const isObject$1 = (val) => val !== null && typeof val === 'object'; @@ -164,7 +164,7 @@ var serviceContext = (function (vue) { return str; } function elemsInArray(strArr, optionalVal) { - if (!isArray(strArr) || + if (!isArray$1(strArr) || strArr.length === 0 || strArr.find((val) => optionalVal.indexOf(val) === -1)) { return optionalVal; @@ -189,7 +189,7 @@ var serviceContext = (function (vue) { if (!protocol) { return; } - if (!isArray(protocol)) { + if (!isArray$1(protocol)) { return validateProtocol(name, args[0] || Object.create(null), protocol, onFail); } const len = protocol.length; @@ -219,7 +219,7 @@ var serviceContext = (function (vue) { // type check if (type != null) { let isValid = false; - const types = isArray(type) ? type : [type]; + const types = isArray$1(type) ? type : [type]; const expectedTypes = []; // value is valid as long as one of the specified types match for (let i = 0; i < types.length && !isValid; i++) { @@ -252,7 +252,7 @@ var serviceContext = (function (vue) { valid = isObject$1(value); } else if (expectedType === 'Array') { - valid = isArray(value); + valid = isArray$1(value); } else { { @@ -460,7 +460,7 @@ var serviceContext = (function (vue) { function wrapperOptions(interceptors, options = {}) { [HOOK_SUCCESS, HOOK_FAIL, HOOK_COMPLETE].forEach((name) => { const hooks = interceptors[name]; - if (!isArray(hooks)) { + if (!isArray$1(hooks)) { return; } const oldCallback = options[name]; @@ -474,11 +474,11 @@ var serviceContext = (function (vue) { } function wrapperReturnValue(method, returnValue) { const returnValueHooks = []; - if (isArray(globalInterceptors.returnValue)) { + if (isArray$1(globalInterceptors.returnValue)) { returnValueHooks.push(...globalInterceptors.returnValue); } const interceptor = scopedInterceptors[method]; - if (interceptor && isArray(interceptor.returnValue)) { + if (interceptor && isArray$1(interceptor.returnValue)) { returnValueHooks.push(...interceptor.returnValue); } returnValueHooks.forEach((hook) => { @@ -506,7 +506,7 @@ var serviceContext = (function (vue) { function invokeApi(method, api, options, ...params) { const interceptor = getApiInterceptorHooks(method); if (interceptor && Object.keys(interceptor).length) { - if (isArray(interceptor.invoke)) { + if (isArray$1(interceptor.invoke)) { const res = queue(interceptor.invoke, options); return res.then((options) => { return api(wrapperOptions(interceptor, options), ...params); @@ -797,7 +797,7 @@ var serviceContext = (function (vue) { if (key in query) { // an extra variable for ts types let currentValue = query[key]; - if (!isArray(currentValue)) { + if (!isArray$1(currentValue)) { currentValue = query[key] = [currentValue]; } currentValue.push(value); @@ -1262,18 +1262,20 @@ var serviceContext = (function (vue) { ON_NAVIGATION_BAR_SEARCH_INPUT_FOCUS_CHANGED, ]; + const isArray = Array.isArray; const isObject = (val) => val !== null && typeof val === 'object'; + const defaultDelimiters = ['{', '}']; class BaseFormatter { constructor() { this._caches = Object.create(null); } - interpolate(message, values) { + interpolate(message, values, delimiters = defaultDelimiters) { if (!values) { return [message]; } let tokens = this._caches[message]; if (!tokens) { - tokens = parse(message); + tokens = parse(message, delimiters); this._caches[message] = tokens; } return compile(tokens, values); @@ -1281,24 +1283,24 @@ var serviceContext = (function (vue) { } const RE_TOKEN_LIST_VALUE = /^(?:\d)+/; const RE_TOKEN_NAMED_VALUE = /^(?:\w)+/; - function parse(format) { + function parse(format, [startDelimiter, endDelimiter]) { const tokens = []; let position = 0; let text = ''; while (position < format.length) { let char = format[position++]; - if (char === '{') { + if (char === startDelimiter) { if (text) { tokens.push({ type: 'text', value: text }); } text = ''; let sub = ''; char = format[position++]; - while (char !== undefined && char !== '}') { + while (char !== undefined && char !== endDelimiter) { sub += char; char = format[position++]; } - const isClosed = char === '}'; + const isClosed = char === endDelimiter; const type = RE_TOKEN_LIST_VALUE.test(sub) ? 'list' : isClosed && RE_TOKEN_NAMED_VALUE.test(sub) @@ -1306,12 +1308,12 @@ var serviceContext = (function (vue) { : 'unknown'; tokens.push({ value: sub, type }); } - else if (char === '%') { - // when found rails i18n syntax, skip text capture - if (format[position] !== '{') { - text += char; - } - } + // else if (char === '%') { + // // when found rails i18n syntax, skip text capture + // if (format[position] !== '{') { + // text += char + // } + // } else { text += char; } @@ -1322,7 +1324,7 @@ var serviceContext = (function (vue) { function compile(tokens, values) { const compiled = []; let index = 0; - const mode = Array.isArray(values) + const mode = isArray(values) ? 'list' : isObject(values) ? 'named' @@ -1425,9 +1427,12 @@ var serviceContext = (function (vue) { this.messages[this.locale] = {}; } this.message = this.messages[this.locale]; - this.watchers.forEach((watcher) => { - watcher(this.locale, oldLocale); - }); + // 仅发生变化时,通知 + if (oldLocale !== this.locale) { + this.watchers.forEach((watcher) => { + watcher(this.locale, oldLocale); + }); + } } getLocale() { return this.locale; @@ -1543,6 +1548,9 @@ var serviceContext = (function (vue) { add(locale, message) { return i18n.add(locale, message); }, + watch(fn) { + return i18n.watchLocale(fn); + }, getLocale() { return i18n.getLocale(); }, @@ -2611,7 +2619,7 @@ var serviceContext = (function (vue) { const res = childVal ? parentVal ? parentVal.concat(childVal) - : isArray(childVal) + : isArray$1(childVal) ? childVal : [childVal] : parentVal; @@ -7350,7 +7358,7 @@ var serviceContext = (function (vue) { plus.gallery.save(options.filePath, warpPlusSuccessCallback(resolve), warpPlusErrorCallback(reject)); }, SaveImageToPhotosAlbumProtocol, SaveImageToPhotosAlbumOptions); - const compressImage = defineAsyncApi(API_COMPRESS_IMAGE, (options, { resolve, reject }) => { + const compressImage$1 = defineAsyncApi(API_COMPRESS_IMAGE, (options, { resolve, reject }) => { const dst = `${TEMP_PATH}/compressed/${Date.now()}_${getFileName(options.src)}`; plus.zip.compressImage(extend({}, options, { dst, @@ -7384,6 +7392,23 @@ var serviceContext = (function (vue) { }, reject); }); } + function compressImage(tempFilePath) { + const dst = `${TEMP_PATH}/compressed/${Date.now()}_${getFileName(tempFilePath)}`; + return new Promise((resolve) => { + plus.nativeUI.showWaiting(); + plus.zip.compressImage({ + src: tempFilePath, + dst, + overwrite: true, + }, () => { + plus.nativeUI.closeWaiting(); + resolve(dst); + }, () => { + plus.nativeUI.closeWaiting(); + resolve(tempFilePath); + }); + }); + } const chooseImage = defineAsyncApi(API_CHOOSE_IMAGE, // @ts-ignore crop 属性App特有 ({ count, sizeType, sourceType, crop } = {}, { resolve, reject }) => { @@ -7409,7 +7434,22 @@ var serviceContext = (function (vue) { } function openCamera() { const camera = plus.camera.getCamera(); - camera.captureImage((path) => successCallback([path]), errorCallback, { + camera.captureImage((path) => { + // fix By Lxh 暂时添加拍照压缩逻辑,等客户端增加逻辑后修改 + // 判断是否需要压缩 + if (sizeType && sizeType.includes('compressed')) { + return getFileInfo(path) + .then(({ size }) => { + // 压缩阈值 0.5 兆 + const THRESHOLD = 1024 * 1024 * 0.5; + return size && size > THRESHOLD + ? compressImage(path).then((dstPath) => successCallback([dstPath])) + : successCallback([path]); + }) + .catch(errorCallback); + } + return successCallback([path]); + }, errorCallback, { filename: TEMP_PATH + '/camera/', resolution: 'high', crop, @@ -9717,7 +9757,7 @@ var serviceContext = (function (vue) { Object.keys(options).forEach((name) => { if (name.indexOf('on') === 0) { const hooks = options[name]; - if (isArray(hooks)) { + if (isArray$1(hooks)) { hooks.forEach((hook) => injectLifecycleHook(name, hook, publicThis, instance)); } else { @@ -9740,7 +9780,7 @@ var serviceContext = (function (vue) { initModules(instance, options.$renderjs, options['$' + RENDERJS_MODULES]); } function initModules(instance, modules, moduleIds = {}) { - if (!isArray(modules)) { + if (!isArray$1(modules)) { return; } const ownerId = instance.uid; @@ -10309,7 +10349,7 @@ var serviceContext = (function (vue) { else if (name === 'titleImage' && value) { titleNView.tags = createTitleImageTags(value); } - else if (name === 'buttons' && isArray(value)) { + else if (name === 'buttons' && isArray$1(value)) { titleNView.buttons = value.map((button, index) => { button.onclick = createTitleNViewBtnClick(index); return button; @@ -12468,7 +12508,7 @@ var serviceContext = (function (vue) { getRecorderManager: getRecorderManager, saveVideoToPhotosAlbum: saveVideoToPhotosAlbum, saveImageToPhotosAlbum: saveImageToPhotosAlbum, - compressImage: compressImage, + compressImage: compressImage$1, compressVideo: compressVideo, chooseImage: chooseImage, chooseVideo: chooseVideo, @@ -12548,7 +12588,7 @@ var serviceContext = (function (vue) { if ((process.env.NODE_ENV !== 'production')) { console.log(formatLog('publishHandler', event, args, pageIds)); } - if (!isArray(pageIds)) { + if (!isArray$1(pageIds)) { pageIds = [pageIds]; } const evalJSCode = `typeof UniViewJSBridge !== 'undefined' && UniViewJSBridge.subscribeHandler("${event}",${args},__PAGE_ID__)`; diff --git a/packages/uni-app-plus/dist/uni-app-view.umd.js b/packages/uni-app-plus/dist/uni-app-view.umd.js index e4df9af87ed24281b822602df0c0818c2189c953..c572db5611744e11310ff7950fa58919b9a45e6c 100644 --- a/packages/uni-app-plus/dist/uni-app-view.umd.js +++ b/packages/uni-app-plus/dist/uni-app-view.umd.js @@ -1 +1 @@ -!function(e){"function"==typeof define&&define.amd?define(e):e()}((function(){"use strict";var e={exports:{}},t={exports:{}},n={exports:{}},r=n.exports={version:"2.6.12"};"number"==typeof __e&&(__e=r);var i={exports:{}},a=i.exports=void 0!==a&&a.Math==Math?a:"undefined"!=typeof self&&self.Math==Math?self:Function("return this")();"number"==typeof __g&&(__g=a);var o=n.exports,s=i.exports,l="__core-js_shared__",u=s[l]||(s[l]={});(t.exports=function(e,t){return u[e]||(u[e]=void 0!==t?t:{})})("versions",[]).push({version:o.version,mode:"window",copyright:"© 2020 Denis Pushkarev (zloirock.ru)"});var c=0,d=Math.random(),h=function(e){return"Symbol(".concat(void 0===e?"":e,")_",(++c+d).toString(36))},p=t.exports("wks"),f=h,v=i.exports.Symbol,g="function"==typeof v;(e.exports=function(e){return p[e]||(p[e]=g&&v[e]||(g?v:f)("Symbol."+e))}).store=p;var m={},y=function(e){return"object"==typeof e?null!==e:"function"==typeof e},_=y,b=function(e){if(!_(e))throw TypeError(e+" is not an object!");return e},w=function(e){try{return!!e()}catch(t){return!0}},x=!w((function(){return 7!=Object.defineProperty({},"a",{get:function(){return 7}}).a})),S=y,T=i.exports.document,E=S(T)&&S(T.createElement),k=function(e){return E?T.createElement(e):{}},C=!x&&!w((function(){return 7!=Object.defineProperty(k("div"),"a",{get:function(){return 7}}).a})),M=y,O=b,I=C,N=function(e,t){if(!M(e))return e;var n,r;if(t&&"function"==typeof(n=e.toString)&&!M(r=n.call(e)))return r;if("function"==typeof(n=e.valueOf)&&!M(r=n.call(e)))return r;if(!t&&"function"==typeof(n=e.toString)&&!M(r=n.call(e)))return r;throw TypeError("Can't convert object to primitive value")},L=Object.defineProperty;m.f=x?Object.defineProperty:function(e,t,n){if(O(e),t=N(t,!0),O(n),I)try{return L(e,t,n)}catch(r){}if("get"in n||"set"in n)throw TypeError("Accessors not supported!");return"value"in n&&(e[t]=n.value),e};var A=function(e,t){return{enumerable:!(1&e),configurable:!(2&e),writable:!(4&e),value:t}},P=m,R=A,B=x?function(e,t,n){return P.f(e,t,R(1,n))}:function(e,t,n){return e[t]=n,e},D=e.exports("unscopables"),$=Array.prototype;null==$[D]&&B($,D,{});var F={},j={}.toString,W=function(e){return j.call(e).slice(8,-1)},V=function(e){if(null==e)throw TypeError("Can't call method on "+e);return e},z=Object("z").propertyIsEnumerable(0)?Object:function(e){return"String"==W(e)?e.split(""):Object(e)},H=V,q=function(e){return z(H(e))},U={exports:{}},Y={}.hasOwnProperty,X=function(e,t){return Y.call(e,t)},G=t.exports("native-function-to-string",Function.toString),J=i.exports,K=B,Z=X,Q=h("src"),ee=G,te="toString",ne=(""+ee).split(te);n.exports.inspectSource=function(e){return ee.call(e)},(U.exports=function(e,t,n,r){var i="function"==typeof n;i&&(Z(n,"name")||K(n,"name",t)),e[t]!==n&&(i&&(Z(n,Q)||K(n,Q,e[t]?""+e[t]:ne.join(String(t)))),e===J?e[t]=n:r?e[t]?e[t]=n:K(e,t,n):(delete e[t],K(e,t,n)))})(Function.prototype,te,(function(){return"function"==typeof this&&this[Q]||ee.call(this)}));var re=function(e){if("function"!=typeof e)throw TypeError(e+" is not a function!");return e},ie=re,ae=i.exports,oe=n.exports,se=B,le=U.exports,ue=function(e,t,n){if(ie(e),void 0===t)return e;switch(n){case 1:return function(n){return e.call(t,n)};case 2:return function(n,r){return e.call(t,n,r)};case 3:return function(n,r,i){return e.call(t,n,r,i)}}return function(){return e.apply(t,arguments)}},ce=function(e,t,n){var r,i,a,o,s=e&ce.F,l=e&ce.G,u=e&ce.S,c=e&ce.P,d=e&ce.B,h=l?ae:u?ae[t]||(ae[t]={}):(ae[t]||{}).prototype,p=l?oe:oe[t]||(oe[t]={}),f=p.prototype||(p.prototype={});for(r in l&&(n=t),n)a=((i=!s&&h&&void 0!==h[r])?h:n)[r],o=d&&i?ue(a,ae):c&&"function"==typeof a?ue(Function.call,a):a,h&&le(h,r,a,e&ce.U),p[r]!=a&&se(p,r,o),c&&f[r]!=a&&(f[r]=a)};ae.core=oe,ce.F=1,ce.G=2,ce.S=4,ce.P=8,ce.B=16,ce.W=32,ce.U=64,ce.R=128;var de,he=ce,pe=Math.ceil,fe=Math.floor,ve=function(e){return isNaN(e=+e)?0:(e>0?fe:pe)(e)},ge=ve,me=Math.min,ye=ve,_e=Math.max,be=Math.min,we=q,xe=function(e){return e>0?me(ge(e),9007199254740991):0},Se=function(e,t){return(e=ye(e))<0?_e(e+t,0):be(e,t)},Te=t.exports("keys"),Ee=h,ke=function(e){return Te[e]||(Te[e]=Ee(e))},Ce=X,Me=q,Oe=(de=!1,function(e,t,n){var r,i=we(e),a=xe(i.length),o=Se(n,a);if(de&&t!=t){for(;a>o;)if((r=i[o++])!=r)return!0}else for(;a>o;o++)if((de||o in i)&&i[o]===t)return de||o||0;return!de&&-1}),Ie=ke("IE_PROTO"),Ne="constructor,hasOwnProperty,isPrototypeOf,propertyIsEnumerable,toLocaleString,toString,valueOf".split(","),Le=function(e,t){var n,r=Me(e),i=0,a=[];for(n in r)n!=Ie&&Ce(r,n)&&a.push(n);for(;t.length>i;)Ce(r,n=t[i++])&&(~Oe(a,n)||a.push(n));return a},Ae=Ne,Pe=Object.keys||function(e){return Le(e,Ae)},Re=m,Be=b,De=Pe,$e=x?Object.defineProperties:function(e,t){Be(e);for(var n,r=De(t),i=r.length,a=0;i>a;)Re.f(e,n=r[a++],t[n]);return e},Fe=i.exports.document,je=Fe&&Fe.documentElement,We=b,Ve=$e,ze=Ne,He=ke("IE_PROTO"),qe=function(){},Ue=function(){var e,t=k("iframe"),n=ze.length;for(t.style.display="none",je.appendChild(t),t.src="javascript:",(e=t.contentWindow.document).open(),e.write("