From e61d3e9d451166f868e5a2120ac2cedefeb167d6 Mon Sep 17 00:00:00 2001 From: fxy060608 Date: Fri, 6 Aug 2021 13:28:01 +0800 Subject: [PATCH] feat(app): androidPrivacy.json --- packages/uni-app-plus/dist/index.v3.js | 61 +++++++++---------- packages/uni-app-plus/lib/uni.config.js | 2 +- packages/uni-mp-weixin/lib/uni.config.js | 2 +- .../build/webpack.nvue.conf.js | 12 +++- packages/vue-cli-plugin-uni/lib/mp/index.js | 2 +- .../lib/plugin/index-new.js | 2 +- 6 files changed, 44 insertions(+), 37 deletions(-) diff --git a/packages/uni-app-plus/dist/index.v3.js b/packages/uni-app-plus/dist/index.v3.js index 9a1a8b02f..acb5eb22a 100644 --- a/packages/uni-app-plus/dist/index.v3.js +++ b/packages/uni-app-plus/dist/index.v3.js @@ -13,7 +13,8 @@ var serviceContext = (function () { 'base64ToArrayBuffer', 'arrayBufferToBase64', 'addInterceptor', - 'removeInterceptor' + 'removeInterceptor', + 'interceptors' ]; const network = [ @@ -253,7 +254,7 @@ var serviceContext = (function () { const ad = [ 'createRewardedVideoAd', 'createFullScreenVideoAd', - 'createInterstitialAd', + 'createInterstitialAd', 'createInteractiveAd' ]; @@ -693,7 +694,7 @@ var serviceContext = (function () { } if (res === false) { return { - then () {} + then () { } } } } @@ -741,15 +742,15 @@ var serviceContext = (function () { if (hook !== 'returnValue') { interceptor[hook] = globalInterceptors[hook].slice(); } - }); - const scopedInterceptor = scopedInterceptors[method]; - if (scopedInterceptor) { - Object.keys(scopedInterceptor).forEach(hook => { - if (hook !== 'returnValue') { - interceptor[hook] = (interceptor[hook] || []).concat(scopedInterceptor[hook]); - } - }); - } + }); + const scopedInterceptor = scopedInterceptors[method]; + if (scopedInterceptor) { + Object.keys(scopedInterceptor).forEach(hook => { + if (hook !== 'returnValue') { + interceptor[hook] = (interceptor[hook] || []).concat(scopedInterceptor[hook]); + } + }); + } return interceptor } @@ -773,10 +774,14 @@ var serviceContext = (function () { if (!isPromise(res)) { return res } - return res.then(res => { - return res[1] - }).catch(res => { - return res[0] + return new Promise((resolve, reject) => { + res.then(res => { + if (res[0]) { + reject(res[0]); + } else { + resolve(res[1]); + } + }); }) } }; @@ -1313,14 +1318,6 @@ var serviceContext = (function () { this.watchers.splice(index, 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') { @@ -1403,9 +1400,6 @@ var serviceContext = (function () { t(key, values) { return t(key, values); }, - getLocale() { - return i18n.getLocale(); - }, setLocale(newLocale) { return i18n.setLocale(newLocale); }, @@ -6806,11 +6800,11 @@ var serviceContext = (function () { const errorCallback = warpPlusErrorCallback(callbackId, 'chooseVideo', 'cancel'); function successCallback (tempFilePath = '') { - const dst = `${TEMP_PATH}/compressed/${Date.now()}_${getFileName(tempFilePath)}`; + const filename = `${TEMP_PATH}/compressed/${Date.now()}_${getFileName(tempFilePath)}`; const compressVideo = compressed ? new Promise((resolve) => { plus.zip.compressVideo({ src: tempFilePath, - dst + filename }, ({ tempFilePath }) => { resolve(tempFilePath); }, () => { @@ -6908,11 +6902,11 @@ var serviceContext = (function () { } function compressVideo$1 (options, callbackId) { - const dst = `${TEMP_PATH}/compressed/${Date.now()}_${getFileName(options.src)}`; + const filename = `${TEMP_PATH}/compressed/${Date.now()}_${getFileName(options.src)}`; const successCallback = warpPlusSuccessCallback(callbackId, 'compressVideo'); const errorCallback = warpPlusErrorCallback(callbackId, 'compressVideo'); plus.zip.compressVideo(Object.assign({}, options, { - dst + filename }), successCallback, errorCallback); } @@ -7536,7 +7530,7 @@ var serviceContext = (function () { } if (files && files.length) { files.forEach(file => { - uploader.addFile(getRealPath$1(file.uri), { + uploader.addFile(getRealPath$1(file.uri || file.filePath), { key: file.name || 'file' }); }); @@ -20967,6 +20961,9 @@ var serviceContext = (function () { } const evalJSCode = `typeof UniViewJSBridge !== 'undefined' && UniViewJSBridge.subscribeHandler("${eventType}",${args},__PAGE_ID__)`; + if (process.env.NODE_ENV !== 'production') { + console.log(`UNIAPP[publishHandler]:[${+new Date()}]`, 'length', evalJSCode.length); + } pageIds.forEach(id => { const webview = plus.webview.getWebviewById(String(id)); webview && webview.evalJS(evalJSCode.replace('__PAGE_ID__', id)); diff --git a/packages/uni-app-plus/lib/uni.config.js b/packages/uni-app-plus/lib/uni.config.js index 2241958b9..e482ed3ab 100644 --- a/packages/uni-app-plus/lib/uni.config.js +++ b/packages/uni-app-plus/lib/uni.config.js @@ -27,7 +27,7 @@ module.exports = { subPackages: true }, copyWebpackOptions (platformOptions, vueOptions) { - const copyOptions = [] + const copyOptions = ['androidPrivacy.json'] const componentsCopyOption = getComponentsCopyOption() if (componentsCopyOption) { copyOptions.push(componentsCopyOption) diff --git a/packages/uni-mp-weixin/lib/uni.config.js b/packages/uni-mp-weixin/lib/uni.config.js index 9041ec915..e0a984553 100644 --- a/packages/uni-mp-weixin/lib/uni.config.js +++ b/packages/uni-mp-weixin/lib/uni.config.js @@ -29,7 +29,7 @@ module.exports = { 'ext.json', 'custom-tab-bar', 'plugin.json', - 'functional-pages', + 'functional-pages' ] const workers = platformOptions.workers workers && copyOptions.push(workers) diff --git a/packages/vue-cli-plugin-hbuilderx/build/webpack.nvue.conf.js b/packages/vue-cli-plugin-hbuilderx/build/webpack.nvue.conf.js index 99b75f2a0..bec673e1d 100644 --- a/packages/vue-cli-plugin-hbuilderx/build/webpack.nvue.conf.js +++ b/packages/vue-cli-plugin-hbuilderx/build/webpack.nvue.conf.js @@ -208,7 +208,16 @@ if (process.env.UNI_USING_NATIVE || process.env.UNI_USING_V3_NATIVE) { const array = [{ from: path.resolve(process.env.UNI_INPUT_DIR, 'static'), to: 'static' - }] + }] + + const androidPrivacyPath = path.resolve(process.env.UNI_INPUT_DIR, 'androidPrivacy.json') + if (fs.existsSync(androidPrivacyPath)) { + array.push({ + from: androidPrivacyPath, + to: 'androidPrivacy.json' + }) + } + const hybridHtmlPath = path.resolve(process.env.UNI_INPUT_DIR, 'hybrid/html') if (fs.existsSync(hybridHtmlPath)) { array.push({ @@ -216,6 +225,7 @@ if (process.env.UNI_USING_NATIVE || process.env.UNI_USING_V3_NATIVE) { to: 'hybrid/html' }) } + if (process.env.UNI_USING_NVUE_COMPILER) { array.push({ from: path.resolve(getTemplatePath(), 'common'), diff --git a/packages/vue-cli-plugin-uni/lib/mp/index.js b/packages/vue-cli-plugin-uni/lib/mp/index.js index f830d77cc..a4799b64e 100644 --- a/packages/vue-cli-plugin-uni/lib/mp/index.js +++ b/packages/vue-cli-plugin-uni/lib/mp/index.js @@ -172,7 +172,7 @@ module.exports = { if (process.env.UNI_MP_PLUGIN) { // 小程序插件入口使用 // packages\webpack-uni-mp-loader\lib\plugin\index-new.js -> addMPPluginRequire - beforeCode += `wx.__webpack_require_${process.env.UNI_MP_PLUGIN.replace(/-/g,'_')}__ = __webpack_require__;` + beforeCode += `wx.__webpack_require_${process.env.UNI_MP_PLUGIN.replace(/-/g, '_')}__ = __webpack_require__;` const UNI_MP_PLUGIN_MAIN = process.env.UNI_MP_PLUGIN_MAIN if (UNI_MP_PLUGIN_MAIN) { diff --git a/packages/webpack-uni-mp-loader/lib/plugin/index-new.js b/packages/webpack-uni-mp-loader/lib/plugin/index-new.js index e2b376b84..40786c21b 100644 --- a/packages/webpack-uni-mp-loader/lib/plugin/index-new.js +++ b/packages/webpack-uni-mp-loader/lib/plugin/index-new.js @@ -80,7 +80,7 @@ function addMPPluginRequire (compilation) { const newlineIndex = compilation.assets[name].source().lastIndexOf('\n') const source = compilation.assets[name].source().substring(0, newlineIndex) + - `\nmodule.exports = wx.__webpack_require_${process.env.UNI_MP_PLUGIN.replace(/-/g,'_')}__('${uniModuleId}');\n` + + `\nmodule.exports = wx.__webpack_require_${process.env.UNI_MP_PLUGIN.replace(/-/g, '_')}__('${uniModuleId}');\n` + compilation.assets[name].source().substring(newlineIndex + 1) compilation.assets[name] = { -- GitLab