From cb1435d6155cf9260477179cc06a14f4b1d885e6 Mon Sep 17 00:00:00 2001 From: fxy060608 Date: Fri, 27 Mar 2020 16:47:05 +0800 Subject: [PATCH] refactor(cli): plugin --- lib/h5/uni.config.js | 49 ++ package.json | 2 +- packages/uni-app-plus/lib/uni.config.js | 44 ++ packages/uni-app-plus/package.json | 36 +- .../template/common/__uniappchooselocation.js | 1 + .../template/common/__uniappopenlocation.js | 1 + .../template/common/__uniapppicker.js | 1 + .../template/common/__uniappscan.js | 1 + .../template/common/__uniappsuccess.png | Bin 0 -> 2021 bytes .../uni-app-plus/template/v3/__uniappes6.js | 1 + .../uni-app-plus/template/v3/__uniappquill.js | 8 + .../template/v3/__uniappquillimageresize.js | 1 + .../template/v3/__uniappsuccess.png | Bin 0 -> 2021 bytes .../template/v3/__uniappview.html | 28 + packages/uni-cli-shared/lib/index.js | 10 +- packages/uni-cli-shared/lib/manifest.js | 9 +- packages/uni-cli-shared/lib/platform.js | 493 +----------------- packages/uni-cli-shared/lib/plugin.js | 127 +++++ packages/uni-cli-shared/lib/preprocess.js | 63 +++ packages/uni-cli-shared/lib/util.js | 42 +- packages/uni-h5/package.json | 47 +- packages/uni-migration/lib/index.js | 4 +- packages/uni-migration/lib/util.js | 4 +- packages/uni-migration/lib/validate.js | 2 +- packages/uni-migration/lib/vant.js | 2 +- packages/uni-mp-alipay/lib/uni.config.js | 20 + packages/uni-mp-alipay/package.json | 36 +- packages/uni-mp-baidu/lib/uni.config.js | 20 + packages/uni-mp-baidu/package.json | 36 +- packages/uni-mp-qq/lib/uni.config.js | 41 ++ packages/uni-mp-qq/package.json | 36 +- packages/uni-mp-toutiao/lib/uni.config.js | 17 + packages/uni-mp-toutiao/package.json | 36 +- packages/uni-mp-weixin/lib/uni.config.js | 41 ++ packages/uni-mp-weixin/package.json | 36 +- packages/uni-quickapp/lib/chain-webpack.js | 5 +- packages/uni-quickapp/lib/compiler-module.js | 2 +- .../uni-quickapp/lib/configure-webpack.js | 20 +- .../lib/{vue.config.js => uni.config.js} | 0 packages/uni-quickapp/lib/validate.js | 2 +- packages/uni-quickapp/package.json | 10 +- .../build/webpack.nvue.conf.js | 5 +- packages/vue-cli-plugin-hbuilderx/index.js | 8 +- .../vue-cli-plugin-hbuilderx/module-alias.js | 14 +- packages/vue-cli-plugin-hbuilderx/util.js | 64 +++ packages/vue-cli-plugin-uni/index.js | 9 +- .../lib/configure-webpack.js | 18 +- .../lib/copy-webpack-options.js | 70 ++- packages/vue-cli-plugin-uni/lib/env.js | 38 +- .../webpack-uni-mp-loader/lib/template-new.js | 73 --- .../webpack-uni-mp-loader/lib/template.bak.js | 69 +++ .../webpack-uni-mp-loader/lib/template.js | 104 ++-- 52 files changed, 1003 insertions(+), 803 deletions(-) create mode 100644 lib/h5/uni.config.js create mode 100644 packages/uni-app-plus/lib/uni.config.js create mode 100644 packages/uni-app-plus/template/common/__uniappchooselocation.js create mode 100644 packages/uni-app-plus/template/common/__uniappopenlocation.js create mode 100644 packages/uni-app-plus/template/common/__uniapppicker.js create mode 100644 packages/uni-app-plus/template/common/__uniappscan.js create mode 100644 packages/uni-app-plus/template/common/__uniappsuccess.png create mode 100644 packages/uni-app-plus/template/v3/__uniappes6.js create mode 100644 packages/uni-app-plus/template/v3/__uniappquill.js create mode 100644 packages/uni-app-plus/template/v3/__uniappquillimageresize.js create mode 100644 packages/uni-app-plus/template/v3/__uniappsuccess.png create mode 100644 packages/uni-app-plus/template/v3/__uniappview.html create mode 100644 packages/uni-cli-shared/lib/plugin.js create mode 100644 packages/uni-cli-shared/lib/preprocess.js create mode 100644 packages/uni-mp-alipay/lib/uni.config.js create mode 100644 packages/uni-mp-baidu/lib/uni.config.js create mode 100644 packages/uni-mp-qq/lib/uni.config.js create mode 100644 packages/uni-mp-toutiao/lib/uni.config.js create mode 100644 packages/uni-mp-weixin/lib/uni.config.js rename packages/uni-quickapp/lib/{vue.config.js => uni.config.js} (100%) create mode 100644 packages/vue-cli-plugin-hbuilderx/util.js delete mode 100644 packages/webpack-uni-mp-loader/lib/template-new.js create mode 100644 packages/webpack-uni-mp-loader/lib/template.bak.js diff --git a/lib/h5/uni.config.js b/lib/h5/uni.config.js new file mode 100644 index 000000000..e78655915 --- /dev/null +++ b/lib/h5/uni.config.js @@ -0,0 +1,49 @@ +const fs = require('fs') +const path = require('path') + +function getTemplatePath(template) { + if (template) { + return path.resolve(process.env.UNI_INPUT_DIR, template) + } + return path.resolve(process.env.UNI_CLI_CONTEXT, 'public/index.html') +} + +function transform(content) { + if (process.env.NODE_ENV === 'production') { + return content + // shadow + `body::after{position:fixed;content:'';left:-1000px;top:-1000px;-webkit-animation:shadow-preload .1s;-webkit-animation-delay:3s;animation:shadow-preload .1s;animation-delay:3s}@-webkit-keyframes shadow-preload{0%{background-image:url(https://cdn.dcloud.net.cn/img/shadow-grey.png)}100%{background-image:url(https://cdn.dcloud.net.cn/img/shadow-grey.png)}}@keyframes shadow-preload{0%{background-image:url(https://cdn.dcloud.net.cn/img/shadow-grey.png)}100%{background-image:url(https://cdn.dcloud.net.cn/img/shadow-grey.png)}}` + } + return content +} + +function getIndexCssPath(assetsDir, template) { + const VUE_APP_INDEX_CSS_HASH = process.env.VUE_APP_INDEX_CSS_HASH + if (VUE_APP_INDEX_CSS_HASH) { + try { + const templateContent = fs.readFileSync(getTemplatePath(template)) + if (/\bVUE_APP_INDEX_CSS_HASH\b/.test(templateContent)) { + return path.join(assetsDir, `[name].${VUE_APP_INDEX_CSS_HASH}.[ext]`) + } + } catch (e) {} + } + return assetsDir +} + +module.exports = { + options: { + cssVars: { + '--status-bar-height': '0px' + }, + filterTag: 'wxs', + vue: '@dcloudio/vue-cli-plugin-uni/packages/h5-vue' + }, + copyWebpackOptions(platformOptions, vueOptions) { + return [{ + from: require.resolve('@dcloudio/uni-h5/dist/index.css'), + to: getIndexCssPath(vueOptions.assetsDir, platformOptions.template), + transform + }, + 'hybrid/html' + ] + } +} diff --git a/package.json b/package.json index 39e4691a5..7b75efc80 100644 --- a/package.json +++ b/package.json @@ -4,7 +4,7 @@ "scripts": { "build:service:legacy": "npm run lint && rollup -c build/rollup.config.service.js", "lint": "eslint --fix --config package.json --ext .js --ext .vue --ignore-path .eslintignore build src", - "lint:cli": "eslint --fix --config package.json --ext .js --ext .vue --ignore-path .eslintignore packages/uni-cli-shared packages/uni-template-compiler \"packages/vue-cli-*/**/*.js\" \"packages/webpack-uni-*/**/*.js\"", + "lint:cli": "eslint --fix --config package.json --ext .js --ext .vue --ignore-path .eslintignore packages/uni-cli-shared packages/uni-template-compiler \"packages/uni-*/lib/*.js\" \"packages/vue-cli-*/**/*.js\" \"packages/webpack-uni-*/**/*.js\"", "dev:h5": "npm run lint && cross-env NODE_ENV=production UNI_WATCH=true UNI_PLATFORM=h5 node build/build.js", "build:h5": "npm run lint && cross-env NODE_ENV=production UNI_WATCH=false UNI_PLATFORM=h5 node build/build.js", "build:h5:ui": "cross-env NODE_ENV=production UNI_WATCH=false UNI_PLATFORM=h5 UNI_UI=true node build/build.js", diff --git a/packages/uni-app-plus/lib/uni.config.js b/packages/uni-app-plus/lib/uni.config.js new file mode 100644 index 000000000..cc123014b --- /dev/null +++ b/packages/uni-app-plus/lib/uni.config.js @@ -0,0 +1,44 @@ +const fs = require('fs') +const path = require('path') + +const COMPONENTS_DIR_NAME = 'wxcomponents' + +function getComponentsCopyOption () { + if (process.env.UNI_OUTPUT_TMP_DIR) { // TODO v3不需要,即将废弃 + const componentsDir = path.resolve(process.env.UNI_INPUT_DIR, COMPONENTS_DIR_NAME) + if (fs.existsSync(componentsDir)) { + return { + from: componentsDir, + to: COMPONENTS_DIR_NAME, + ignore: ['**/*.vue', '**/*.css'] + } + } + } +} + +module.exports = { + options: { + extnames: { // TODO v3不需要此配置 + style: '.wxss', + template: '.wxml', + filter: '.wxs' + }, + filterTag: 'wxs' + }, + copyWebpackOptions (platformOptions, vueOptions) { + const copyOptions = [] + const componentsCopyOption = getComponentsCopyOption() + if (componentsCopyOption) { + copyOptions.push(componentsCopyOption) + } + copyOptions.push('hybrid/html') + if (process.env.UNI_USING_V3) { // TODO 将仅保留v3逻辑 + copyOptions.push(path.resolve(__dirname, '../dist/view.css')) + copyOptions.push(path.resolve(__dirname, '../dist/view.umd.min.js')) + // TODO 后续common与v3目录应该合并 + copyOptions.push(path.resolve(__dirname, '../template/common')) + copyOptions.push(path.resolve(__dirname, '../template/v3')) + } + return copyOptions + } +} diff --git a/packages/uni-app-plus/package.json b/packages/uni-app-plus/package.json index d4706c538..3f3650bfa 100644 --- a/packages/uni-app-plus/package.json +++ b/packages/uni-app-plus/package.json @@ -1,17 +1,21 @@ -{ - "name": "@dcloudio/uni-app-plus", - "version": "2.0.0-alpha-26420200309002", - "description": "uni-app app-plus", - "main": "dist/index.js", - "repository": { - "type": "git", - "url": "git+https://github.com/dcloudio/uni-app.git", - "directory": "packages/uni-app-plus" - }, - "scripts": { - "test": "echo \"Error: no test specified\" && exit 1" - }, - "author": "fxy060608", - "license": "Apache-2.0", - "gitHead": "84e9cb1ca1898054d161f1514efadd1ab24fd804" +{ + "name": "@dcloudio/uni-app-plus", + "version": "2.0.0-alpha-26420200309002", + "description": "uni-app app-plus", + "main": "dist/index.js", + "repository": { + "type": "git", + "url": "git+https://github.com/dcloudio/uni-app.git", + "directory": "packages/uni-app-plus" + }, + "scripts": { + "test": "echo \"Error: no test specified\" && exit 1" + }, + "author": "fxy060608", + "license": "Apache-2.0", + "uni-app": { + "name": "app-plus", + "title": "APP-PLUS" + }, + "gitHead": "84e9cb1ca1898054d161f1514efadd1ab24fd804" } diff --git a/packages/uni-app-plus/template/common/__uniappchooselocation.js b/packages/uni-app-plus/template/common/__uniappchooselocation.js new file mode 100644 index 000000000..9bbff37ce --- /dev/null +++ b/packages/uni-app-plus/template/common/__uniappchooselocation.js @@ -0,0 +1 @@ +!function(e){var t={};function A(a){if(t[a])return t[a].exports;var i=t[a]={i:a,l:!1,exports:{}};return e[a].call(i.exports,i,i.exports,A),i.l=!0,i.exports}A.m=e,A.c=t,A.d=function(e,t,a){A.o(e,t)||Object.defineProperty(e,t,{enumerable:!0,get:a})},A.r=function(e){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})},A.t=function(e,t){if(1&t&&(e=A(e)),8&t)return e;if(4&t&&"object"==typeof e&&e&&e.__esModule)return e;var a=Object.create(null);if(A.r(a),Object.defineProperty(a,"default",{enumerable:!0,value:e}),2&t&&"string"!=typeof e)for(var i in e)A.d(a,i,function(t){return e[t]}.bind(null,i));return a},A.n=function(e){var t=e&&e.__esModule?function(){return e.default}:function(){return e};return A.d(t,"a",t),t},A.o=function(e,t){return Object.prototype.hasOwnProperty.call(e,t)},A.p="",A(A.s=40)}([function(e,t){e.exports={}},function(e,t,A){"use strict";function a(e,t,A,a,i,n,o,s){var r,c="function"==typeof e?e.options:e;if(t&&(c.render=t,c.staticRenderFns=A,c._compiled=!0),a&&(c.functional=!0),n&&(c._scopeId="data-v-"+n),o?(r=function(e){(e=e||this.$vnode&&this.$vnode.ssrContext||this.parent&&this.parent.$vnode&&this.parent.$vnode.ssrContext)||"undefined"==typeof __VUE_SSR_CONTEXT__||(e=__VUE_SSR_CONTEXT__),i&&i.call(this,e),e&&e._registeredComponents&&e._registeredComponents.add(o)},c._ssrRegister=r):i&&(r=s?function(){i.call(this,this.$root.$options.shadowRoot)}:i),r)if(c.functional){c._injectStyles=r;var l=c.render;c.render=function(e,t){return r.call(t),l(e,t)}}else{var d=c.beforeCreate;c.beforeCreate=d?[].concat(d,r):[r]}return{exports:e,options:c}}A.d(t,"a",function(){return a})},function(e,t,A){"use strict";var a;Object.defineProperty(t,"__esModule",{value:!0}),t.weexPlus=t.default=void 0,a="function"==typeof getUni?getUni:function(){var e=function(e){return"function"==typeof e},t=/^\$|^on|^create|Sync$|Manager$|^pause/,A=["os","getCurrentSubNVue","getSubNVueById","stopRecord","stopVoice","stopBackgroundAudio","stopPullDownRefresh","hideKeyboard","hideToast","hideLoading","showNavigationBarLoading","hideNavigationBarLoading","canIUse","navigateBack","closeSocket","pageScrollTo","drawCanvas"],a=function(e){return!(t.test(e)&&"createBLEConnection"!==e||~A.indexOf(e))},n=function(t){return function(){for(var A=arguments.length,a=Array(A>1?A-1:0),i=1;i0&&void 0!==arguments[0]?arguments[0]:{};return e(n.success)||e(n.fail)||e(n.complete)?t.apply(void 0,[n].concat(a)):new Promise(function(e,A){t.apply(void 0,[Object.assign({},n,{success:e,fail:A})].concat(a)),Promise.prototype.finally=function(e){var t=this.constructor;return this.then(function(A){return t.resolve(e()).then(function(){return A})},function(A){return t.resolve(e()).then(function(){throw A})})}}).then(function(e){return[null,e]}).catch(function(e){return[e]})}},o=[],s=void 0;function r(e){o.forEach(function(t){return t({origin:s,data:e})})}var c=i.webview.currentWebview().id,l=new BroadcastChannel("UNI-APP-SUBNVUE");function d(e){e.$processed=!0;var t=i.webview.currentWebview().id===e.id,A="uniNView"===e.__uniapp_origin_type&&e.__uniapp_origin_id,a=e.id;if(e.postMessage=function(e){A?l.postMessage({data:e,to:t?A:a}):m({type:"UniAppSubNVue",data:e})},e.onMessage=function(e){o.push(e)},e.__uniapp_mask_id){s=e.__uniapp_host;var n=e.__uniapp_mask,r=i.webview.getWebviewById(e.__uniapp_mask_id);r=r.parent()||r;var c=e.show,d=e.hide,u=e.close,g=function(){r.setStyle({mask:"none"})};e.show=function(){r.setStyle({mask:n});for(var t=arguments.length,A=Array(t),a=0;a1&&void 0!==arguments[1]?arguments[1]:Q,A=arguments.length>2&&void 0!==arguments[2]?arguments[2]:"application/x-www-form-urlencoded";return"object"===(void 0===e?"undefined":T(e))?"POST"===t.toUpperCase()&&"application/json"===A.toLowerCase()?JSON.stringify(e):Object.keys(e).map(function(t){return encodeURIComponent(t)+"="+encodeURIComponent(e[t])}).join("&"):e},G=weex.requireModule("plusstorage"),U="__TYPE",R=weex.requireModule("clipboard"),V=function(){if("function"==typeof getUniEmitter)return getUniEmitter;var e={$on:function(){console.warn("uni.$on failed")},$off:function(){console.warn("uni.$off failed")},$once:function(){console.warn("uni.$once failed")},$emit:function(){console.warn("uni.$emit failed")}};return function(){return e}}();function F(e,t,A){return e[t].apply(e,A)}var Y=Object.freeze({loadFontFace:function(t){var A=t.family,a=t.source,i=(t.desc,t.success),n=(t.fail,t.complete);P.addRule("fontFace",{fontFamily:A,src:a.replace(/"/g,"'")});var o={errMsg:"loadFontFace:ok",status:"loaded"};e(i)&&i(o),e(n)&&n(o)},ready:O,request:function(t){var A=t.url,a=t.data,i=t.header,n=t.method,o=void 0===n?"GET":n,s=t.dataType,r=void 0===s?"json":s,c=(t.responseType,t.success),l=t.fail,d=t.complete,u=!1,g=!1,f={};if(i)for(var p in i)g||"content-type"!==p.toLowerCase()?f[p]=i[p]:(g=!0,f["Content-Type"]=i[p]);return o===Q&&a&&(A=A+(~A.indexOf("?")?"&"===A.substr(-1)||"?"===A.substr(-1)?"":"&":"?")+D(a)),N.fetch({url:A,method:o,headers:f,type:"json"===r?"json":"text",body:o!==Q?D(a,o,f["Content-Type"]):""},function(t){var A=t.status,a=(t.ok,t.statusText,t.data),i=t.headers,n={};!A||-1===A||u?(n.errMsg="request:fail",e(l)&&l(n)):(n.data=a,n.statusCode=A,n.header=i,e(c)&&c(n)),e(d)&&d(n)}),{abort:function(){u=!0}}},getStorage:function(t){var A=t.key,a=(t.data,t.success),i=t.fail,n=t.complete;G.getItem(A+U,function(t){if("success"===t.result){var o=t.data;G.getItem(A,function(t){if("success"===t.result){var A=t.data;o&&A?("String"!==o&&(A=JSON.parse(A)),e(a)&&a({errMsg:"getStorage:ok",data:A})):(t.errMsg="setStorage:fail",e(i)&&i(t))}else t.errMsg="setStorage:fail",e(i)&&i(t);e(n)&&n(t)})}else t.errMsg="setStorage:fail",e(i)&&i(t),e(n)&&n(t)})},setStorage:function(t){var A=t.key,a=t.data,i=t.success,n=t.fail,o=t.complete,s="String";"object"===(void 0===a?"undefined":T(a))&&(s="Object",a=JSON.stringify(a)),G.setItem(A,a,function(t){"success"===t.result?G.setItem(A+U,s,function(t){"success"===t.result?e(i)&&i({errMsg:"setStorage:ok"}):(t.errMsg="setStorage:fail",e(n)&&n(t))}):(t.errMsg="setStorage:fail",e(n)&&n(t)),e(o)&&o(t)})},removeStorage:function(t){var A=t.key,a=(t.data,t.success),i=t.fail,n=t.complete;G.removeItem(A,function(t){"success"===t.result?e(a)&&a({errMsg:"removeStorage:ok"}):(t.errMsg="removeStorage:fail",e(i)&&i(t)),e(n)&&n(t)}),G.removeItem(A+U)},clearStorage:function(e){e.key,e.data,e.success,e.fail,e.complete},getClipboardData:function(t){var A=t.success,a=(t.fail,t.complete);R.getString(function(t){var i={errMsg:"getClipboardData:ok",data:t.data};e(A)&&A(i),e(a)&&a(i)})},setClipboardData:function(t){var A=t.data,a=t.success,i=(t.fail,t.complete),n={errMsg:"setClipboardData:ok"};R.setString(A),e(a)&&a(n),e(i)&&i(n)},onSubNVueMessage:r,getSubNVueById:u,getCurrentSubNVue:function(){return u(i.webview.currentWebview().id)},$on:function(){return F(V(),"$on",[].concat(Array.prototype.slice.call(arguments)))},$off:function(){return F(V(),"$off",[].concat(Array.prototype.slice.call(arguments)))},$once:function(){return F(V(),"$once",[].concat(Array.prototype.slice.call(arguments)))},$emit:function(){return F(V(),"$emit",[].concat(Array.prototype.slice.call(arguments)))}}),H={os:{nvue:!0}},Z={};return"undefined"!=typeof Proxy?Z=new Proxy({},{get:function(e,t){if("os"===t)return{nvue:!0};if("postMessage"===t)return m;if("requireNativePlugin"===t)return k;if("onNavigationBarButtonTap"===t)return C;if("onNavigationBarSearchInputChanged"===t)return L;if("onNavigationBarSearchInputConfirmed"===t)return I;if("onNavigationBarSearchInputClicked"===t)return E;var A=Y[t];return A||(A=b(t)),a(t)?n(A):A}}):(Object.keys(H).forEach(function(e){Z[e]=H[e]}),Z.postMessage=m,Z.requireNativePlugin=k,Z.onNavigationBarButtonTap=C,Z.onNavigationBarSearchInputChanged=L,Z.onNavigationBarSearchInputConfirmed=I,Z.onNavigationBarSearchInputClicked=E,Object.keys({uploadFile:!0,downloadFile:!0,chooseImage:!0,previewImage:!0,getImageInfo:!0,saveImageToPhotosAlbum:!0,chooseVideo:!0,saveVideoToPhotosAlbum:!0,saveFile:!0,getSavedFileList:!0,getSavedFileInfo:!0,removeSavedFile:!0,openDocument:!0,setStorage:!0,getStorage:!0,getStorageInfo:!0,removeStorage:!0,clearStorage:!0,getLocation:!0,chooseLocation:!0,openLocation:!0,getSystemInfo:!0,getNetworkType:!0,makePhoneCall:!0,scanCode:!0,setScreenBrightness:!0,getScreenBrightness:!0,setKeepScreenOn:!0,vibrateLong:!0,vibrateShort:!0,addPhoneContact:!0,showToast:!0,showLoading:!0,hideToast:!0,hideLoading:!0,showModal:!0,showActionSheet:!0,setNavigationBarTitle:!0,setNavigationBarColor:!0,navigateTo:!0,redirectTo:!0,reLaunch:!0,switchTab:!0,navigateBack:!0,getProvider:!0,login:!0,getUserInfo:!0,share:!0,requestPayment:!0,subscribePush:!0,unsubscribePush:!0,onPush:!0,offPush:!0}).forEach(function(e){var t=Y[e];t||(t=b(e)),a(e)?Z[e]=n(t):Z[e]=t})),Z};var i=new WeexPlus(weex);t.weexPlus=i;var n=a(weex,i,BroadcastChannel);t.default=n},function(e,t,A){Vue.prototype.__$appStyle__={},Vue.prototype.__merge_style&&Vue.prototype.__merge_style(A(4).default,Vue.prototype.__$appStyle__)},function(e,t,A){"use strict";A.r(t);var a=A(0),i=A.n(a);for(var n in a)"default"!==n&&function(e){A.d(t,e,function(){return a[e]})}(n);t.default=i.a},function(e,t,A){"use strict";(function(e){Object.defineProperty(t,"__esModule",{value:!0}),t.default=void 0;var A={onLoad:function(){var t=this,A=e.webview.currentWebview().extras||{},a=A.from,i=(A.callback,A.runtime),n=A.data,o=void 0===n?{}:n,s=A.useGlobalEvent;this.__from=a,this.__runtime=i,this.__page=e.webview.currentWebview().id,this.__useGlobalEvent=s,this.data=JSON.parse(JSON.stringify(o)),e.key.addEventListener("backbutton",function(){"function"==typeof t.onClose?t.onClose():e.webview.currentWebview().close("auto")});var r=this,c=function(e){var t=e.data&&e.data.__message;t&&r.__onMessageCallback&&r.__onMessageCallback(t.data)};this.__useGlobalEvent?weex.requireModule("globalEvent").addEventListener("plusMessage",c):new BroadcastChannel(this.__page).onmessage=c},methods:{postMessage:function(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},A=arguments.length>1&&void 0!==arguments[1]&&arguments[1],a={__message:{__page:this.__page,data:t,keep:A}},i=this.__from;if("v8"===this.__runtime){if(this.__useGlobalEvent)e.webview.postMessageToUniNView(a,i);else new BroadcastChannel(i).postMessage(a)}else{var n=e.webview.getWebviewById(i);n&&n.evalJS("__plusMessage&&__plusMessage(".concat(JSON.stringify({data:a}),")"))}},onMessage:function(e){this.__onMessageCallback=e}}};t.default=A}).call(this,A(2).weexPlus)},function(e,t,A){"use strict";var a=A(29),i=A(11),n=A(1);var o=Object(n.a)(i.default,a.a,a.b,!1,null,null,"8d0eedfe");(function(){this.options.style||(this.options.style={}),Vue.prototype.__merge_style&&Vue.prototype.__$appStyle__&&Vue.prototype.__merge_style(Vue.prototype.__$appStyle__,this.options.style),Vue.prototype.__merge_style?Vue.prototype.__merge_style(A(35).default,this.options.style):Object.assign(this.options.style,A(35).default)}).call(o),t.default=o.exports},,,,,function(e,t,A){"use strict";var a=A(12),i=A.n(a);t.default=i.a},function(e,t,A){"use strict";(function(e,a){Object.defineProperty(t,"__esModule",{value:!0}),t.default=void 0;var i,n=(i=A(5))&&i.__esModule?i:{default:i};weex.requireModule("dom").addRule("fontFace",{fontFamily:"unichooselocation",src:"url('data:font/truetype;charset=utf-8;base64,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aG9vc2Vsb2NhdGlvbkdlbmVyYXRlZCBieSBzdmcydHRmIGZyb20gRm9udGVsbG8gcHJvamVjdC5odHRwOi8vZm9udGVsbG8uY29tAAoAQwByAGUAYQB0AGUAZAAgAGIAeQAgAGkAYwBvAG4AZgBvAG4AdAAKAHUAbgBpAGMAaABvAG8AcwBlAGwAbwBjAGEAdABpAG8AbgBSAGUAZwB1AGwAYQByAHUAbgBpAGMAaABvAG8AcwBlAGwAbwBjAGEAdABpAG8AbgB1AG4AaQBjAGgAbwBvAHMAZQBsAG8AYwBhAHQAaQBvAG4AVgBlAHIAcwBpAG8AbgAgADEALgAwAHUAbgBpAGMAaABvAG8AcwBlAGwAbwBjAGEAdABpAG8AbgBHAGUAbgBlAHIAYQB0AGUAZAAgAGIAeQAgAHMAdgBnADIAdAB0AGYAIABmAHIAbwBtACAARgBvAG4AdABlAGwAbABvACAAcAByAG8AagBlAGMAdAAuAGgAdAB0AHAAOgAvAC8AZgBvAG4AdABlAGwAbABvAC4AYwBvAG0AAAAAAgAAAAAAAAAKAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAFAQIBAwEEAQUBBgAKbXlsb2NhdGlvbgZ4dWFuemUFY2xvc2UGc291c3VvAAAAAA==')"});var o={en:{ok:"OK",cancel:"Cancel",search_tips:"Search for a place",no_found:"No results found"},cn:{ok:"完成",cancel:"取消",search_tips:"搜索地点",no_found:"对不起,没有搜索到相关数据"}},s=weex.requireModule("mapSearch"),r={mixins:[n.default],data:function(){return{resource:{},userKeyword:"",showLocation:!0,latitude:39.908692,longitude:116.397477,nearList:[],nearSelectedIndex:-1,nearLoading:!1,nearLoadingEnd:!1,noNearData:!1,isUserLocation:!1,statusBarHeight:20,mapHeight:250,markers:[{id:"location",latitude:39.908692,longitude:116.397477,zIndex:"1",iconPath:"data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAADQAAABICAMAAACORiZjAAAByFBMVEUAAAD/PyL/PyL/PyL/PyL/PyL/PyL/PyL/PyL/PiL/PyL/PyL/PyP/PyL/PyL/PyL/PyL/PiL/PyL8PiP/PyL4OyP/PyL3OyX9Pyb0RUP0RkPzOiXsPj3YLi7TKSnQJiX0RkTgMCj0QjvkNC3vPDPwOy/9PyXsNSTyRUTgNDPdMjHrPTzuQD7iNTTxQ0HTJyTZKyf1RULlNjDZKyTfLSLeLSX0Qzz3Qzv8PSTMJCTmOjnPJSXLIiLzRkXWLCvgNDPZLyzVKijRJSTtPzvcMS7jNjPZLCnyREHpOzjiNDDtPzvzQz/VKSXkNTDsPDXyQjz2RT7pMyTxOinjMST5QjTmOjnPJSLdLyr0RD//YF7/////R0b/Tk3/XVv/WFb/VVP/S0v/Pz//W1n/UVD/REP/Xlz/Ojr/QUH/Skn/U1L/ODf7VlX5UU/oOzrqNzf/+/v5UlHvQUD2TEv0SUj3Tk3/2dn8W1r6TEv7R0b7REPvPTzzPDvwNjXkMjLnMDDjLS3dKir/xcX/vr7/qqn/pqX/mZn/fn7/ZWT/8PD/4eH/3t3/zs7/ra3/kpL/iIj/e3r5PDz4NjbxMTHsMTDlLCz/9vb/6ej/ubjhOGVRAAAAWXRSTlMABQ4TFgoIHhApI0RAGhgzJi89Ozg2LVEg4s5c/v366tmZiYl2X0pE/vn08eTe1sWvqqiOgXVlUE399/b08u3n4tzZ1dTKyMTDvLmzqqKal35taFxH6sC3oms+ongAAAOtSURBVEjHjZV3W9pQGMXJzQACQRARxVF3HdVW26od7q111NqhdbRSbQVElnvvbV1tv25Jgpr3kpCcP+/7/J5z8p57QScr4l46jSJohEhKEGlANKGBYBA1NFDpyklPz3FV5tWwHKnGEbShprIuFPAujEW14A2E6nqqWYshEcYYqnNC3mEgbyh9wMgZGCUbZHZFFobjtODLKWQpRMgyhrxiiQtwK/6SqpczY/QdvqlhJflcZpZk4hiryzecQIH0IitFY0xaBWDkqCEr9CLIDsDIJqywswbpNlB/ZEpVkZ4kPZKEqwmOTakrXGCk6IdwFYExDfI+SX4ISBeExjQp0m/jUMyIeuLVBo2Xma0kIRpVhyc1Kpxn42hxdd2BuOnv3Z2d3YO4Y29LCitcQiItcxxH5kcEncRhmc5UiofowuJxqPO5kZjm9rFROC9JWAXqC8HBgciI1AWcRbqj+fgX0emDg+MRif5OglmgJdlIEvzCJ8D5xQjQORhOlJlTKR4qmwD6B6FtOJ012yyMjrHMwuNTCM1jUG2SHDQPoWMMciZxdBR6PQOOtyF0ikEmEfrom5FqH0J7YOh+LUAE1bbolmrqj5SZOwTDxXJTdBFRqCrsBtoHRnAW7hRXThYE3VA7koVjo2CfUK4O2WdHodx7c7FsZ25sNDtotxp4SF++OIrpcHf+6Ojk7BA/X2wwOfRIeLj5wVGNClYJF4K/sY4SrVBJhj323hHXG/ymScEu091PH0HaS5e0MEslGeLuBCt9fqYWKLNXNIpZGcuXfqlqqaHWLhrFrLpWvqpqpU1ixFs9Ll1WY5ZLo19ECUb3X+VXg/y5wEj4qtYVlXCtRdIvErtyZi0nDJc1aLZxCPtrZ3P9PxLIX2Vy8P8zQAxla1xVZlYba6NbYAAi7KIwSxnKKjDHtoAHfOb/qSD/Z1OKEA4XbXHUr8ozq/XOZKOFxgkx4Mv177Jaz4fhQFnWdr8c4283pVhBRSDg4+zLeOYyu9CcCsIBK5T2fF0mXK7JkYaAEaAoY9Mazqw1FdnBRcWFuA/ZGDOd/R7eH7my3m1MA208k60I3ibHozUps/bICe+PQllbUmjrBaxIqaynG5JwT5UrgmW9ubpjrt5kJMOKlMvavIM2o08cVqRcVvONyNw0Y088YVmvPIJeqVUEy9rkmU31imBZ1x7PNV6RelkeD16Relmfbm81VQTLevs2A74iDWXpXzznwwEj9YCszcbCcOqiSY4jYTh1Jx1B04o+/wH6/wOSPFj1xgAAAABJRU5ErkJggg==",width:26,height:36}],showSearch:!1,searchList:[],searchSelectedIndex:-1,searchLoading:!1,searchEnd:!1,noSearchData:!1}},computed:{disableOK:function(){return this.nearSelectedIndex<0&&this.searchSelectedIndex<0}},onLoad:function(){this.resource=e.os.language.toLowerCase().indexOf("zh")>=0?o.cn:o.en,this.statusBarHeight=e.navigator.getStatusbarHeight(),this.mapHeight=e.screen.resolutionHeight/2;var t=this.data;this.userKeyword=t.keyword||"",this._searchInputTimer=null,this._searchPageIndex=1,this._searchKeyword="",this._nearPageIndex=1,this._hasUserLocation=!1,this._userLatitude=0,this._userLongitude=0},onReady:function(){this.mapContext=this.$refs.map1,this.data.latitude&&this.data.longitude?(this._hasUserLocation=!0,this.moveToCenter({latitude:this.data.latitude,longitude:this.data.longitude})):this.getUserLocation()},onUnload:function(){this.clearSearchTimer()},methods:{cancelClick:function(){this.postMessage({event:"cancel"})},doneClick:function(){if(!this.disableOK){var e=this.showSearch&&this.searchSelectedIndex>=0?this.searchList[this.searchSelectedIndex]:this.nearList[this.nearSelectedIndex],t={name:e.name,address:e.address,latitude:e.location.latitude,longitude:e.location.longitude};this.postMessage({event:"selected",detail:t})}},getUserLocation:function(){var t=this;e.geolocation.getCurrentPosition(function(e){var A=e.coordsType,a=e.coords;"wgs84"===A.toLowerCase()?t.wgs84togcjo2(a,function(e){t.getUserLocationSuccess(e)}):t.getUserLocationSuccess(a)},function(e){t._hasUserLocation=!0,console.log(a("Gelocation Error: code - "+e.code+"; message - "+e.message," at template\\__uniappchooselocation.nvue:235"))},{geocode:!1})},getUserLocationSuccess:function(e){this._userLatitude=e.latitude,this._userLongitude=e.longitude,this._hasUserLocation=!0,this.moveToCenter({latitude:e.latitude,longitude:e.longitude})},searchclick:function(t){this.showSearch=t,!1===t&&e.key.hideSoftKeybord()},showSearchView:function(){this.searchList=[],this.showSearch=!0},hideSearchView:function(){this.showSearch=!1,e.key.hideSoftKeybord(),this.noSearchData=!1,this.searchSelectedIndex=-1},onregionchange:function(e){var t=this,A=e.detail,a=A.type||e.type;"drag"===(A.causedBy||e.causedBy)&&"end"===a&&this.mapContext.getCenterLocation(function(e){t.moveToCenter({latitude:e.latitude,longitude:e.longitude})})},onItemClick:function(e,t){t.stopPropagation(),this.nearSelectedIndex!==e&&(this.nearSelectedIndex=e),this.updateMarker(this.nearList[e].location)},moveToCenter:function(e){this.latitude===e.latitude&&this.longitude===e.longitude||(this.latitude=e.latitude,this.longitude=e.longitude,this.updateCenter(e),this.isUserLocation=this._userLatitude===e.latitude&&this._userLongitude===e.longitude)},updateCenter:function(e){this.nearSelectedIndex=-1,this.nearList=[],this.updateMarker(e),this._hasUserLocation&&(this._nearPageIndex=1,this.nearLoadingEnd=!1,this.reverseGeocode(e),this.searchNearByPoint(e))},searchNear:function(){this.nearLoadingEnd||this.searchNearByPoint({latitude:this.latitude,longitude:this.longitude})},searchNearByPoint:function(e){var t=this;this.noNearData=!1,this.nearLoading=!0,s.poiSearchNearBy({point:{latitude:e.latitude,longitude:e.longitude},key:this.userKeyword,index:this._nearPageIndex,radius:1e3},function(e){t.nearLoading=!1,t._nearPageIndex=e.pageIndex+1,t.nearLoadingEnd=e.pageIndex===e.pageNumber,e.poiList&&e.poiList.length?(t.replaceEscape(e.poiList),t.nearList=t.nearList.concat(e.poiList)):t.noNearData=0===t.nearList.length})},updateMarker:function(e){this.mapContext.translateMarker({markerId:"location",destination:{latitude:e.latitude,longitude:e.longitude},duration:0},function(e){})},reverseGeocode:function(e){var t=this;s.reverseGeocode({point:e},function(A){"success"===A.type&&t._nearPageIndex<=2&&t.nearList.splice(0,0,{code:A.code,location:e,name:"地图位置",address:A.address||""})})},onsearchinput:function(e){var t=this,A=e.detail.value.replace(/^\s+|\s+$/g,"");this.clearSearchTimer(),this._searchInputTimer=setTimeout(function(){clearTimeout(t._searchInputTimer),t._searchPageIndex=1,t.searchEnd=!1,t._searchKeyword=A,t.searchList=[],t.search()},300)},clearSearchTimer:function(){this._searchInputTimer&&clearTimeout(this._searchInputTimer)},search:function(){var e=this;0===this._searchKeyword.length||this._searchEnd||this.searchLoading||(this.searchLoading=!0,this.noSearchData=!1,s.poiSearchNearBy({point:{latitude:this.latitude,longitude:this.longitude},key:this._searchKeyword,index:this._searchPageIndex,radius:5e4},function(t){e.searchLoading=!1,e._searchPageIndex=t.pageIndex+1,e.searchEnd=t.pageIndex===t.pageNumber,t.poiList&&t.poiList.length?(e.replaceEscape(t.poiList),e.searchList=e.searchList.concat(t.poiList)):e.noSearchData=0===e.searchList.length}))},onSearchListTouchStart:function(){e.key.hideSoftKeybord()},onSearchItemClick:function(e,t){t.stopPropagation(),this.searchSelectedIndex!==e&&(this.searchSelectedIndex=e)},replaceEscape:function(e){for(var t=0;t1){var n=a.pop();i=a.join("---COMMA---"),0===n.indexOf(" at ")?i+=n:i+="---COMMA---"+n}else i=a[0];return i}},function(e,t,A){"use strict";var a=function(){var e=this,t=e.$createElement,A=e._self._c||t;return A("scroll-view",{staticStyle:{flexDirection:"column"},attrs:{scrollY:!0,enableBackToTop:!0,bubble:"true"}},[A("view",{staticClass:["page","flex-c"]},[A("view",{staticClass:["flex-r","map-view"]},[A("map",{ref:"map1",staticClass:["map","flex-fill"],style:"height:"+e.mapHeight+"px",attrs:{showLocation:e.showLocation,longitude:e.longitude,latitude:e.latitude,markers:e.markers},on:{regionchange:e.onregionchange}}),A("view",{staticClass:["map-location","flex-c","a-i-c","j-c-c"],on:{click:function(t){e.getUserLocation()}}},[A("u-text",{staticClass:["unichooselocation-icons","map-location-text"],class:{"map-location-text-active":e.isUserLocation}},[e._v("")])]),A("view",{staticClass:["nav-cover"]},[A("view",{staticClass:["statusbar"],style:"height:"+e.statusBarHeight+"px"}),A("view",{staticClass:["title-view","flex-r"]},[A("view",{staticClass:["btn-cancel"],on:{click:e.cancelClick}},[A("u-text",{staticClass:["unichooselocation-icons","btn-cancel-text"]},[e._v("")])]),A("view",{staticClass:["flex-fill"]}),A("view",{staticClass:["btn-done","flex-r","a-i-c","j-c-c"],class:{"btn-done-disabled":e.disableOK},on:{click:e.doneClick}},[A("u-text",{staticClass:["text-done"],class:{"text-done-disabled":e.disableOK}},[e._v(e._s(e.resource.ok))])])])])],1),A("view",{staticClass:["flex-c","result-area"],class:{"searching-area":e.showSearch}},[A("view",{staticClass:["search-bar"]},[A("view",{staticClass:["search-area","flex-r","a-i-c"],on:{click:e.showSearchView}},[A("u-text",{staticClass:["search-icon","unichooselocation-icons"]},[e._v("")]),A("u-text",{staticClass:["search-text"]},[e._v(e._s(e.resource.search_tips))])])]),e.noNearData?e._e():A("list",{staticClass:["flex-fill","list-view"],attrs:{loadmoreoffset:"5",scrollY:!0},on:{loadmore:function(t){e.searchNear()}}},[e._l(e.nearList,function(t,a){return A("cell",{key:t.uid,appendAsTree:!0,attrs:{append:"tree"}},[A("view",{staticClass:["list-item"],on:{click:function(t){e.onItemClick(a,t)}}},[A("view",{staticClass:["flex-r"]},[A("view",{staticClass:["list-text-area","flex-fill","flex-c"]},[A("u-text",{staticClass:["list-name"]},[e._v(e._s(t.name))]),t.distance?A("u-text",{staticClass:["list-address"]},[e._v(e._s(t.distance<100?"100m 内":t.distance+"m")+" | "+e._s(t.address))]):e._e(),t.distance?e._e():A("u-text",{staticClass:["list-address"]},[e._v(e._s(t.address))])]),a===e.nearSelectedIndex?A("view",{staticClass:["list-icon-area","flex-r","a-i-c","j-c-c"]},[A("u-text",{staticClass:["unichooselocation-icons","list-selected-icon"]},[e._v("")])]):e._e()]),A("view",{staticClass:["list-line"]})])])}),e.nearLoading?A("cell",{appendAsTree:!0,attrs:{append:"tree"}},[A("view",{staticClass:["loading-view","flex-c","a-i-c","j-c-c"]},[A("loading-indicator",{staticClass:["loading-icon"],attrs:{animating:!0,arrow:"false"}})])]):e._e()],2),e.noNearData?A("view",{staticClass:["flex-fill","flex-r","a-i-c","j-c-c"]},[A("u-text",{staticClass:["no-data"]},[e._v(e._s(e.resource.no_found))])]):e._e(),e.showSearch?A("view",{staticClass:["search-view","flex-c"]},[A("view",{staticClass:["search-bar","flex-r","a-i-c"]},[A("view",{staticClass:["search-area","flex-fill","flex-r"]},[A("u-input",{staticClass:["search-input","flex-fill"],attrs:{focus:!0,placeholder:e.resource.search_tips},on:{input:e.onsearchinput}})],1),A("u-text",{staticClass:["search-cancel"],on:{click:e.hideSearchView}},[e._v(e._s(e.resource.cancel))])]),e.noSearchData?e._e():A("list",{staticClass:["flex-fill","list-view"],attrs:{enableBackToTop:!0,scrollY:!0},on:{loadmore:function(t){e.search()},touchstart:e.onSearchListTouchStart}},[e._l(e.searchList,function(t,a){return A("cell",{key:t.uid,appendAsTree:!0,attrs:{append:"tree"}},[A("view",{staticClass:["list-item"],on:{click:function(t){e.onSearchItemClick(a,t)}}},[A("view",{staticClass:["flex-r"]},[A("view",{staticClass:["list-text-area","flex-fill","flex-c"]},[A("u-text",{staticClass:["list-name"]},[e._v(e._s(t.name))]),t.distance?A("u-text",{staticClass:["list-address"]},[e._v(e._s(t.distance<100?"100m 内":t.distance+"m")+" | "+e._s(t.address))]):e._e(),t.distance?e._e():A("u-text",{staticClass:["list-address"]},[e._v(e._s(t.address))])]),a===e.searchSelectedIndex?A("view",{staticClass:["list-icon-area","flex-r","a-i-c","j-c-c"]},[A("u-text",{staticClass:["unichooselocation-icons","list-selected-icon"]},[e._v("")])]):e._e()]),A("view",{staticClass:["list-line"]})])])}),e.searchLoading?A("cell",{appendAsTree:!0,attrs:{append:"tree"}},[A("view",{staticClass:["loading-view","flex-c","a-i-c","j-c-c"]},[A("loading-indicator",{staticClass:["loading-icon"],attrs:{animating:!0}})])]):e._e()],2),e.noSearchData?A("view",{staticClass:["flex-fill","flex-r","j-c-c"]},[A("u-text",{staticClass:["no-data","no-data-search"]},[e._v(e._s(e.resource.no_found))])]):e._e()]):e._e()])])])},i=[];A.d(t,"a",function(){return a}),A.d(t,"b",function(){return i})},,,,,,function(e,t,A){"use strict";A.r(t);var a=A(13),i=A.n(a);for(var n in a)"default"!==n&&function(e){A.d(t,e,function(){return a[e]})}(n);t.default=i.a},,,,,function(e,t,A){"use strict";A.r(t);A(3);var a=A(6);a.default.mpType="page",a.default.route="template/__uniappchooselocation",a.default.el="#root",new Vue(a.default)}]); \ No newline at end of file diff --git a/packages/uni-app-plus/template/common/__uniappopenlocation.js b/packages/uni-app-plus/template/common/__uniappopenlocation.js new file mode 100644 index 000000000..280cd1d9f --- /dev/null +++ b/packages/uni-app-plus/template/common/__uniappopenlocation.js @@ -0,0 +1 @@ +!function(e){var t={};function n(a){if(t[a])return t[a].exports;var o=t[a]={i:a,l:!1,exports:{}};return e[a].call(o.exports,o,o.exports,n),o.l=!0,o.exports}n.m=e,n.c=t,n.d=function(e,t,a){n.o(e,t)||Object.defineProperty(e,t,{enumerable:!0,get:a})},n.r=function(e){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})},n.t=function(e,t){if(1&t&&(e=n(e)),8&t)return e;if(4&t&&"object"==typeof e&&e&&e.__esModule)return e;var a=Object.create(null);if(n.r(a),Object.defineProperty(a,"default",{enumerable:!0,value:e}),2&t&&"string"!=typeof e)for(var o in e)n.d(a,o,function(t){return e[t]}.bind(null,o));return a},n.n=function(e){var t=e&&e.__esModule?function(){return e.default}:function(){return e};return n.d(t,"a",t),t},n.o=function(e,t){return Object.prototype.hasOwnProperty.call(e,t)},n.p="",n(n.s=41)}([function(e,t){e.exports={}},function(e,t,n){"use strict";function a(e,t,n,a,o,i,r,s){var u,c="function"==typeof e?e.options:e;if(t&&(c.render=t,c.staticRenderFns=n,c._compiled=!0),a&&(c.functional=!0),i&&(c._scopeId="data-v-"+i),r?(u=function(e){(e=e||this.$vnode&&this.$vnode.ssrContext||this.parent&&this.parent.$vnode&&this.parent.$vnode.ssrContext)||"undefined"==typeof __VUE_SSR_CONTEXT__||(e=__VUE_SSR_CONTEXT__),o&&o.call(this,e),e&&e._registeredComponents&&e._registeredComponents.add(r)},c._ssrRegister=u):o&&(u=s?function(){o.call(this,this.$root.$options.shadowRoot)}:o),u)if(c.functional){c._injectStyles=u;var l=c.render;c.render=function(e,t){return u.call(t),l(e,t)}}else{var f=c.beforeCreate;c.beforeCreate=f?[].concat(f,u):[u]}return{exports:e,options:c}}n.d(t,"a",function(){return a})},function(e,t,n){"use strict";var a;Object.defineProperty(t,"__esModule",{value:!0}),t.weexPlus=t.default=void 0,a="function"==typeof getUni?getUni:function(){var e=function(e){return"function"==typeof e},t=/^\$|^on|^create|Sync$|Manager$|^pause/,n=["os","getCurrentSubNVue","getSubNVueById","stopRecord","stopVoice","stopBackgroundAudio","stopPullDownRefresh","hideKeyboard","hideToast","hideLoading","showNavigationBarLoading","hideNavigationBarLoading","canIUse","navigateBack","closeSocket","pageScrollTo","drawCanvas"],a=function(e){return!(t.test(e)&&"createBLEConnection"!==e||~n.indexOf(e))},i=function(t){return function(){for(var n=arguments.length,a=Array(n>1?n-1:0),o=1;o0&&void 0!==arguments[0]?arguments[0]:{};return e(i.success)||e(i.fail)||e(i.complete)?t.apply(void 0,[i].concat(a)):new Promise(function(e,n){t.apply(void 0,[Object.assign({},i,{success:e,fail:n})].concat(a)),Promise.prototype.finally=function(e){var t=this.constructor;return this.then(function(n){return t.resolve(e()).then(function(){return n})},function(n){return t.resolve(e()).then(function(){throw n})})}}).then(function(e){return[null,e]}).catch(function(e){return[e]})}},r=[],s=void 0;function u(e){r.forEach(function(t){return t({origin:s,data:e})})}var c=o.webview.currentWebview().id,l=new BroadcastChannel("UNI-APP-SUBNVUE");function f(e){e.$processed=!0;var t=o.webview.currentWebview().id===e.id,n="uniNView"===e.__uniapp_origin_type&&e.__uniapp_origin_id,a=e.id;if(e.postMessage=function(e){n?l.postMessage({data:e,to:t?n:a}):b({type:"UniAppSubNVue",data:e})},e.onMessage=function(e){r.push(e)},e.__uniapp_mask_id){s=e.__uniapp_host;var i=e.__uniapp_mask,u=o.webview.getWebviewById(e.__uniapp_mask_id);u=u.parent()||u;var c=e.show,f=e.hide,d=e.close,p=function(){u.setStyle({mask:"none"})};e.show=function(){u.setStyle({mask:i});for(var t=arguments.length,n=Array(t),a=0;a1&&void 0!==arguments[1]?arguments[1]:N,n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:"application/x-www-form-urlencoded";return"object"===(void 0===e?"undefined":L(e))?"POST"===t.toUpperCase()&&"application/json"===n.toLowerCase()?JSON.stringify(e):Object.keys(e).map(function(t){return encodeURIComponent(t)+"="+encodeURIComponent(e[t])}).join("&"):e},V=weex.requireModule("plusstorage"),q="__TYPE",z=weex.requireModule("clipboard"),F=function(){if("function"==typeof getUniEmitter)return getUniEmitter;var e={$on:function(){console.warn("uni.$on failed")},$off:function(){console.warn("uni.$off failed")},$once:function(){console.warn("uni.$once failed")},$emit:function(){console.warn("uni.$emit failed")}};return function(){return e}}();function D(e,t,n){return e[t].apply(e,n)}var X=Object.freeze({loadFontFace:function(t){var n=t.family,a=t.source,o=(t.desc,t.success),i=(t.fail,t.complete);O.addRule("fontFace",{fontFamily:n,src:a.replace(/"/g,"'")});var r={errMsg:"loadFontFace:ok",status:"loaded"};e(o)&&o(r),e(i)&&i(r)},ready:T,request:function(t){var n=t.url,a=t.data,o=t.header,i=t.method,r=void 0===i?"GET":i,s=t.dataType,u=void 0===s?"json":s,c=(t.responseType,t.success),l=t.fail,f=t.complete,d=!1,p=!1,v={};if(o)for(var g in o)p||"content-type"!==g.toLowerCase()?v[g]=o[g]:(p=!0,v["Content-Type"]=o[g]);return r===N&&a&&(n=n+(~n.indexOf("?")?"&"===n.substr(-1)||"?"===n.substr(-1)?"":"&":"?")+R(a)),U.fetch({url:n,method:r,headers:v,type:"json"===u?"json":"text",body:r!==N?R(a,r,v["Content-Type"]):""},function(t){var n=t.status,a=(t.ok,t.statusText,t.data),o=t.headers,i={};!n||-1===n||d?(i.errMsg="request:fail",e(l)&&l(i)):(i.data=a,i.statusCode=n,i.header=o,e(c)&&c(i)),e(f)&&f(i)}),{abort:function(){d=!0}}},getStorage:function(t){var n=t.key,a=(t.data,t.success),o=t.fail,i=t.complete;V.getItem(n+q,function(t){if("success"===t.result){var r=t.data;V.getItem(n,function(t){if("success"===t.result){var n=t.data;r&&n?("String"!==r&&(n=JSON.parse(n)),e(a)&&a({errMsg:"getStorage:ok",data:n})):(t.errMsg="setStorage:fail",e(o)&&o(t))}else t.errMsg="setStorage:fail",e(o)&&o(t);e(i)&&i(t)})}else t.errMsg="setStorage:fail",e(o)&&o(t),e(i)&&i(t)})},setStorage:function(t){var n=t.key,a=t.data,o=t.success,i=t.fail,r=t.complete,s="String";"object"===(void 0===a?"undefined":L(a))&&(s="Object",a=JSON.stringify(a)),V.setItem(n,a,function(t){"success"===t.result?V.setItem(n+q,s,function(t){"success"===t.result?e(o)&&o({errMsg:"setStorage:ok"}):(t.errMsg="setStorage:fail",e(i)&&i(t))}):(t.errMsg="setStorage:fail",e(i)&&i(t)),e(r)&&r(t)})},removeStorage:function(t){var n=t.key,a=(t.data,t.success),o=t.fail,i=t.complete;V.removeItem(n,function(t){"success"===t.result?e(a)&&a({errMsg:"removeStorage:ok"}):(t.errMsg="removeStorage:fail",e(o)&&o(t)),e(i)&&i(t)}),V.removeItem(n+q)},clearStorage:function(e){e.key,e.data,e.success,e.fail,e.complete},getClipboardData:function(t){var n=t.success,a=(t.fail,t.complete);z.getString(function(t){var o={errMsg:"getClipboardData:ok",data:t.data};e(n)&&n(o),e(a)&&a(o)})},setClipboardData:function(t){var n=t.data,a=t.success,o=(t.fail,t.complete),i={errMsg:"setClipboardData:ok"};z.setString(n),e(a)&&a(i),e(o)&&o(i)},onSubNVueMessage:u,getSubNVueById:d,getCurrentSubNVue:function(){return d(o.webview.currentWebview().id)},$on:function(){return D(F(),"$on",[].concat(Array.prototype.slice.call(arguments)))},$off:function(){return D(F(),"$off",[].concat(Array.prototype.slice.call(arguments)))},$once:function(){return D(F(),"$once",[].concat(Array.prototype.slice.call(arguments)))},$emit:function(){return D(F(),"$emit",[].concat(Array.prototype.slice.call(arguments)))}}),H={os:{nvue:!0}},Y={};return"undefined"!=typeof Proxy?Y=new Proxy({},{get:function(e,t){if("os"===t)return{nvue:!0};if("postMessage"===t)return b;if("requireNativePlugin"===t)return B;if("onNavigationBarButtonTap"===t)return _;if("onNavigationBarSearchInputChanged"===t)return M;if("onNavigationBarSearchInputConfirmed"===t)return I;if("onNavigationBarSearchInputClicked"===t)return k;var n=X[t];return n||(n=P(t)),a(t)?i(n):n}}):(Object.keys(H).forEach(function(e){Y[e]=H[e]}),Y.postMessage=b,Y.requireNativePlugin=B,Y.onNavigationBarButtonTap=_,Y.onNavigationBarSearchInputChanged=M,Y.onNavigationBarSearchInputConfirmed=I,Y.onNavigationBarSearchInputClicked=k,Object.keys({uploadFile:!0,downloadFile:!0,chooseImage:!0,previewImage:!0,getImageInfo:!0,saveImageToPhotosAlbum:!0,chooseVideo:!0,saveVideoToPhotosAlbum:!0,saveFile:!0,getSavedFileList:!0,getSavedFileInfo:!0,removeSavedFile:!0,openDocument:!0,setStorage:!0,getStorage:!0,getStorageInfo:!0,removeStorage:!0,clearStorage:!0,getLocation:!0,chooseLocation:!0,openLocation:!0,getSystemInfo:!0,getNetworkType:!0,makePhoneCall:!0,scanCode:!0,setScreenBrightness:!0,getScreenBrightness:!0,setKeepScreenOn:!0,vibrateLong:!0,vibrateShort:!0,addPhoneContact:!0,showToast:!0,showLoading:!0,hideToast:!0,hideLoading:!0,showModal:!0,showActionSheet:!0,setNavigationBarTitle:!0,setNavigationBarColor:!0,navigateTo:!0,redirectTo:!0,reLaunch:!0,switchTab:!0,navigateBack:!0,getProvider:!0,login:!0,getUserInfo:!0,share:!0,requestPayment:!0,subscribePush:!0,unsubscribePush:!0,onPush:!0,offPush:!0}).forEach(function(e){var t=X[e];t||(t=P(e)),a(e)?Y[e]=i(t):Y[e]=t})),Y};var o=new WeexPlus(weex);t.weexPlus=o;var i=a(weex,o,BroadcastChannel);t.default=i},function(e,t,n){Vue.prototype.__$appStyle__={},Vue.prototype.__merge_style&&Vue.prototype.__merge_style(n(4).default,Vue.prototype.__$appStyle__)},function(e,t,n){"use strict";n.r(t);var a=n(0),o=n.n(a);for(var i in a)"default"!==i&&function(e){n.d(t,e,function(){return a[e]})}(i);t.default=o.a},function(e,t,n){"use strict";(function(e){Object.defineProperty(t,"__esModule",{value:!0}),t.default=void 0;var n={onLoad:function(){var t=this,n=e.webview.currentWebview().extras||{},a=n.from,o=(n.callback,n.runtime),i=n.data,r=void 0===i?{}:i,s=n.useGlobalEvent;this.__from=a,this.__runtime=o,this.__page=e.webview.currentWebview().id,this.__useGlobalEvent=s,this.data=JSON.parse(JSON.stringify(r)),e.key.addEventListener("backbutton",function(){"function"==typeof t.onClose?t.onClose():e.webview.currentWebview().close("auto")});var u=this,c=function(e){var t=e.data&&e.data.__message;t&&u.__onMessageCallback&&u.__onMessageCallback(t.data)};this.__useGlobalEvent?weex.requireModule("globalEvent").addEventListener("plusMessage",c):new BroadcastChannel(this.__page).onmessage=c},methods:{postMessage:function(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},n=arguments.length>1&&void 0!==arguments[1]&&arguments[1],a={__message:{__page:this.__page,data:t,keep:n}},o=this.__from;if("v8"===this.__runtime){if(this.__useGlobalEvent)e.webview.postMessageToUniNView(a,o);else new BroadcastChannel(o).postMessage(a)}else{var i=e.webview.getWebviewById(o);i&&i.evalJS("__plusMessage&&__plusMessage(".concat(JSON.stringify({data:a}),")"))}},onMessage:function(e){this.__onMessageCallback=e}}};t.default=n}).call(this,n(2).weexPlus)},,function(e,t,n){"use strict";var a=n(30),o=n(14),i=n(1);var r=Object(i.a)(o.default,a.a,a.b,!1,null,null,"53d1e1f6");(function(){this.options.style||(this.options.style={}),Vue.prototype.__merge_style&&Vue.prototype.__$appStyle__&&Vue.prototype.__merge_style(Vue.prototype.__$appStyle__,this.options.style),Vue.prototype.__merge_style?Vue.prototype.__merge_style(n(36).default,this.options.style):Object.assign(this.options.style,n(36).default)}).call(r),t.default=r.exports},,,,,,,function(e,t,n){"use strict";var a=n(15),o=n.n(a);t.default=o.a},function(e,t,n){"use strict";(function(e){Object.defineProperty(t,"__esModule",{value:!0}),t.default=void 0;var a,o=(a=n(5))&&a.__esModule?a:{default:a};weex.requireModule("mapSearch");var i={mixins:[o.default],data:function(){return{longitude:"",latitude:"",markers:[{id:"location",latitude:39.908692,longitude:116.397477,title:"天安门",zIndex:"1",iconPath:"data:image/png;base64,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",width:26,height:36}],name:"",address:""}},onLoad:function(){var e=this.data;this.latitude=e.latitude||39.908692,this.longitude=e.longitude||116.397477,this.name=e.name||"",this.address=e.address||""},onReady:function(){this.mapContext=this.$refs.map1,this.updateMarker()},methods:{goto:function(){var t="iOS"===weex.config.env.platform;!function(t,n,a,o){var i=[{title:"腾讯地图网页版",getUrl:function(){return"https://apis.map.qq.com/uri/v1/routeplan?type=drive&to="+encodeURIComponent(a)+"&tocoord="+encodeURIComponent(t+","+n)+"&referer=APP"}}],r=[];[{title:"高德地图",pname:"com.autonavi.minimap",action:o?"iosamap://":"amapuri://",getUrl:function(){var e;return e=o?"iosamap://path":"amapuri://route/plan/",e+="?sourceApplication=APP&dname="+encodeURIComponent(a)+"&dlat="+t+"&dlon="+n+"&dev=0"}},{title:"百度地图",pname:"com.baidu.BaiduMap",action:"baidumap://",getUrl:function(){return"baidumap://map/direction?destination="+encodeURIComponent("latlng:"+t+","+n+"|name:"+a)+"&mode=driving&src=APP&coord_type=gcj02"}},{title:"腾讯地图",pname:"com.tencent.map",action:"qqmap://",getUrl:function(){return"qqmap://map/routeplan?type=drive"+(o?"&from="+encodeURIComponent("我的位置"):"")+"&to="+encodeURIComponent(a)+"&tocoord="+encodeURIComponent(t+","+n)+"&referer=APP"}}].forEach(function(t){e.runtime.isApplicationExist({pname:t.pname,action:t.action})&&r.push(t)}),o&&r.unshift({title:"Apple 地图",getUrl:function(){return"https://maps.apple.com/?daddr="+encodeURIComponent(a)+"&sll="+encodeURIComponent(t+","+n)}}),0===r.length&&(r=r.concat(i)),e.nativeUI.actionSheet({title:"导航方式",cancel:"取消",buttons:r},function(t){var n,a=t.index;a>0&&(n=r[a-1],e.runtime.openURL(n.getUrl(),function(){},n.pname))})}(this.latitude,this.longitude,this.name,t)},updateMarker:function(){this.mapContext.moveToLocation(),this.mapContext.translateMarker({markerId:"location",destination:{latitude:this.latitude,longitude:this.longitude},duration:0},function(e){})}}};t.default=i}).call(this,n(2).weexPlus)},function(e,t){e.exports={page:{flex:1},"flex-r":{flexDirection:"row",flexWrap:"nowrap"},"flex-c":{flexDirection:"column",flexWrap:"nowrap"},"flex-fill":{flex:1},"a-i-c":{alignItems:"center"},"j-c-c":{justifyContent:"center"},target:{paddingTop:"10",paddingBottom:"10"},"text-area":{paddingLeft:"10",paddingRight:"10",flex:1},name:{fontSize:"16",lines:1,textOverflow:"ellipsis"},address:{fontSize:"14",color:"#808080",lines:1,textOverflow:"ellipsis",marginTop:"2"},"goto-area":{paddingTop:0,paddingRight:"15",paddingBottom:0,paddingLeft:"15"},"goto-icon":{width:"50",height:"50"},"goto-text":{fontSize:"14",color:"#FFFFFF"}}},,,,,,,,,,,,,,function(e,t,n){"use strict";var a=function(){var e=this,t=e.$createElement,n=e._self._c||t;return n("scroll-view",{staticStyle:{flexDirection:"column"},attrs:{scrollY:!0,enableBackToTop:!0,bubble:"true"}},[n("view",{staticClass:["page","flex-c"]},[n("map",{ref:"map1",staticClass:["flex-fill","map"],attrs:{longitude:e.longitude,latitude:e.latitude,markers:e.markers}}),n("view",{staticClass:["flex-r","a-i-c","target"]},[n("view",{staticClass:["text-area"]},[n("u-text",{staticClass:["name"]},[e._v(e._s(e.name))]),n("u-text",{staticClass:["address"]},[e._v(e._s(e.address))])]),n("view",{staticClass:["goto-area"],on:{click:e.goto}},[n("u-image",{staticClass:["goto-icon"],attrs:{src:"data:image/png;base64,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"}})],1)])],1)])},o=[];n.d(t,"a",function(){return a}),n.d(t,"b",function(){return o})},,,,,,function(e,t,n){"use strict";n.r(t);var a=n(16),o=n.n(a);for(var i in a)"default"!==i&&function(e){n.d(t,e,function(){return a[e]})}(i);t.default=o.a},,,,,function(e,t,n){"use strict";n.r(t);n(3);var a=n(7);a.default.mpType="page",a.default.route="template/__uniappopenlocation",a.default.el="#root",new Vue(a.default)}]); \ No newline at end of file diff --git a/packages/uni-app-plus/template/common/__uniapppicker.js b/packages/uni-app-plus/template/common/__uniapppicker.js new file mode 100644 index 000000000..84870efab --- /dev/null +++ b/packages/uni-app-plus/template/common/__uniapppicker.js @@ -0,0 +1 @@ +!function(e){var t={};function n(a){if(t[a])return t[a].exports;var r=t[a]={i:a,l:!1,exports:{}};return e[a].call(r.exports,r,r.exports,n),r.l=!0,r.exports}n.m=e,n.c=t,n.d=function(e,t,a){n.o(e,t)||Object.defineProperty(e,t,{enumerable:!0,get:a})},n.r=function(e){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})},n.t=function(e,t){if(1&t&&(e=n(e)),8&t)return e;if(4&t&&"object"==typeof e&&e&&e.__esModule)return e;var a=Object.create(null);if(n.r(a),Object.defineProperty(a,"default",{enumerable:!0,value:e}),2&t&&"string"!=typeof e)for(var r in e)n.d(a,r,function(t){return e[t]}.bind(null,r));return a},n.n=function(e){var t=e&&e.__esModule?function(){return e.default}:function(){return e};return n.d(t,"a",t),t},n.o=function(e,t){return Object.prototype.hasOwnProperty.call(e,t)},n.p="",n(n.s=44)}([function(e,t){e.exports={}},function(e,t,n){"use strict";function a(e,t,n,a,r,i,o,s,u,c){var l,f="function"==typeof e?e.options:e;if(u){f.components||(f.components={});var d=Object.prototype.hasOwnProperty;for(var p in u)d.call(u,p)&&!d.call(f.components,p)&&(f.components[p]=u[p])}if(c&&((c.beforeCreate||(c.beforeCreate=[])).unshift((function(){this[c.__module]=this})),(f.mixins||(f.mixins=[])).push(c)),t&&(f.render=t,f.staticRenderFns=n,f._compiled=!0),a&&(f.functional=!0),i&&(f._scopeId="data-v-"+i),o?(l=function(e){(e=e||this.$vnode&&this.$vnode.ssrContext||this.parent&&this.parent.$vnode&&this.parent.$vnode.ssrContext)||"undefined"==typeof __VUE_SSR_CONTEXT__||(e=__VUE_SSR_CONTEXT__),r&&r.call(this,e),e&&e._registeredComponents&&e._registeredComponents.add(o)},f._ssrRegister=l):r&&(l=s?function(){r.call(this,this.$root.$options.shadowRoot)}:r),l)if(f.functional){f._injectStyles=l;var h=f.render;f.render=function(e,t){return l.call(t),h(e,t)}}else{var v=f.beforeCreate;f.beforeCreate=v?[].concat(v,l):[l]}return{exports:e,options:f}}n.d(t,"a",(function(){return a}))},function(e,t,n){"use strict";var a;Object.defineProperty(t,"__esModule",{value:!0}),t.weexPlus=t.default=void 0,a="function"==typeof getUni?getUni:function(){var e=function(e){return"function"==typeof e},t=function(e){return e.then((function(e){return[null,e]})).catch((function(e){return[e]}))},n=/^\$|^on|^create|Sync$|Manager$|^pause/,a=["os","getCurrentSubNVue","getSubNVueById","stopRecord","stopVoice","stopBackgroundAudio","stopPullDownRefresh","hideKeyboard","hideToast","hideLoading","showNavigationBarLoading","hideNavigationBarLoading","canIUse","navigateBack","closeSocket","pageScrollTo","drawCanvas"],i=function(e){return(!n.test(e)||"createBLEConnection"===e)&&!~a.indexOf(e)},o=function(n){return function(){for(var a=arguments.length,r=Array(a>1?a-1:0),i=1;i0&&void 0!==arguments[0]?arguments[0]:{};return e(o.success)||e(o.fail)||e(o.complete)?n.apply(void 0,[o].concat(r)):t(new Promise((function(e,t){n.apply(void 0,[Object.assign({},o,{success:e,fail:t})].concat(r)),Promise.prototype.finally=function(e){var t=this.constructor;return this.then((function(n){return t.resolve(e()).then((function(){return n}))}),(function(n){return t.resolve(e()).then((function(){throw n}))}))}})))}},s=[],u=void 0;function c(e){s.forEach((function(t){return t({origin:u,data:e})}))}var l=r.webview.currentWebview().id,f=new BroadcastChannel("UNI-APP-SUBNVUE");function d(e){var t=r.webview.getWebviewById(e);return t&&!t.$processed&&function(e){e.$processed=!0;var t=r.webview.currentWebview().id===e.id,n="uniNView"===e.__uniapp_origin_type&&e.__uniapp_origin_id,a=e.id;if(e.postMessage=function(e){n?f.postMessage({data:e,to:t?n:a}):_({type:"UniAppSubNVue",data:e})},e.onMessage=function(e){s.push(e)},e.__uniapp_mask_id){u=e.__uniapp_host;var i=e.__uniapp_mask,o=r.webview.getWebviewById(e.__uniapp_mask_id);o=o.parent()||o;var c=e.show,l=e.hide,d=e.close,p=function(){o.setStyle({mask:i})},h=function(){o.setStyle({mask:"none"})};e.show=function(){p();for(var t=arguments.length,n=Array(t),a=0;a1&&void 0!==arguments[1]?arguments[1]:"GET",n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:"application/x-www-form-urlencoded";return"object"===(void 0===e?"undefined":L(e))?"POST"===t.toUpperCase()&&"application/json"===n.toLowerCase()?JSON.stringify(e):Object.keys(e).map((function(t){return encodeURIComponent(t)+"="+encodeURIComponent(e[t])})).join("&"):e},$=weex.requireModule("plusstorage"),j=weex.requireModule("clipboard"),B=function(){if("function"==typeof getUniEmitter)return getUniEmitter;var e={$on:function(){console.warn("uni.$on failed")},$off:function(){console.warn("uni.$off failed")},$once:function(){console.warn("uni.$once failed")},$emit:function(){console.warn("uni.$emit failed")}};return function(){return e}}();function R(e,t,n){return e[t].apply(e,n)}var U=Object.freeze({loadFontFace:function(t){var n=t.family,a=t.source,r=(t.desc,t.success),i=(t.fail,t.complete);I.addRule("fontFace",{fontFamily:n,src:a.replace(/"/g,"'")});var o={errMsg:"loadFontFace:ok",status:"loaded"};e(r)&&r(o),e(i)&&i(o)},ready:N,request:function(t){var n=t.url,a=t.data,r=t.header,i=t.method,o=void 0===i?"GET":i,s=t.dataType,u=void 0===s?"json":s,c=(t.responseType,t.success),l=t.fail,f=t.complete,d=!1,p=!1,h={};if(r)for(var v in r)p||"content-type"!==v.toLowerCase()?h[v]=r[v]:(p=!0,h["Content-Type"]=r[v]);return"GET"===o&&a&&(n=n+(~n.indexOf("?")?"&"===n.substr(-1)||"?"===n.substr(-1)?"":"&":"?")+D(a)),P.fetch({url:n,method:o,headers:h,type:"json"===u?"json":"text",body:"GET"!==o?D(a,o,h["Content-Type"]):""},(function(t){var n=t.status,a=(t.ok,t.statusText,t.data),r=t.headers,i={};!n||-1===n||d?(i.errMsg="request:fail",e(l)&&l(i)):(i.data=a,i.statusCode=n,i.header=r,e(c)&&c(i)),e(f)&&f(i)})),{abort:function(){d=!0}}},getStorage:function(t){var n=t.key,a=(t.data,t.success),r=t.fail,i=t.complete;$.getItem(n+"__TYPE",(function(t){if("success"===t.result){var o=t.data;$.getItem(n,(function(t){if("success"===t.result){var n=t.data;o&&n?("String"!==o&&(n=JSON.parse(n)),e(a)&&a({errMsg:"getStorage:ok",data:n})):(t.errMsg="setStorage:fail",e(r)&&r(t))}else t.errMsg="setStorage:fail",e(r)&&r(t);e(i)&&i(t)}))}else t.errMsg="setStorage:fail",e(r)&&r(t),e(i)&&i(t)}))},setStorage:function(t){var n=t.key,a=t.data,r=t.success,i=t.fail,o=t.complete,s="String";"object"===(void 0===a?"undefined":L(a))&&(s="Object",a=JSON.stringify(a)),$.setItem(n,a,(function(t){"success"===t.result?$.setItem(n+"__TYPE",s,(function(t){"success"===t.result?e(r)&&r({errMsg:"setStorage:ok"}):(t.errMsg="setStorage:fail",e(i)&&i(t))})):(t.errMsg="setStorage:fail",e(i)&&i(t)),e(o)&&o(t)}))},removeStorage:function(t){var n=t.key,a=(t.data,t.success),r=t.fail,i=t.complete;$.removeItem(n,(function(t){"success"===t.result?e(a)&&a({errMsg:"removeStorage:ok"}):(t.errMsg="removeStorage:fail",e(r)&&r(t)),e(i)&&i(t)})),$.removeItem(n+"__TYPE")},clearStorage:function(e){e.key,e.data,e.success,e.fail,e.complete},getClipboardData:function(t){var n=t.success,a=(t.fail,t.complete);j.getString((function(t){var r={errMsg:"getClipboardData:ok",data:t.data};e(n)&&n(r),e(a)&&a(r)}))},setClipboardData:function(t){var n=t.data,a=t.success,r=(t.fail,t.complete),i={errMsg:"setClipboardData:ok"};j.setString(n),e(a)&&a(i),e(r)&&r(i)},onSubNVueMessage:c,getSubNVueById:d,getCurrentSubNVue:function(){return d(r.webview.currentWebview().id)},$on:function(){return R(B(),"$on",[].concat(Array.prototype.slice.call(arguments)))},$off:function(){return R(B(),"$off",[].concat(Array.prototype.slice.call(arguments)))},$once:function(){return R(B(),"$once",[].concat(Array.prototype.slice.call(arguments)))},$emit:function(){return R(B(),"$emit",[].concat(Array.prototype.slice.call(arguments)))}}),Y={os:{nvue:!0}},z={};return"undefined"!=typeof Proxy?z=new Proxy({},{get:function(e,t){if("os"===t)return{nvue:!0};if("postMessage"===t)return _;if("requireNativePlugin"===t)return C;if("onNavigationBarButtonTap"===t)return k;if("onNavigationBarSearchInputChanged"===t)return M;if("onNavigationBarSearchInputConfirmed"===t)return E;if("onNavigationBarSearchInputClicked"===t)return x;var n=U[t];return n||(n=b(t)),i(t)?o(n):n}}):(Object.keys(Y).forEach((function(e){z[e]=Y[e]})),z.postMessage=_,z.requireNativePlugin=C,z.onNavigationBarButtonTap=k,z.onNavigationBarSearchInputChanged=M,z.onNavigationBarSearchInputConfirmed=E,z.onNavigationBarSearchInputClicked=x,Object.keys({uploadFile:!0,downloadFile:!0,chooseImage:!0,previewImage:!0,getImageInfo:!0,saveImageToPhotosAlbum:!0,chooseVideo:!0,saveVideoToPhotosAlbum:!0,saveFile:!0,getSavedFileList:!0,getSavedFileInfo:!0,removeSavedFile:!0,openDocument:!0,setStorage:!0,getStorage:!0,getStorageInfo:!0,removeStorage:!0,clearStorage:!0,getLocation:!0,chooseLocation:!0,openLocation:!0,getSystemInfo:!0,getNetworkType:!0,makePhoneCall:!0,scanCode:!0,setScreenBrightness:!0,getScreenBrightness:!0,setKeepScreenOn:!0,vibrateLong:!0,vibrateShort:!0,addPhoneContact:!0,showToast:!0,showLoading:!0,hideToast:!0,hideLoading:!0,showModal:!0,showActionSheet:!0,setNavigationBarTitle:!0,setNavigationBarColor:!0,navigateTo:!0,redirectTo:!0,reLaunch:!0,switchTab:!0,navigateBack:!0,getProvider:!0,login:!0,getUserInfo:!0,share:!0,requestPayment:!0,subscribePush:!0,unsubscribePush:!0,onPush:!0,offPush:!0}).forEach((function(e){var t=U[e];t||(t=b(e)),i(e)?z[e]=o(t):z[e]=t}))),z};var r=new WeexPlus(weex);t.weexPlus=r;var i=a(weex,r,BroadcastChannel);t.default=i},function(e,t,n){Vue.prototype.__$appStyle__={},Vue.prototype.__merge_style&&Vue.prototype.__merge_style(n(4).default,Vue.prototype.__$appStyle__)},function(e,t,n){"use strict";n.r(t);var a=n(0),r=n.n(a);for(var i in a)"default"!==i&&function(e){n.d(t,e,(function(){return a[e]}))}(i);t.default=r.a},function(e,t,n){"use strict";(function(e){Object.defineProperty(t,"__esModule",{value:!0}),t.default=void 0;var n={onLoad:function(){this.initMessage()},methods:{initMessage:function(){var t=this,n=e.webview.currentWebview().extras||{},a=n.from,r=(n.callback,n.runtime),i=n.data,o=void 0===i?{}:i,s=n.useGlobalEvent;this.__from=a,this.__runtime=r,this.__page=e.webview.currentWebview().id,this.__useGlobalEvent=s,this.data=JSON.parse(JSON.stringify(o)),e.key.addEventListener("backbutton",(function(){"function"==typeof t.onClose?t.onClose():e.webview.currentWebview().close("auto")}));var u=this,c=function(e){var t=e.data&&e.data.__message;t&&u.__onMessageCallback&&u.__onMessageCallback(t.data)};this.__useGlobalEvent?weex.requireModule("globalEvent").addEventListener("plusMessage",c):new BroadcastChannel(this.__page).onmessage=c},postMessage:function(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},n=arguments.length>1&&void 0!==arguments[1]&&arguments[1],a={__message:{__page:this.__page,data:t,keep:n}},r=this.__from;if("v8"===this.__runtime)if(this.__useGlobalEvent)e.webview.postMessageToUniNView(a,r);else{var i=new BroadcastChannel(r);i.postMessage(a)}else{var o=e.webview.getWebviewById(r);o&&o.evalJS("__plusMessage&&__plusMessage(".concat(JSON.stringify({data:a}),")"))}},onMessage:function(e){this.__onMessageCallback=e}}};t.default=n}).call(this,n(2).weexPlus)},,,,function(e,t,n){"use strict";var a=n(30),r=n(20),i=n(1);var o=Object(i.a)(r.default,a.b,a.c,!1,null,null,"186ae9bb",!1,a.a,void 0);(function(e){this.options.style||(this.options.style={}),Vue.prototype.__merge_style&&Vue.prototype.__$appStyle__&&Vue.prototype.__merge_style(Vue.prototype.__$appStyle__,this.options.style),Vue.prototype.__merge_style?Vue.prototype.__merge_style(n(40).default,this.options.style):Object.assign(this.options.style,n(40).default)}).call(o),t.default=o.exports},,,,,,,,,,,function(e,t,n){"use strict";var a=n(21),r=n.n(a);t.default=r.a},function(e,t,n){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.default=void 0;var a=r(n(45));function r(e){return e&&e.__esModule?e:{default:e}}var i={mixins:[r(n(5)).default],components:{picker:a.default},data:function(){return{range:[],rangeKey:"",value:0,mode:"selector",fields:"day",start:"",end:"",disabled:!1,visible:!1}},onLoad:function(){var e=this;null===this.data?this.postMessage({event:"created"},!0):this.showPicker(this.data),this.onMessage((function(t){e.showPicker(t)}))},onReady:function(){var e=this;this.$nextTick((function(){e.visible=!0}))},methods:{showPicker:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},t=e.column;for(var n in e)"column"!==n&&("number"==typeof t?this.$set(this.$data[n],t,e[n]):this.$data[n]=e[n])},close:function(e){var t=this,n=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},a=n.value,r=void 0===a?-1:a;this.visible=!1,setTimeout((function(){t.postMessage({event:e,value:r})}),210)},onClose:function(){this.close("cancel")},columnchange:function(e){var t=e.column,n=e.value;this.$set(this.value,t,n),this.postMessage({event:"columnchange",column:t,value:n},!0)}}};t.default=i},function(e,t,n){"use strict";n.r(t);var a=n(23),r=n.n(a);for(var i in a)"default"!==i&&function(e){n.d(t,e,(function(){return a[e]}))}(i);t.default=r.a},function(e,t,n){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.default=void 0;var a=n(46),r=o(n(35)),i=o(n(47));function o(e){return e&&e.__esModule?e:{default:e}}function s(e){return function(e){if(Array.isArray(e)){for(var t=0,n=new Array(e.length);tn(i)&&this._cloneArray(a,i)}e.forEach((function(e,n){e!==t.oldValueArray[n]&&(t.oldValueArray[n]=e,t.mode===f.MULTISELECTOR&&t.$emit("columnchange",{column:n,value:e}))}))},visible:function(e){var t=this;e?this.$nextTick((function(){l.transition(t.$refs.picker,{styles:{transform:"translateY(0)"},duration:200})})):l.transition(this.$refs.picker,{styles:{transform:"translateY(".concat(283+this.safeAreaInsets.bottom,"px)")},duration:200})}},created:function(){this._createTime(),this._createDate(),this._setValueSync()},methods:{getTexts:function(e,t){var n=this,a=this.textMaxLength;return e.map((function(e){var r=("object"==typeof e?e[n.rangeKey]||"":e)+(n.units[t]||"");if(a>0&&r.length>a)for(var i=0,o=0;o127||94===s?1:.65)>=a)return o===r.length-1?r:r.slice(0,o)+"..."}return r||" "})).join("\n")},_createTime:function(){var e=[],t=[];e.splice(0,e.length);for(var n=0;n<24;n++)e.push((n<10?"0":"")+n);t.splice(0,t.length);for(var a=0;a<60;a++)t.push((a<10?"0":"")+a);this.timeArray.push(e,t)},_createDate:function(){for(var e=[],t=(new Date).getFullYear(),n=t-61,a=t+61;n<=a;n++)e.push(String(n));for(var r=[],i=1;i<=12;i++)r.push((i<10?"0":"")+i);for(var o=[],s=1;s<=31;s++)o.push((s<10?"0":"")+s);this.dateArray.push(e,r,o)},_getTimeValue:function(e){return 60*e[0]+e[1]},_getDateValue:function(e){return 366*e[0]+31*(e[1]||0)+(e[2]||0)},_cloneArray:function(e,t){for(var n=0;n=0&&(o=t?this._getDateValueArray(t):o.map((function(){return 0}))),o},_change:function(){this.$emit("change",{value:this._getValue()})},_cancel:function(){this.$emit("cancel")}}};t.default=p},function(e,t){e.exports={content:{position:"absolute",top:0,left:0,bottom:0,right:0},"uni-mask":{position:"absolute",top:0,left:0,bottom:0,right:0,backgroundColor:"rgba(0,0,0,0.4)",opacity:0,transitionProperty:"opacity",transitionDuration:200,transitionTimingFunction:"linear"},"@TRANSITION":{"uni-mask":{property:"opacity",duration:200,timingFunction:"linear"}},"uni-mask-android":{backgroundColor:"rgba(0,0,0,0.6)"},"uni-mask-visible":{opacity:1},"uni-picker":{position:"absolute",left:0,bottom:0,right:0,backgroundColor:"#ffffff",color:"#000000",flexDirection:"column",transform:"translateY(295px)"},"uni-picker-header":{height:"45",borderBottomWidth:0,backgroundColor:"#E6E6E6",fontSize:"20"},"uni-picker-action":{position:"absolute",textAlign:"center",top:0,height:"45",paddingTop:0,paddingRight:"14",paddingBottom:0,paddingLeft:"14",fontSize:"17",lineHeight:"45"},"uni-picker-action-cancel":{left:0,color:"#888888"},"uni-picker-action-confirm":{right:0,color:"#007aff"},"uni-picker-content":{flex:1},"uni-picker-item":{lineHeight:"34",textAlign:"center",color:"#000000"}}},function(e,t){e.exports={page:{flex:1}}},,,,,function(e,t,n){"use strict";var a=function(){var e=this,t=e.$createElement,n=e._self._c||t;return n("scroll-view",{staticStyle:{flexDirection:"column"},attrs:{scrollY:!0,enableBackToTop:!0,bubble:"true"}},[n("view",{staticClass:["page"]},[n("picker",{attrs:{range:e.range,rangeKey:e.rangeKey,value:e.value,mode:e.mode,fields:e.fields,start:e.start,end:e.end,disabled:e.disabled,visible:e.visible},on:{change:function(t){e.close("change",t)},cancel:function(t){e.close("cancel",t)},columnchange:e.columnchange}})],1)])},r=[];n.d(t,"b",(function(){return a})),n.d(t,"c",(function(){return r})),n.d(t,"a",(function(){}))},,,function(e,t,n){"use strict";var a=function(){var e=this,t=e.$createElement,n=e._self._c||t;return n("div",{staticClass:["content"]},[n("div",{ref:"mask",staticClass:["uni-mask"],class:{"uni-mask-visible":e.visible,"uni-mask-android":e.android},on:{click:e._cancel}}),n("div",{ref:"picker",staticClass:["uni-picker"],class:{"uni-picker-visible":e.visible},style:"padding-bottom:"+e.safeAreaInsets.bottom+"px;height:"+(e.height+e.safeAreaInsets.bottom)+"px;"},[n("div",{staticClass:["uni-picker-header"]},[n("u-text",{staticClass:["uni-picker-action","uni-picker-action-cancel"],style:"left:"+e.safeAreaInsets.left+"px",on:{click:e._cancel}},[e._v(e._s(e.localize("cancel")))]),n("u-text",{staticClass:["uni-picker-action","uni-picker-action-confirm"],style:"right:"+e.safeAreaInsets.right+"px",on:{click:e._change}},[e._v(e._s(e.localize("ok")))])]),e.visible?n("picker-view",{staticClass:["uni-picker-content"],style:"margin-left:"+e.safeAreaInsets.left+"px",attrs:{height:"216",indicatorStyle:"height: 34px;border-color:#C8C9C9;border-top-width:0.5px;border-bottom-width:0.5px;",value:e.valueArray},on:{"update:value":function(t){e.valueArray=t}}},e._l(e.rangeArray,(function(t,a){return n("picker-view-column",{key:a,attrs:{length:t.length}},[n("u-text",{staticClass:["uni-picker-item"],style:{fontSize:e.fontSize+"px"}},[e._v(e._s(e.getTexts(t,a)))])])})),1):e._e()],1)])},r=[];n.d(t,"b",(function(){return a})),n.d(t,"c",(function(){return r})),n.d(t,"a",(function(){}))},,function(e,t,n){"use strict";(function(e){Object.defineProperty(t,"__esModule",{value:!0}),t.default=void 0;var n={data:function(){return{locale:{default:"en",full:"en",primary:"en"},localization:{en:{ok:"OK",cancel:"Cancel"},zh:{ok:"完成",cancel:"取消"},"zh-hans":{},"zh-hant":{}}}},onLoad:function(){this.initLocale()},created:function(){this.initLocale()},methods:{initLocale:function(){if(!this.__initLocale){this.__initLocale=!0;var t=e.os.language.toLowerCase().replace("_","-").split("-"),n=t[1];n&&(t[1]={chs:"hans",cn:"hans",sg:"hans",cht:"hant",tw:"hant",hk:"hant",mo:"hant"}[n]||n),t.length=t.length>2?2:t.length,this.locale.full=t.join("-"),this.locale.primary=t[0]}},localize:function(e){var t=this.locale,n=this.localization;function a(e){return n[e]||{}}return a(t.full)[e]||a(t.primary)[e]||a(t.default)[e]||e}}};t.default=n}).call(this,n(2).weexPlus)},,,,function(e,t,n){"use strict";n.r(t);var a=n(24),r=n.n(a);for(var i in a)"default"!==i&&function(e){n.d(t,e,(function(){return a[e]}))}(i);t.default=r.a},function(e,t,n){"use strict";n.r(t);var a=n(25),r=n.n(a);for(var i in a)"default"!==i&&function(e){n.d(t,e,(function(){return a[e]}))}(i);t.default=r.a},,,,function(e,t,n){"use strict";n.r(t);n(3);var a=n(9);a.default.mpType="page",a.default.route="template/__uniapppicker",a.default.el="#root",new Vue(a.default)},function(e,t,n){"use strict";n.r(t);var a=n(33),r=n(22);for(var i in r)"default"!==i&&function(e){n.d(t,e,(function(){return r[e]}))}(i);var o=n(1);var s=Object(o.a)(r.default,a.b,a.c,!1,null,null,"7a3cf155",!1,a.a,void 0);(function(e){this.options.style||(this.options.style={}),Vue.prototype.__merge_style&&Vue.prototype.__$appStyle__&&Vue.prototype.__merge_style(Vue.prototype.__$appStyle__,this.options.style),Vue.prototype.__merge_style?Vue.prototype.__merge_style(n(39).default,this.options.style):Object.assign(this.options.style,n(39).default)}).call(s),t.default=s.exports},function(e,t,n){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.formatDateTime=function(e){var t=e.date,n=void 0===t?new Date:t,r=e.mode;return"time"===(void 0===r?"date":r)?a(n.getHours())+":"+a(n.getMinutes()):n.getFullYear()+"-"+a(n.getMonth()+1)+"-"+a(n.getDate())};var a=function(e){return e>9?e:"0"+e}},function(e,t,n){"use strict";(function(e){Object.defineProperty(t,"__esModule",{value:!0}),t.default=void 0;var n={data:function(){return{safeAreaInsets:{left:0,right:0,top:0,bottom:0}}},onLoad:function(){this.initSafeAreaInsets()},created:function(){this.initSafeAreaInsets()},methods:{initSafeAreaInsets:function(){var t=this;if(!this.__initSafeAreaInsets){this.__initSafeAreaInsets=!0;var n=e.webview.currentWebview();n.addEventListener("resize",(function(){setTimeout((function(){t.updateSafeAreaInsets(n)}),20)})),this.updateSafeAreaInsets(n)}},updateSafeAreaInsets:function(e){var t=e.getSafeAreaInsets(),n=this.safeAreaInsets;Object.keys(n).forEach((function(e){n[e]=t[e]}))}}};t.default=n}).call(this,n(2).weexPlus)}]); \ No newline at end of file diff --git a/packages/uni-app-plus/template/common/__uniappscan.js b/packages/uni-app-plus/template/common/__uniappscan.js new file mode 100644 index 000000000..e4eaceccd --- /dev/null +++ b/packages/uni-app-plus/template/common/__uniappscan.js @@ -0,0 +1 @@ +!function(e){var t={};function n(a){if(t[a])return t[a].exports;var o=t[a]={i:a,l:!1,exports:{}};return e[a].call(o.exports,o,o.exports,n),o.l=!0,o.exports}n.m=e,n.c=t,n.d=function(e,t,a){n.o(e,t)||Object.defineProperty(e,t,{enumerable:!0,get:a})},n.r=function(e){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})},n.t=function(e,t){if(1&t&&(e=n(e)),8&t)return e;if(4&t&&"object"==typeof e&&e&&e.__esModule)return e;var a=Object.create(null);if(n.r(a),Object.defineProperty(a,"default",{enumerable:!0,value:e}),2&t&&"string"!=typeof e)for(var o in e)n.d(a,o,function(t){return e[t]}.bind(null,o));return a},n.n=function(e){var t=e&&e.__esModule?function(){return e.default}:function(){return e};return n.d(t,"a",t),t},n.o=function(e,t){return Object.prototype.hasOwnProperty.call(e,t)},n.p="",n(n.s=43)}([function(e,t){e.exports={}},function(e,t,n){"use strict";function a(e,t,n,a,o,r,i,s,c,u){var l,f="function"==typeof e?e.options:e;if(c&&(f.components=Object.assign(c,f.components||{})),u&&((u.beforeCreate||(u.beforeCreate=[])).unshift(function(){this[u.__module]=this}),(f.mixins||(f.mixins=[])).push(u)),t&&(f.render=t,f.staticRenderFns=n,f._compiled=!0),a&&(f.functional=!0),r&&(f._scopeId="data-v-"+r),i?(l=function(e){(e=e||this.$vnode&&this.$vnode.ssrContext||this.parent&&this.parent.$vnode&&this.parent.$vnode.ssrContext)||"undefined"==typeof __VUE_SSR_CONTEXT__||(e=__VUE_SSR_CONTEXT__),o&&o.call(this,e),e&&e._registeredComponents&&e._registeredComponents.add(i)},f._ssrRegister=l):o&&(l=s?function(){o.call(this,this.$root.$options.shadowRoot)}:o),l)if(f.functional){f._injectStyles=l;var d=f.render;f.render=function(e,t){return l.call(t),d(e,t)}}else{var p=f.beforeCreate;f.beforeCreate=p?[].concat(p,l):[l]}return{exports:e,options:f}}n.d(t,"a",function(){return a})},function(e,t,n){"use strict";var a;Object.defineProperty(t,"__esModule",{value:!0}),t.weexPlus=t.default=void 0,a="function"==typeof getUni?getUni:function(){var e=function(e){return"function"==typeof e},t=/^\$|^on|^create|Sync$|Manager$|^pause/,n=["os","getCurrentSubNVue","getSubNVueById","stopRecord","stopVoice","stopBackgroundAudio","stopPullDownRefresh","hideKeyboard","hideToast","hideLoading","showNavigationBarLoading","hideNavigationBarLoading","canIUse","navigateBack","closeSocket","pageScrollTo","drawCanvas"],a=function(e){return!(t.test(e)&&"createBLEConnection"!==e||~n.indexOf(e))},r=function(t){return function(){for(var n=arguments.length,a=Array(n>1?n-1:0),o=1;o0&&void 0!==arguments[0]?arguments[0]:{};return e(r.success)||e(r.fail)||e(r.complete)?t.apply(void 0,[r].concat(a)):new Promise(function(e,n){t.apply(void 0,[Object.assign({},r,{success:e,fail:n})].concat(a)),Promise.prototype.finally=function(e){var t=this.constructor;return this.then(function(n){return t.resolve(e()).then(function(){return n})},function(n){return t.resolve(e()).then(function(){throw n})})}}).then(function(e){return[null,e]}).catch(function(e){return[e]})}},i=[],s=void 0;function c(e){i.forEach(function(t){return t({origin:s,data:e})})}var u=o.webview.currentWebview().id,l=new BroadcastChannel("UNI-APP-SUBNVUE");function f(e){e.$processed=!0;var t=o.webview.currentWebview().id===e.id,n="uniNView"===e.__uniapp_origin_type&&e.__uniapp_origin_id,a=e.id;if(e.postMessage=function(e){n?l.postMessage({data:e,to:t?n:a}):_({type:"UniAppSubNVue",data:e})},e.onMessage=function(e){i.push(e)},e.__uniapp_mask_id){s=e.__uniapp_host;var r=e.__uniapp_mask,c=o.webview.getWebviewById(e.__uniapp_mask_id);c=c.parent()||c;var u=e.show,f=e.hide,d=e.close,p=function(){c.setStyle({mask:"none"})};e.show=function(){c.setStyle({mask:r});for(var t=arguments.length,n=Array(t),a=0;a1&&void 0!==arguments[1]?arguments[1]:R,n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:"application/x-www-form-urlencoded";return"object"===(void 0===e?"undefined":x(e))?"POST"===t.toUpperCase()&&"application/json"===n.toLowerCase()?JSON.stringify(e):Object.keys(e).map(function(t){return encodeURIComponent(t)+"="+encodeURIComponent(e[t])}).join("&"):e},F=weex.requireModule("plusstorage"),j="__TYPE",$=weex.requireModule("clipboard"),L=function(){if("function"==typeof getUniEmitter)return getUniEmitter;var e={$on:function(){console.warn("uni.$on failed")},$off:function(){console.warn("uni.$off failed")},$once:function(){console.warn("uni.$once failed")},$emit:function(){console.warn("uni.$emit failed")}};return function(){return e}}();function Q(e,t,n){return e[t].apply(e,n)}var J=Object.freeze({loadFontFace:function(t){var n=t.family,a=t.source,o=(t.desc,t.success),r=(t.fail,t.complete);N.addRule("fontFace",{fontFamily:n,src:a.replace(/"/g,"'")});var i={errMsg:"loadFontFace:ok",status:"loaded"};e(o)&&o(i),e(r)&&r(i)},ready:D,request:function(t){var n=t.url,a=t.data,o=t.header,r=t.method,i=void 0===r?"GET":r,s=t.dataType,c=void 0===s?"json":s,u=(t.responseType,t.success),l=t.fail,f=t.complete,d=!1,p=!1,g={};if(o)for(var v in o)p||"content-type"!==v.toLowerCase()?g[v]=o[v]:(p=!0,g["Content-Type"]=o[v]);return i===R&&a&&(n=n+(~n.indexOf("?")?"&"===n.substr(-1)||"?"===n.substr(-1)?"":"&":"?")+V(a)),U.fetch({url:n,method:i,headers:g,type:"json"===c?"json":"text",body:i!==R?V(a,i,g["Content-Type"]):""},function(t){var n=t.status,a=(t.ok,t.statusText,t.data),o=t.headers,r={};!n||-1===n||d?(r.errMsg="request:fail",e(l)&&l(r)):(r.data=a,r.statusCode=n,r.header=o,e(u)&&u(r)),e(f)&&f(r)}),{abort:function(){d=!0}}},getStorage:function(t){var n=t.key,a=(t.data,t.success),o=t.fail,r=t.complete;F.getItem(n+j,function(t){if("success"===t.result){var i=t.data;F.getItem(n,function(t){if("success"===t.result){var n=t.data;i&&n?("String"!==i&&(n=JSON.parse(n)),e(a)&&a({errMsg:"getStorage:ok",data:n})):(t.errMsg="setStorage:fail",e(o)&&o(t))}else t.errMsg="setStorage:fail",e(o)&&o(t);e(r)&&r(t)})}else t.errMsg="setStorage:fail",e(o)&&o(t),e(r)&&r(t)})},setStorage:function(t){var n=t.key,a=t.data,o=t.success,r=t.fail,i=t.complete,s="String";"object"===(void 0===a?"undefined":x(a))&&(s="Object",a=JSON.stringify(a)),F.setItem(n,a,function(t){"success"===t.result?F.setItem(n+j,s,function(t){"success"===t.result?e(o)&&o({errMsg:"setStorage:ok"}):(t.errMsg="setStorage:fail",e(r)&&r(t))}):(t.errMsg="setStorage:fail",e(r)&&r(t)),e(i)&&i(t)})},removeStorage:function(t){var n=t.key,a=(t.data,t.success),o=t.fail,r=t.complete;F.removeItem(n,function(t){"success"===t.result?e(a)&&a({errMsg:"removeStorage:ok"}):(t.errMsg="removeStorage:fail",e(o)&&o(t)),e(r)&&r(t)}),F.removeItem(n+j)},clearStorage:function(e){e.key,e.data,e.success,e.fail,e.complete},getClipboardData:function(t){var n=t.success,a=(t.fail,t.complete);$.getString(function(t){var o={errMsg:"getClipboardData:ok",data:t.data};e(n)&&n(o),e(a)&&a(o)})},setClipboardData:function(t){var n=t.data,a=t.success,o=(t.fail,t.complete),r={errMsg:"setClipboardData:ok"};$.setString(n),e(a)&&a(r),e(o)&&o(r)},onSubNVueMessage:c,getSubNVueById:d,getCurrentSubNVue:function(){return d(o.webview.currentWebview().id)},$on:function(){return Q(L(),"$on",[].concat(Array.prototype.slice.call(arguments)))},$off:function(){return Q(L(),"$off",[].concat(Array.prototype.slice.call(arguments)))},$once:function(){return Q(L(),"$once",[].concat(Array.prototype.slice.call(arguments)))},$emit:function(){return Q(L(),"$emit",[].concat(Array.prototype.slice.call(arguments)))}}),q={os:{nvue:!0}},K={};return"undefined"!=typeof Proxy?K=new Proxy({},{get:function(e,t){if("os"===t)return{nvue:!0};if("postMessage"===t)return _;if("requireNativePlugin"===t)return I;if("onNavigationBarButtonTap"===t)return M;if("onNavigationBarSearchInputChanged"===t)return k;if("onNavigationBarSearchInputConfirmed"===t)return B;if("onNavigationBarSearchInputClicked"===t)return O;var n=J[t];return n||(n=b(t)),a(t)?r(n):n}}):(Object.keys(q).forEach(function(e){K[e]=q[e]}),K.postMessage=_,K.requireNativePlugin=I,K.onNavigationBarButtonTap=M,K.onNavigationBarSearchInputChanged=k,K.onNavigationBarSearchInputConfirmed=B,K.onNavigationBarSearchInputClicked=O,Object.keys({uploadFile:!0,downloadFile:!0,chooseImage:!0,previewImage:!0,getImageInfo:!0,saveImageToPhotosAlbum:!0,chooseVideo:!0,saveVideoToPhotosAlbum:!0,saveFile:!0,getSavedFileList:!0,getSavedFileInfo:!0,removeSavedFile:!0,openDocument:!0,setStorage:!0,getStorage:!0,getStorageInfo:!0,removeStorage:!0,clearStorage:!0,getLocation:!0,chooseLocation:!0,openLocation:!0,getSystemInfo:!0,getNetworkType:!0,makePhoneCall:!0,scanCode:!0,setScreenBrightness:!0,getScreenBrightness:!0,setKeepScreenOn:!0,vibrateLong:!0,vibrateShort:!0,addPhoneContact:!0,showToast:!0,showLoading:!0,hideToast:!0,hideLoading:!0,showModal:!0,showActionSheet:!0,setNavigationBarTitle:!0,setNavigationBarColor:!0,navigateTo:!0,redirectTo:!0,reLaunch:!0,switchTab:!0,navigateBack:!0,getProvider:!0,login:!0,getUserInfo:!0,share:!0,requestPayment:!0,subscribePush:!0,unsubscribePush:!0,onPush:!0,offPush:!0}).forEach(function(e){var t=J[e];t||(t=b(e)),a(e)?K[e]=r(t):K[e]=t})),K};var o=new WeexPlus(weex);t.weexPlus=o;var r=a(weex,o,BroadcastChannel);t.default=r},function(e,t,n){Vue.prototype.__$appStyle__={},Vue.prototype.__merge_style&&Vue.prototype.__merge_style(n(4).default,Vue.prototype.__$appStyle__)},function(e,t,n){"use strict";n.r(t);var a=n(0),o=n.n(a);for(var r in a)"default"!==r&&function(e){n.d(t,e,function(){return a[e]})}(r);t.default=o.a},function(e,t,n){"use strict";(function(e){Object.defineProperty(t,"__esModule",{value:!0}),t.default=void 0;var n={onLoad:function(){this.initMessage()},methods:{initMessage:function(){var t=this,n=e.webview.currentWebview().extras||{},a=n.from,o=(n.callback,n.runtime),r=n.data,i=void 0===r?{}:r,s=n.useGlobalEvent;this.__from=a,this.__runtime=o,this.__page=e.webview.currentWebview().id,this.__useGlobalEvent=s,this.data=JSON.parse(JSON.stringify(i)),e.key.addEventListener("backbutton",function(){"function"==typeof t.onClose?t.onClose():e.webview.currentWebview().close("auto")});var c=this,u=function(e){var t=e.data&&e.data.__message;t&&c.__onMessageCallback&&c.__onMessageCallback(t.data)};this.__useGlobalEvent?weex.requireModule("globalEvent").addEventListener("plusMessage",u):new BroadcastChannel(this.__page).onmessage=u},postMessage:function(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},n=arguments.length>1&&void 0!==arguments[1]&&arguments[1],a={__message:{__page:this.__page,data:t,keep:n}},o=this.__from;if("v8"===this.__runtime){if(this.__useGlobalEvent)e.webview.postMessageToUniNView(a,o);else new BroadcastChannel(o).postMessage(a)}else{var r=e.webview.getWebviewById(o);r&&r.evalJS("__plusMessage&&__plusMessage(".concat(JSON.stringify({data:a}),")"))}},onMessage:function(e){this.__onMessageCallback=e}}};t.default=n}).call(this,n(2).weexPlus)},,,function(e,t,n){"use strict";var a=n(32),o=n(17),r=n(1);var i=Object(r.a)(o.default,a.b,a.c,!1,null,null,"57707442",!1,a.a,void 0);(function(e){this.options.style||(this.options.style={}),Vue.prototype.__merge_style&&Vue.prototype.__$appStyle__&&Vue.prototype.__merge_style(Vue.prototype.__$appStyle__,this.options.style),Vue.prototype.__merge_style?Vue.prototype.__merge_style(n(38).default,this.options.style):Object.assign(this.options.style,n(38).default)}).call(i),t.default=i.exports},,,,,,,,,function(e,t,n){"use strict";var a=n(18),o=n.n(a);t.default=o.a},function(e,t,n){"use strict";(function(e){Object.defineProperty(t,"__esModule",{value:!0}),t.default=void 0;var a,o,r=(a=n(5))&&a.__esModule?a:{default:a};function i(e,t,n){return t in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}var s=e.barcode,c={qrCode:[s.QR,s.AZTEC,s.MAXICODE],barCode:[s.EAN13,s.EAN8,s.UPCA,s.UPCE,s.CODABAR,s.CODE128,s.CODE39,s.CODE93,s.ITF,s.RSS14,s.RSSEXPANDED],datamatrix:[s.DATAMATRIX],pdf417:[s.PDF417]},u=(i(o={},s.QR,"QR_CODE"),i(o,s.EAN13,"EAN_13"),i(o,s.EAN8,"EAN_8"),i(o,s.DATAMATRIX,"DATA_MATRIX"),i(o,s.UPCA,"UPC_A"),i(o,s.UPCE,"UPC_E"),i(o,s.CODABAR,"CODABAR"),i(o,s.CODE39,"CODE_39"),i(o,s.CODE93,"CODE_93"),i(o,s.CODE128,"CODE_128"),i(o,s.ITF,"CODE_25"),i(o,s.PDF417,"PDF_417"),i(o,s.AZTEC,"AZTEC"),i(o,s.RSS14,"RSS_14"),i(o,s.RSSEXPANDED,"RSSEXPANDED"),o),l={mixins:[r.default],data:{filters:[0,2,1],backgroud:"#000000",frameColor:"#118ce9",scanbarColor:"#118ce9",enabledFlash:!1,flashImage0:"data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAADAAAAAwCAYAAABXAvmHAAABjklEQVRoQ+1ZbVHEQAx9TwE4ABTcOQAknANQAKcAUAAOAAXgAHAACsDCKQiTmbYDzJZtNt2bFrJ/m6+Xl2yyU2LmhzOPH/8PgIjcADirxNyapNoffMwMiMgzgMPBHmyCLySPLCoBwJKtAbJbYaBmD1yRvBwAtBMxl5DF+DZkiwCIyBLAzsgBbki+Wm2WAlCaL6zOMvKnJO+sNksB7ALQbO1ZHfbIv5FUVs2nCIB6EZETALdmj2mFY5I6X8ynGEADQllYmL1+VzBfnV/VvQB0aj45ARyQ/Ci14QLQsOBZLe5JaikWnzEA7AN4L4hgA2Dpyb76dANwsOCq/TZhASAYKGie0a7R1lDPI0ebtF0NUi+4yfdAtxr3PEMnD6BbD0QkNfACQO05EAwMuaBqDrIVycdmTpwDuP4R0OR7QFftVRP0g+49cwOQq4DJMxAAchmofY3m/EcJBQOZbTRKKJeBKKEoIePvpFRJ1VzmciUccyCa+C81cerBkuuB7sGTE/zt+yhN7AnAqxsAvBn06n8CkyPwMZKwm+UAAAAASUVORK5CYII=",flashImage1:"data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAADAAAAAwBAMAAAClLOS0AAAAMFBMVEUAAAA3kvI3lfY2k/VAl+43k/U3k/Q4k/M3kvI3k/M4k/Q4lPU2lPU2k/Vdq843k/WWSpNKAAAAD3RSTlMAwD+QINCAcPBgUDDgoBAE044kAAAAdklEQVQ4y2OgOrD/DwffUSTkERIfyZXAtOMbca7iVoKDDSgSbAijJqBI8J2HiX9FM2s+TOITmgQrTEIATYIJJuEA5mJ68S+Gg/0hEi0YEoxQK2gs0WyPQyKBGYeEAhPtJRaw45AIccXpwVEJekuwQyQWMFAfAACeDBJY9aXa3QAAAABJRU5ErkJggg=="},onLoad:function(){var e=this,t=this.data.scanType,n=[];Array.isArray(t)&&t.length&&t.forEach(function(e){var t=c[e];t&&(n=n.concat(t))}),n.length||(n=n.concat(c.qrCode).concat(c.barCode).concat(c.datamatrix).concat(c.pdf417)),this.filters=n,this.onMessage(function(t){e.gallery()})},onUnload:function(){this.cancel()},methods:{start:function(){this.$refs.barcode.start({conserve:!0,filename:"_doc/barcode/"})},scan:function(t){var n=this;s.scan(t,function(e,t,a){n.scanSuccess(e,t,a)},function(){e.nativeUI.toast("识别失败")},this.filters)},cancel:function(){this.$refs.barcode.cancel()},gallery:function(){var t=this;e.gallery.pick(function(e){t.scan(e)},function(t){12!==t.code&&e.nativeUI.toast("选择失败")},{multiple:!1,system:!1})},onmarked:function(e){var t=e.detail;this.scanSuccess(t.code,t.message,t.file)},scanSuccess:function(e,t,n){this.postMessage({event:"marked",detail:{scanType:u[e],result:t,charSet:"utf8",path:n||""}})},onerror:function(e){this.postMessage({event:"fail",message:JSON.stringify(e)})},setFlash:function(){this.enabledFlash=!this.enabledFlash,this.$refs.barcode.setFlash(this.enabledFlash)}}};t.default=l}).call(this,n(2).weexPlus)},function(e,t){e.exports={content:{flex:1,alignItems:"center",justifyContent:"center",backgroundColor:"#000000"},barcode:{position:"absolute",left:0,top:0,right:0,bottom:0,zIndex:1},"set-flash":{alignItems:"center",justifyContent:"center",transform:"translateY(80px)",zIndex:2},"image-flash":{width:"26",height:"26",marginBottom:"2"},"image-flash-text":{fontSize:"10",color:"#FFFFFF"}}},,,,,,,,,,,,,function(e,t,n){"use strict";var a=function(){var e=this,t=e.$createElement,n=e._self._c||t;return n("scroll-view",{staticStyle:{flexDirection:"column"},attrs:{scrollY:!0,enableBackToTop:!0,bubble:"true"}},[n("view",{staticClass:["content"]},[n("barcode",{ref:"barcode",staticClass:["barcode"],attrs:{autostart:"true",backgroud:e.backgroud,frameColor:e.frameColor,scanbarColor:e.scanbarColor,filters:e.filters},on:{marked:e.onmarked,error:e.onerror}}),n("view",{staticClass:["set-flash"],on:{click:e.setFlash}},[n("u-image",{staticClass:["image-flash"],attrs:{src:e.enabledFlash?e.flashImage1:e.flashImage0,resize:"stretch"}}),n("u-text",{staticClass:["image-flash-text"]},[e._v(e._s(e.enabledFlash?"轻触关闭":"轻触照亮"))])],1)],1)])},o=[];n.d(t,"b",function(){return a}),n.d(t,"c",function(){return o}),n.d(t,"a",function(){})},,,,,,function(e,t,n){"use strict";n.r(t);var a=n(19),o=n.n(a);for(var r in a)"default"!==r&&function(e){n.d(t,e,function(){return a[e]})}(r);t.default=o.a},,,,,function(e,t,n){"use strict";n.r(t);n(3);var a=n(8);a.default.mpType="page",a.default.route="template/__uniappscan",a.default.el="#root",new Vue(a.default)}]); \ No newline at end of file diff --git a/packages/uni-app-plus/template/common/__uniappsuccess.png b/packages/uni-app-plus/template/common/__uniappsuccess.png new file mode 100644 index 0000000000000000000000000000000000000000..c1f5bd7c5293dcc37284f30b215ff2a3779c316f GIT binary patch literal 2021 zcma)7eK^x=A72+`^OkKEQTWYFlb05qPGRvo!@P{AZ4rsi#PMX`})4zpZoj$T-W{mX8$YD z$3WLi7Y2hF_)^F;%~`R!;OjKI`&ReYFqqC=U$Q6T)awsL2VytvGkt#34vS^CaX2By zU!LB60M@{nNJ2(I##{v@t`wYo%DIgpUOXi*2L7&4%bCRWH#lL<#($tnIrs0AdJkC| zW3M&dh?kyh7?2&wpZPlBHh#Rpwc%J-;XvW=`YaMI+Ie_sE?l)VCd*i>N#Xw$uV^Oo zAIZSL0BP6B&d$zs!nco?%UqnD8~*&+E!bV_nQrUzjE<^0Fxl zus$tw^bH>`Y1Z%>I-MRu^W4_n)6+8`KR7k(N?w^V+NT|*J#YEs1A`J5%0Hp+XY&+Z zJT`;_FR2k+$6wqFwCSVIzmlbXAh46>yDdYizI$BUfXJMz$mg0KJb?ssmLV&gX=zwZ z1Rh+8^^kTl&?tIs|ItLu9S=&9dubX4x@&`>g$+0`(D`y}Y|Df>3;>A9Xi_4?I?n;I z@%LZ%X*35&;pYV)i|{NJvc7}^$`RC~e1s*WU8ZknSX_V`c}13fU|@E8qe=4JXLGq+ zgj=_m7$>pCDGjT1ecSW0(IhG~Sz6zNJZLeRzIqDAT^cPfy_3T1gXx|BM|$ zqf&NiJlcqoy|2KD8eElLQ9x`Cj%9=j_zh7K!g@9y7zanx5euggdV=m$`j70)7f=vI z+VWrHE;l!pAtvh~`i22knX?v{2XL)ein{sj0gueX)^v8}yVdYzP58DV4aTnByH8u} z%ldxQrwmcTC%~*8NE9$ zWQnLN6`?Wa~NMMBV>SjkxQFxKv{C_I8JD0O&%A^|`i7Dr~r$4}^*BTDXZw&+hfU}_CsL&K%Few1B>HpIXct=oZ@PZwQh`HZWy7P0DP%ybKH_~mfL zfk&IabdfC|)@$fREHr&*C$hW!W%Lp!^QmZ;5$mzV0)L>w=LQN0QLYRMx574XLayk|?T<)M*^Qtd2PtA* zKH8H_aJFABw+U7B#J!&wPRLOU6GVwbccZ?%|A2+o=5Bw_ir^p-MGc)P0uh4oiJaV_ z$R9F``Y@M{q?euRfP&CK$c9hXvW%B@_;{@d2e+SnFh3o)cWdoEaD{J^RF5hhCB9qN zfAWPva`hQ?BQm8g<91m`uH#QvKZUwBG!yw62#RzaSWHk6FECdo(%y7#+|<=P&iAlV z#s}yln@z`g9YVjb3fuamkDijT(W}rcPw5=9IH{R6*CwFz9sTOA_dwl2aR`DNJ1wzC zColY>pxR#^rYMp??V8`k66*t_7k8=D*mu;Z!DXYS{8daWFu zg|mhiIuUJYsAFV2t|NbG*;B%w~YK@z>yEk-Y{UUuN_dmQ$CmUVbu?EUR-;rKF!Dv|VJ?AM7Zbw>;thwlP!olCy7b zYxv0S%%O7sZ=vGj23tFLGZE=kw0_}RwW1sLG)XJGiD%Y7Us}jLunlM9BFy9c1P_(u z{LBvh;rT1@NE>^SEvg@9a=6PpE|usGL3gu7Rk0dE`eeN3YS9G_5wOPUdFX%^UX*)Tl}|?50x;OFpp9V| zo#Uqi2y*O=*zgg&Zg+@EhkppBn!bq8UF?Z$djA^ literal 0 HcmV?d00001 diff --git a/packages/uni-app-plus/template/v3/__uniappes6.js b/packages/uni-app-plus/template/v3/__uniappes6.js new file mode 100644 index 000000000..d4018e8a7 --- /dev/null +++ b/packages/uni-app-plus/template/v3/__uniappes6.js @@ -0,0 +1 @@ +!function(t){"use strict";!function(t){var r={};function n(e){if(r[e])return r[e].exports;var o=r[e]={i:e,l:!1,exports:{}};return t[e].call(o.exports,o,o.exports,n),o.l=!0,o.exports}n.m=t,n.c=r,n.d=function(t,r,e){n.o(t,r)||Object.defineProperty(t,r,{enumerable:!0,get:e})},n.r=function(t){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(t,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(t,"__esModule",{value:!0})},n.t=function(t,r){if(1&r&&(t=n(t)),8&r)return t;if(4&r&&"object"==typeof t&&t&&t.__esModule)return t;var e=Object.create(null);if(n.r(e),Object.defineProperty(e,"default",{enumerable:!0,value:t}),2&r&&"string"!=typeof t)for(var o in t)n.d(e,o,function(r){return t[r]}.bind(null,o));return e},n.n=function(t){var r=t&&t.__esModule?function(){return t.default}:function(){return t};return n.d(r,"a",r),r},n.o=function(t,r){return Object.prototype.hasOwnProperty.call(t,r)},n.p="",n(n.s=0)}([function(t,r,n){n(1),n(54),n(61),n(66),n(68),n(69),n(70),n(71),n(73),n(74),n(76),n(84),n(85),n(86),n(95),n(96),n(98),n(99),n(100),n(102),n(103),n(104),n(105),n(106),n(107),n(109),n(110),n(111),n(112),n(121),n(124),n(125),n(127),n(129),n(130),n(131),n(132),n(133),n(135),n(137),n(140),n(141),n(143),n(145),n(146),n(147),n(148),n(150),n(151),n(152),n(153),n(154),n(156),n(157),n(159),n(160),n(161),n(162),n(163),n(164),n(165),n(166),n(167),n(168),n(170),n(171),n(172),n(174),n(178),n(179),n(180),n(181),n(187),n(189),n(192),n(193),n(194),n(195),n(196),n(197),n(198),n(199),n(201),n(202),n(203),n(206),n(207),n(208),n(209),n(210),n(211),n(212),n(213),n(214),n(215),n(216),t.exports=n(217)},function(r,n,e){var o=e(2),i=e(6),u=e(45),c=e(14),a=e(46),f=e(39),s=e(47),l=e(48),p=e(51),g=e(49),v=e(52),h=g("isConcatSpreadable"),d=v>=51||!i(function(){var t=[];return t[h]=!1,t.concat()[0]!==t}),x=p("concat"),y=function(r){if(!c(r))return!1;var n=r[h];return n!==t?!!n:u(r)};o({target:"Array",proto:!0,forced:!d||!x},{concat:function(t){var r,n,e,o,i,u=a(this),c=l(u,0),p=0;for(r=-1,e=arguments.length;r9007199254740991)throw TypeError("Maximum allowed index exceeded");for(n=0;n=9007199254740991)throw TypeError("Maximum allowed index exceeded");s(c,p++,i)}return c.length=p,c}})},function(r,n,e){var o=e(3),i=e(4).f,u=e(18),c=e(21),a=e(25),f=e(32),s=e(44);r.exports=function(r,n){var e,l,p,g,v,h=r.target,d=r.global,x=r.stat;if(e=d?o:x?o[h]||a(h,{}):(o[h]||{}).prototype)for(l in n){if(g=n[l],p=r.noTargetGet?(v=i(e,l))&&v.value:e[l],!s(d?l:h+(x?".":"#")+l,r.forced)&&p!==t){if(typeof g==typeof p)continue;f(g,p)}(r.sham||p&&p.sham)&&u(g,"sham",!0),c(e,l,g,r)}}},function(t,r){var n=function(t){return t&&t.Math==Math&&t};t.exports=n("object"==typeof globalThis&&globalThis)||n("object"==typeof window&&window)||n("object"==typeof self&&self)||n("object"==typeof global&&global)||Function("return this")()},function(t,r,n){var e=n(5),o=n(7),i=n(8),u=n(9),c=n(13),a=n(15),f=n(16),s=Object.getOwnPropertyDescriptor;r.f=e?s:function(t,r){if(t=u(t),r=c(r,!0),f)try{return s(t,r)}catch(t){}if(a(t,r))return i(!o.f.call(t,r),t[r])}},function(t,r,n){var e=n(6);t.exports=!e(function(){return 7!=Object.defineProperty({},"a",{get:function(){return 7}}).a})},function(t,r){t.exports=function(t){try{return!!t()}catch(t){return!0}}},function(t,r,n){var e={}.propertyIsEnumerable,o=Object.getOwnPropertyDescriptor,i=o&&!e.call({1:2},1);r.f=i?function(t){var r=o(this,t);return!!r&&r.enumerable}:e},function(t,r){t.exports=function(t,r){return{enumerable:!(1&t),configurable:!(2&t),writable:!(4&t),value:r}}},function(t,r,n){var e=n(10),o=n(12);t.exports=function(t){return e(o(t))}},function(t,r,n){var e=n(6),o=n(11),i="".split;t.exports=e(function(){return!Object("z").propertyIsEnumerable(0)})?function(t){return"String"==o(t)?i.call(t,""):Object(t)}:Object},function(t,r){var n={}.toString;t.exports=function(t){return n.call(t).slice(8,-1)}},function(r,n){r.exports=function(r){if(r==t)throw TypeError("Can't call method on "+r);return r}},function(t,r,n){var e=n(14);t.exports=function(t,r){if(!e(t))return t;var n,o;if(r&&"function"==typeof(n=t.toString)&&!e(o=n.call(t)))return o;if("function"==typeof(n=t.valueOf)&&!e(o=n.call(t)))return o;if(!r&&"function"==typeof(n=t.toString)&&!e(o=n.call(t)))return o;throw TypeError("Can't convert object to primitive value")}},function(t,r){t.exports=function(t){return"object"==typeof t?null!==t:"function"==typeof t}},function(t,r){var n={}.hasOwnProperty;t.exports=function(t,r){return n.call(t,r)}},function(t,r,n){var e=n(5),o=n(6),i=n(17);t.exports=!e&&!o(function(){return 7!=Object.defineProperty(i("div"),"a",{get:function(){return 7}}).a})},function(t,r,n){var e=n(3),o=n(14),i=e.document,u=o(i)&&o(i.createElement);t.exports=function(t){return u?i.createElement(t):{}}},function(t,r,n){var e=n(5),o=n(19),i=n(8);t.exports=e?function(t,r,n){return o.f(t,r,i(1,n))}:function(t,r,n){return t[r]=n,t}},function(t,r,n){var e=n(5),o=n(16),i=n(20),u=n(13),c=Object.defineProperty;r.f=e?c:function(t,r,n){if(i(t),r=u(r,!0),i(n),o)try{return c(t,r,n)}catch(t){}if("get"in n||"set"in n)throw TypeError("Accessors not supported");return"value"in n&&(t[r]=n.value),t}},function(t,r,n){var e=n(14);t.exports=function(t){if(!e(t))throw TypeError(String(t)+" is not an object");return t}},function(t,r,n){var e=n(3),o=n(22),i=n(18),u=n(15),c=n(25),a=n(26),f=n(27),s=f.get,l=f.enforce,p=String(a).split("toString");o("inspectSource",function(t){return a.call(t)}),(t.exports=function(t,r,n,o){var a=!!o&&!!o.unsafe,f=!!o&&!!o.enumerable,s=!!o&&!!o.noTargetGet;"function"==typeof n&&("string"!=typeof r||u(n,"name")||i(n,"name",r),l(n).source=p.join("string"==typeof r?r:"")),t!==e?(a?!s&&t[r]&&(f=!0):delete t[r],f?t[r]=n:i(t,r,n)):f?t[r]=n:c(r,n)})(Function.prototype,"toString",function(){return"function"==typeof this&&s(this).source||a.call(this)})},function(r,n,e){var o=e(23),i=e(24);(r.exports=function(r,n){return i[r]||(i[r]=n!==t?n:{})})("versions",[]).push({version:"3.3.6",mode:o?"pure":"global",copyright:"© 2019 Denis Pushkarev (zloirock.ru)"})},function(t,r){t.exports=!1},function(t,r,n){var e=n(3),o=n(25),i=e["__core-js_shared__"]||o("__core-js_shared__",{});t.exports=i},function(t,r,n){var e=n(3),o=n(18);t.exports=function(t,r){try{o(e,t,r)}catch(n){e[t]=r}return r}},function(t,r,n){var e=n(22);t.exports=e("native-function-to-string",Function.toString)},function(t,r,n){var e,o,i,u=n(28),c=n(3),a=n(14),f=n(18),s=n(15),l=n(29),p=n(31),g=c.WeakMap;if(u){var v=new g,h=v.get,d=v.has,x=v.set;e=function(t,r){return x.call(v,t,r),r},o=function(t){return h.call(v,t)||{}},i=function(t){return d.call(v,t)}}else{var y=l("state");p[y]=!0,e=function(t,r){return f(t,y,r),r},o=function(t){return s(t,y)?t[y]:{}},i=function(t){return s(t,y)}}t.exports={set:e,get:o,has:i,enforce:function(t){return i(t)?o(t):e(t,{})},getterFor:function(t){return function(r){var n;if(!a(r)||(n=o(r)).type!==t)throw TypeError("Incompatible receiver, "+t+" required");return n}}}},function(t,r,n){var e=n(3),o=n(26),i=e.WeakMap;t.exports="function"==typeof i&&/native code/.test(o.call(i))},function(t,r,n){var e=n(22),o=n(30),i=e("keys");t.exports=function(t){return i[t]||(i[t]=o(t))}},function(r,n){var e=0,o=Math.random();r.exports=function(r){return"Symbol("+String(r===t?"":r)+")_"+(++e+o).toString(36)}},function(t,r){t.exports={}},function(t,r,n){var e=n(15),o=n(33),i=n(4),u=n(19);t.exports=function(t,r){for(var n=o(r),c=u.f,a=i.f,f=0;fa;)e(c,n=r[a++])&&(~i(f,n)||f.push(n));return f}},function(t,r,n){var e=n(9),o=n(39),i=n(41),u=function(t){return function(r,n,u){var c,a=e(r),f=o(a.length),s=i(u,f);if(t&&n!=n){for(;f>s;)if((c=a[s++])!=c)return!0}else for(;f>s;s++)if((t||s in a)&&a[s]===n)return t||s||0;return!t&&-1}};t.exports={includes:u(!0),indexOf:u(!1)}},function(t,r,n){var e=n(40),o=Math.min;t.exports=function(t){return t>0?o(e(t),9007199254740991):0}},function(t,r){var n=Math.ceil,e=Math.floor;t.exports=function(t){return isNaN(t=+t)?0:(t>0?e:n)(t)}},function(t,r,n){var e=n(40),o=Math.max,i=Math.min;t.exports=function(t,r){var n=e(t);return n<0?o(n+r,0):i(n,r)}},function(t,r){t.exports=["constructor","hasOwnProperty","isPrototypeOf","propertyIsEnumerable","toLocaleString","toString","valueOf"]},function(t,r){r.f=Object.getOwnPropertySymbols},function(t,r,n){var e=n(6),o=/#|\.prototype\./,i=function(t,r){var n=c[u(t)];return n==f||n!=a&&("function"==typeof r?e(r):!!r)},u=i.normalize=function(t){return String(t).replace(o,".").toLowerCase()},c=i.data={},a=i.NATIVE="N",f=i.POLYFILL="P";t.exports=i},function(t,r,n){var e=n(11);t.exports=Array.isArray||function(t){return"Array"==e(t)}},function(t,r,n){var e=n(12);t.exports=function(t){return Object(e(t))}},function(t,r,n){var e=n(13),o=n(19),i=n(8);t.exports=function(t,r,n){var u=e(r);u in t?o.f(t,u,i(0,n)):t[u]=n}},function(r,n,e){var o=e(14),i=e(45),u=e(49)("species");r.exports=function(r,n){var e;return i(r)&&("function"!=typeof(e=r.constructor)||e!==Array&&!i(e.prototype)?o(e)&&null===(e=e[u])&&(e=t):e=t),new(e===t?Array:e)(0===n?0:n)}},function(t,r,n){var e=n(3),o=n(22),i=n(30),u=n(50),c=e.Symbol,a=o("wks");t.exports=function(t){return a[t]||(a[t]=u&&c[t]||(u?c:i)("Symbol."+t))}},function(t,r,n){var e=n(6);t.exports=!!Object.getOwnPropertySymbols&&!e(function(){return!String(Symbol())})},function(t,r,n){var e=n(6),o=n(49),i=n(52),u=o("species");t.exports=function(t){return i>=51||!e(function(){var r=[];return(r.constructor={})[u]=function(){return{foo:1}},1!==r[t](Boolean).foo})}},function(t,r,n){var e,o,i=n(3),u=n(53),c=i.process,a=c&&c.versions,f=a&&a.v8;f?o=(e=f.split("."))[0]+e[1]:u&&(!(e=u.match(/Edge\/(\d+)/))||e[1]>=74)&&(e=u.match(/Chrome\/(\d+)/))&&(o=e[1]),t.exports=o&&+o},function(t,r,n){var e=n(34);t.exports=e("navigator","userAgent")||""},function(t,r,n){var e=n(2),o=n(55),i=n(56);e({target:"Array",proto:!0},{copyWithin:o}),i("copyWithin")},function(r,n,e){var o=e(46),i=e(41),u=e(39),c=Math.min;r.exports=[].copyWithin||function(r,n){var e=o(this),a=u(e.length),f=i(r,a),s=i(n,a),l=arguments.length>2?arguments[2]:t,p=c((l===t?a:i(l,a))-s,a-f),g=1;for(s0;)s in e?e[f]=e[s]:delete e[f],f+=g,s+=g;return e}},function(r,n,e){var o=e(49),i=e(57),u=e(18),c=o("unscopables"),a=Array.prototype;a[c]==t&&u(a,c,i(null)),r.exports=function(t){a[c][t]=!0}},function(r,n,e){var o=e(20),i=e(58),u=e(42),c=e(31),a=e(60),f=e(17),s=e(29)("IE_PROTO"),l=function(){},p=function(){var t,r=f("iframe"),n=u.length;for(r.style.display="none",a.appendChild(r),r.src=String("javascript:"),(t=r.contentWindow.document).open(),t.write(" + View + + + + +
+ + + + + + diff --git a/packages/uni-cli-shared/lib/index.js b/packages/uni-cli-shared/lib/index.js index 771e8bcd2..00e57cdb5 100644 --- a/packages/uni-cli-shared/lib/index.js +++ b/packages/uni-cli-shared/lib/index.js @@ -40,7 +40,6 @@ const { getPlatformProject, isSupportSubPackages, getPlatforms, - getPlatformGlobal, getPlatformScss, getPlatformSass, runByHBuilderX, @@ -48,7 +47,6 @@ const { isInHBuilderXAlpha, getPlatformExts, getPlatformTarget, - getPlatformVue, getShadowCss, getPlatformCssVars, getPlatformCssnano, @@ -58,8 +56,7 @@ const { htmlPreprocessOptions, nvueJsPreprocessOptions, nvueCssPreprocessOptions, - nvueHtmlPreprocessOptions, - devtoolModuleFilenameTemplate + nvueHtmlPreprocessOptions } = require('./platform') module.exports = { @@ -93,8 +90,6 @@ module.exports = { getPlatformExts, getPlatformTarget, getPlatformProject, - getPlatformVue, - getPlatformGlobal, getShadowCss, getPlatformCssVars, getPlatformCssnano, @@ -109,6 +104,5 @@ module.exports = { htmlPreprocessOptions, nvueJsPreprocessOptions, nvueCssPreprocessOptions, - nvueHtmlPreprocessOptions, - devtoolModuleFilenameTemplate + nvueHtmlPreprocessOptions } diff --git a/packages/uni-cli-shared/lib/manifest.js b/packages/uni-cli-shared/lib/manifest.js index 2751be1ee..372775eb4 100644 --- a/packages/uni-cli-shared/lib/manifest.js +++ b/packages/uni-cli-shared/lib/manifest.js @@ -75,7 +75,7 @@ function getH5Options (manifestJson) { if (!h5.publicPath.endsWith('/')) { h5.publicPath = h5.publicPath + '/' } - } else { // 其他模式,启用 base + } else { // 其他模式,启用 base if (base.startsWith('./')) { // 在开发模式, publicPath 如果为 './' webpack-dev-server 匹配文件时会失败 h5.publicPath = base.substr(1) @@ -90,6 +90,11 @@ function getH5Options (manifestJson) { h5.devServer = h5.devServer || {} + // 插件修改 h5Options + global.uniPlugin.configureH5.forEach(configureH5 => { + configureH5(h5) + }) + return h5 } @@ -98,4 +103,4 @@ module.exports = { parseManifestJson, getNetworkTimeout, getH5Options -} +} diff --git a/packages/uni-cli-shared/lib/platform.js b/packages/uni-cli-shared/lib/platform.js index 57d2a6eeb..60e331fa7 100644 --- a/packages/uni-cli-shared/lib/platform.js +++ b/packages/uni-cli-shared/lib/platform.js @@ -2,7 +2,9 @@ const fs = require('fs') const path = require('path') const { - normalizePath + isInHBuilderX, + isInHBuilderXAlpha, + normalizeNodeModules } = require('./util') const { @@ -10,8 +12,6 @@ const { SASS } = require('./scss') -const uniRuntime = '@dcloudio/vue-cli-plugin-uni/packages/mp-vue' - function getShadowCss () { let tagName = 'page' if (process.env.UNI_PLATFORM === 'h5') { @@ -20,462 +20,21 @@ function getShadowCss () { return `${tagName}::after{position:fixed;content:'';left:-1000px;top:-1000px;-webkit-animation:shadow-preload .1s;-webkit-animation-delay:3s;animation:shadow-preload .1s;animation-delay:3s}@-webkit-keyframes shadow-preload{0%{background-image:url(https://cdn.dcloud.net.cn/img/shadow-grey.png)}100%{background-image:url(https://cdn.dcloud.net.cn/img/shadow-grey.png)}}@keyframes shadow-preload{0%{background-image:url(https://cdn.dcloud.net.cn/img/shadow-grey.png)}100%{background-image:url(https://cdn.dcloud.net.cn/img/shadow-grey.png)}}` } -function getCopyOption (file, options) { - if (file === 'wxcomponents') { - if (!options) { - options = {} - } - // 不拷贝vue,css(这些可能是 uni-migration 转换二来的) - options.ignore = ['**/*.vue', '**/*.css'] - } - if (path.isAbsolute(file)) { - if (fs.existsSync(file)) { - return Object.assign({ - from: file, - to: path.resolve(process.env.UNI_OUTPUT_DIR) - }, options) - } - } - const from = path.resolve(process.env.UNI_INPUT_DIR, file) - if (fs.existsSync(from)) { - return Object.assign({ - from, - to: path.resolve(process.env.UNI_OUTPUT_DIR, file) - }, options) - } -} - -function getCopyOptions (files, options = {}, subPackages = true) { - const copyOptions = [] - files.forEach(file => { - // 主包 - const copyOption = getCopyOption(file, options) - if (copyOption) { - copyOptions.push(copyOption) - } - if (subPackages) { - // 分包 - Object.keys(process.UNI_SUBPACKAGES).forEach(root => { // 分包静态资源 - const subCopyOption = getCopyOption(path.join(root, file), options) - if (subCopyOption) { - copyOptions.push(subCopyOption) - } - }) - } - }) - return copyOptions -} - -function getStaticCopyOptions (assetsDir) { - const ignore = [] - - Object.keys(PLATFORMS).forEach(platform => { - if (process.env.UNI_PLATFORM !== platform) { - ignore.push(platform + '/**/*') - } - }) - - return getCopyOptions( - [assetsDir], { - ignore - } - ) -} - -const PLATFORMS = { - 'h5': { - global: '', - exts: false, - vue: '@dcloudio/vue-cli-plugin-uni/packages/h5-vue', - compiler: false, - filterTag: 'wxs', - subPackages: false, - cssVars: { - '--status-bar-height': '0px' - }, - copyWebpackOptions ({ - assetsDir - }) { - const indexCssCopyOptions = [{ - from: require.resolve('@dcloudio/uni-h5/dist/index.css'), - to: assetsDir, - transform (content) { - if (process.env.NODE_ENV === 'production') { - return content + getShadowCss() - } - return content - } - }] - const VUE_APP_INDEX_CSS_HASH = process.env.VUE_APP_INDEX_CSS_HASH - if (VUE_APP_INDEX_CSS_HASH) { - const { - getH5Options - } = require('./manifest') - const { - template - } = getH5Options() - const to = path.join(assetsDir, `[name].${VUE_APP_INDEX_CSS_HASH}.[ext]`) - if (process.env.NODE_ENV === 'production') { - const templateContent = fs.readFileSync(template, { - encoding: 'utf8' - }) - if (/\bVUE_APP_INDEX_CSS_HASH\b/.test(templateContent)) { - indexCssCopyOptions[0].to = to - } - } else { - const indexCssCopyOption = Object.assign({}, indexCssCopyOptions[0]) - indexCssCopyOption.to = to - indexCssCopyOptions.push(indexCssCopyOption) - } - } - return [ - ...getStaticCopyOptions(assetsDir), - ...indexCssCopyOptions, - ...getCopyOptions(['hybrid/html']) - ] - } - }, - 'app-plus': { - global: 'wx', - exts: { - style: '.wxss', - template: '.wxml', - filter: '.wxs' - }, - filterTag: 'wxs', - subPackages: false, - cssVars: {}, - copyWebpackOptions ({ - assetsDir, - vueOptions - }) { - if ( - vueOptions && - vueOptions.pluginOptions && - vueOptions.pluginOptions['uni-app-plus'] && - vueOptions.pluginOptions['uni-app-plus']['view'] - ) { // app-view 无需拷贝资源(app-service 已经做了) - return [] - } - - const files = ['hybrid/html'] - let wxcomponents = [] - if ( - !process.env.UNI_USING_NATIVE && - !process.env.UNI_USING_V3 && - !process.env.UNI_USING_V3_NATIVE - ) { - wxcomponents = getCopyOptions(['wxcomponents'], { - to: path.resolve(process.env.UNI_OUTPUT_TMP_DIR, 'wxcomponents') - }) - } - let template = [] - let view = [] - if (process.env.UNI_USING_V3) { - view = getCopyOptions([ - require.resolve('@dcloudio/uni-app-plus/dist/view.css'), - require.resolve('@dcloudio/uni-app-plus/dist/view.umd.min.js') - ]) - template = [ - ...getCopyOptions([path.resolve(__dirname, '../template/common')]), - ...getCopyOptions([path.resolve(__dirname, '../template/v3')]) - ] - } - return [ - ...view, - ...template, - ...getStaticCopyOptions(assetsDir), - ...wxcomponents, - ...getCopyOptions(files) - ] - } - }, - 'mp-qq': { - global: 'wx', - exts: { - style: '.qss', - template: '.qml', - filter: '.wxs' - }, - filterTag: 'wxs', - subPackages: true, - cssVars: { - '--status-bar-height': '25px', - '--window-top': '0px', - '--window-bottom': '0px' - }, - project: 'project.config.json', - copyWebpackOptions ({ - assetsDir - }) { - return [ - ...getStaticCopyOptions(assetsDir), - ...getCopyOptions(['wxcomponents']) - ] - } - }, - 'mp-weixin': { - global: 'wx', - exts: { - style: '.wxss', - template: '.wxml', - filter: '.wxs' - }, - filterTag: 'wxs', - subPackages: true, - cssVars: { - '--status-bar-height': '25px', - '--window-top': '0px', - '--window-bottom': '0px' - }, - project: 'project.config.json', - copyWebpackOptions ({ - assetsDir, - manifestPlatformOptions - }) { - const files = [ - 'sitemap.json', - 'ext.json', - 'custom-tab-bar' - ] - if (manifestPlatformOptions.workers) { - files.push(manifestPlatformOptions.workers) - } - return [ - ...getStaticCopyOptions(assetsDir), - ...getCopyOptions(['wxcomponents']), - ...getCopyOptions(files, {}, false) - ] - } - }, - 'mp-baidu': { - global: 'swan', - exts: { - style: '.css', - template: '.swan', - filter: '.filter.js' - }, - filterTag: 'filter', - subPackages: true, - cssVars: { - '--status-bar-height': '25px', - '--window-top': '0px', - '--window-bottom': '0px' - }, - project: 'project.swan.json', - copyWebpackOptions ({ - assetsDir - }) { - return [ - ...getStaticCopyOptions(assetsDir), - ...getCopyOptions(['swancomponents']) - ] - } - }, - 'mp-alipay': { - global: 'my', - exts: { - style: '.acss', - template: '.axml', - filter: '.sjs' - }, - filterTag: 'sjs', - subPackages: true, - cssVars: { - '--status-bar-height': '25px', - '--window-top': '0px', - '--window-bottom': '0px' - }, - copyWebpackOptions ({ - assetsDir - }) { - return [ - ...getStaticCopyOptions(assetsDir), - ...getCopyOptions(['mycomponents']) - ] - } - }, - 'mp-toutiao': { - global: 'tt', - exts: { - style: '.ttss', - template: '.ttml' - }, - subPackages: false, - cssVars: { - '--status-bar-height': '25px', - '--window-top': '0px', - '--window-bottom': '0px' - }, - project: 'project.tt.json', - copyWebpackOptions ({ - assetsDir - }) { - return [ - ...getStaticCopyOptions(assetsDir), - ...getCopyOptions(['ttcomponents']) - ] - } - }, - 'quickapp': { - vue: '@dcloudio/vue-cli-plugin-uni/packages/h5-vue', - subPackages: false, - cssVars: { - '--status-bar-height': '25px', - '--window-top': '0px', - '--window-bottom': '0px' - }, - copyWebpackOptions ({ - assetsDir - }) { - return [ - ...getStaticCopyOptions(assetsDir), - ...getCopyOptions(['qacomponents']) - ] - } - } -} // 解决 vue-cli-service lint 时 UNI_PLATFORM 不存在 process.env.UNI_PLATFORM = process.env.UNI_PLATFORM || 'h5' -const platform = PLATFORMS[process.env.UNI_PLATFORM] - -const preprocessContext = {} - -Object.keys(PLATFORMS).forEach(platform => { - preprocessContext[platform.toUpperCase()] = false -}) - -preprocessContext[process.env.UNI_PLATFORM.toUpperCase()] = true - -preprocessContext['MP'] = false -preprocessContext['APP'] = false -preprocessContext['APP-PLUS-NVUE'] = false -preprocessContext['APP_PLUS_NVUE'] = false - -preprocessContext['APP-VUE'] = false -preprocessContext['APP_VUE'] = false -preprocessContext['APP-NVUE'] = false -preprocessContext['APP_NVUE'] = false - -if (process.env.UNI_PLATFORM === 'app-plus') { - preprocessContext['APP-VUE'] = true - preprocessContext['APP_VUE'] = true -} - -if (process.env.UNI_PLATFORM.indexOf('mp-') === 0) { - preprocessContext['MP'] = true -} - -if (process.env.UNI_PLATFORM.indexOf('app-') === 0) { - preprocessContext['APP'] = true -} - -if (process.UNI_SCRIPT_DEFINE && Object.keys(process.UNI_SCRIPT_DEFINE).length) { - Object.keys(process.UNI_SCRIPT_DEFINE).forEach(name => { - preprocessContext[name] = process.UNI_SCRIPT_DEFINE[name] - }) -} - -Object.keys(preprocessContext).forEach(platform => { - if (platform.indexOf('-') !== -1) { - preprocessContext[platform.replace(/-/g, '_')] = preprocessContext[platform] - } -}) - -const nvuePreprocessContext = Object.assign({}, preprocessContext, { - 'APP-VUE': false, - 'APP_VUE': false, - 'APP-NVUE': true, - 'APP_NVUE': true, - 'APP-PLUS-NVUE': true, - 'APP_PLUS_NVUE': true -}) - -const isInHBuilderX = fs.existsSync(path.resolve(process.env.UNI_CLI_CONTEXT, 'bin/uniapp-cli.js')) - -let isInHBuilderXAlpha = false - -if (isInHBuilderX) { - try { - if (require(path.resolve(process.env.UNI_CLI_CONTEXT, '../about/package.json')).alpha) { - isInHBuilderXAlpha = true - } - } catch (e) { - - } -} - -let sourceRoot = false - -function devtoolModuleFilenameTemplate (info) { - if (!sourceRoot) { - if (isInHBuilderX) { - sourceRoot = normalizePath(process.env.UNI_INPUT_DIR) - } else { - sourceRoot = normalizePath(process.env.UNI_CLI_CONTEXT) - } - } - let filePath = false - const absoluteResourcePath = normalizePath(info.absoluteResourcePath) - if ( - absoluteResourcePath.indexOf(sourceRoot) !== -1 && - ( - absoluteResourcePath.endsWith('.js') || - absoluteResourcePath.endsWith('.ts') - ) - ) { - filePath = normalizePath(path.relative(sourceRoot, absoluteResourcePath)) - if ( - filePath.indexOf('node_modules/@dcloudio') === 0 || - filePath.indexOf('node_modules/vue-loader') === 0 || - filePath.indexOf('node_modules/webpack') === 0 - ) { - filePath = false - } - } else if ( - !info.moduleId && - ( - absoluteResourcePath.endsWith('.vue') || - absoluteResourcePath.endsWith('.nvue') - ) - ) { - if ( - absoluteResourcePath.indexOf('src') !== 0 && - absoluteResourcePath.indexOf('node-modules') !== 0 - ) { - filePath = normalizePath(path.relative(sourceRoot, absoluteResourcePath)) - } else { - filePath = absoluteResourcePath - } - } - if ( - filePath && - filePath !== 'main.js' && - filePath !== 'main.ts' && - filePath !== 'src/main.js' && - filePath !== 'src/main.ts' - ) { - return `uni-app:///${filePath}` - } -} - -const NODE_MODULES_REGEX = /(\.\.\/)?node_modules/g - -function normalizeNodeModules (str) { - str = str.replace(NODE_MODULES_REGEX, 'node-modules') - if (process.env.UNI_PLATFORM === 'mp-alipay') { - str = str.replace('node-modules/@', 'node-modules/npm-scope-') - } - return str -} +const uniPluginOptions = global.uniPlugin.options || {} +const { + vueContext: preprocessContext, + nvueContext: nvuePreprocessContext +} = global.uniPlugin.preprocess +// TODO 暂时保留原有导出,减少影响,后续再整理一下 module.exports = { normalizeNodeModules, isInHBuilderX, isInHBuilderXAlpha, runByHBuilderX: isInHBuilderX || fs.existsSync(path.resolve(process.env.UNI_HBUILDERX_PLUGINS || '', 'weapp-tools')), - devtoolModuleFilenameTemplate, getFlexDirection (json) { let flexDir = 'column' if (json && json['nvue'] && json['nvue']['flex-direction']) { @@ -512,40 +71,28 @@ module.exports = { context: nvuePreprocessContext }, isSupportSubPackages () { - return platform.subPackages + return !!uniPluginOptions.subPackages }, getPlatforms () { - return Object.keys(PLATFORMS) - }, - getPlatformCopy () { - return platform.copyWebpackOptions - }, - getPlatformGlobal () { - return platform.global + return global.uniPlugin.platforms }, - getPlatformExts () { - return platform.exts + getPlatformGlobal () { // 目前仅mp-alipay有用 + return uniPluginOptions.global }, - getPlatformTarget () { - return platform.megalo + getPlatformExts () { // 小程序扩展名 + return uniPluginOptions.extnames }, - getPlatformProject () { - return platform.project + getPlatformProject () { // 开发工具项目配置名 + return uniPluginOptions.project }, getPlatformFilterTag () { - return platform.filterTag + return uniPluginOptions.filterTag }, getPlatformVue (vueOptions) { - if (process.env.UNI_PLATFORM === 'h5' && vueOptions && vueOptions.runtimeCompiler) { - return '@dcloudio/vue-cli-plugin-uni/packages/h5-vue/dist/vue.esm.js' - } - if (process.env.UNI_USING_COMPONENTS) { - return uniRuntime - } - return platform.vue + return uniPluginOptions.vue || '@dcloudio/vue-cli-plugin-uni/packages/mp-vue' }, getPlatformCssVars () { - return platform.cssVars + return uniPluginOptions.cssVars }, getPlatformCssnano () { return { diff --git a/packages/uni-cli-shared/lib/plugin.js b/packages/uni-cli-shared/lib/plugin.js new file mode 100644 index 000000000..4fe03c8e3 --- /dev/null +++ b/packages/uni-cli-shared/lib/plugin.js @@ -0,0 +1,127 @@ +const path = require('path') + +const initPreprocessContext = require('./preprocess') + +const Plugin = { + options: {}, + // 初步校验相关配置是否正确 + validate: [], // (platformOptions, manifestJson) {}, + // 以 H5 为基准的平台特殊配置 + configureH5: [], // (h5Options) {}, + // 链式修改 webpack config + chainWebpack: [], // (config, vueOptions, api) {}, + // 修改 webpack config + configureWebpack: [], // (config, vueOptions, api) {}, + // 配置额外的资源拷贝 + copyWebpackOptions: [] // (platformOptions, vueOptions) {} +} + +const PLUGIN_KEYS = Object.keys(Plugin) + +function initPlugin (plugin) { + let pluginApi + try { + pluginApi = require(path.join(plugin.id, (plugin.config.main || '/lib/uni.config.js'))) + } catch (e) { + console.warn(`缺少 uni.config.js `) + } + + pluginApi && PLUGIN_KEYS.forEach(name => { + if (pluginApi[name]) { + if (Array.isArray(Plugin[name])) { // hooks + Plugin[name].push(pluginApi[name]) + } else { // options + Object.assign(Plugin[name], pluginApi[name]) + } + } + }) +} + +const pluginRE = /^(uni-|@[\w-]+(\.)?[\w-]+\/uni-)/ + +const officialPlugins = [ + '@dcloudio/uni-app-plus', + '@dcloudio/uni-h5', + '@dcloudio/uni-mp-alipay', + '@dcloudio/uni-mp-baidu', + '@dcloudio/uni-mp-qq', + '@dcloudio/uni-mp-toutiao', + '@dcloudio/uni-mp-welink', + '@dcloudio/uni-mp-weixin' +] + +function resolvePlugins () { + const pkg = require(path.resolve(process.env.UNI_CLI_CONTEXT, 'package.json')) + return Object.keys(pkg.devDependencies || {}) + .concat(Object.keys(pkg.dependencies || {})) + .map(id => { + let isPlatformPlugin = false + if (id.startsWith('@dcloudio/')) { + if (!officialPlugins.includes(id)) { + return + } + isPlatformPlugin = true + } else { + isPlatformPlugin = pluginRE.test(id) + } + if (!isPlatformPlugin) { + return + } + try { + const pluginPkg = require(id + '/package.json') + const config = pluginPkg['uni-app'] + if (!config) { + return + } + if (!config.name) { + return console.warn(`${id}/package.json->uni-app 缺少 name 属性`) + } + return { + id, + name: config.name, + config + } + } catch (e) {} + }).filter(Boolean) +} + +function initExtends (name, plugin, plugins) { + const extendsPlatform = plugin.config['extends'] + if (extendsPlatform) { + if (extendsPlatform !== 'h5') { + console.error(`目前仅支持基于 h5 平台做扩展`) + process.exit(0) + } + const extendsPlugin = plugins.find(plugin => plugin.name === extendsPlatform) + if (!plugin) { + console.error(`缺少平台 ${extendsPlatform} 插件`) + process.exit(0) + } + process.env.UNI_SUB_PLATFORM = name + process.env.UNI_PLATFORM = extendsPlatform + initPlugin(extendsPlugin) + } +} + +module.exports = { + init () { + const plugins = resolvePlugins() + const plugin = plugins.find(plugin => plugin.name === process.env.UNI_PLATFORM) + if (!plugin) { + console.error(`缺少平台 ${process.env.UNI_PLATFORM} 插件`) + process.exit(0) + } + const name = plugin.name + + initExtends(name, plugin, plugins) + + initPlugin(plugin) + + Plugin.name = name + Plugin.config = plugin.config + Plugin.platforms = plugins.map(plugin => plugin.name) + Plugin.preprocess = initPreprocessContext(name, Plugin.platforms, process.UNI_SCRIPT_DEFINE) + + return Plugin + } +} diff --git a/packages/uni-cli-shared/lib/preprocess.js b/packages/uni-cli-shared/lib/preprocess.js new file mode 100644 index 000000000..d90a990d6 --- /dev/null +++ b/packages/uni-cli-shared/lib/preprocess.js @@ -0,0 +1,63 @@ +const DEFAULT_KEYS = [ + 'MP', + 'APP', + 'APP-PLUS-NVUE', + 'APP-VUE', + 'APP-NVUE' +] + +function normalize (name) { + return name.replace(/-/g, '_').toUpperCase() +} + +module.exports = function initPreprocess (name, platforms, userDefines = {}) { + const vueContext = {} // vue 值为true的条件编译 + const nvueContext = {} // nvue 值为true的条件编译 + + const defaultContext = {} + + const userDefineKeys = Object.keys(userDefines) + + platforms + .concat(DEFAULT_KEYS) + .concat(userDefineKeys) + .forEach(name => { + defaultContext[normalize(name)] = false + }) + + vueContext[normalize(name)] = true + + if (name === 'app-plus') { + vueContext['APP_VUE'] = true + + nvueContext['APP_PLUS'] = true + nvueContext['APP_NVUE'] = true + nvueContext['APP_PLUS_NVUE'] = true + } + + if (name.startsWith('mp-')) { + vueContext['MP'] = true + } + + if (name.startsWith('app-')) { + vueContext['APP'] = true + } + + userDefineKeys.forEach(name => { + if (userDefines[name]) { + const key = normalize(name) + vueContext[key] = nvueContext[key] = true + } + }) + + return { + vueContext: { + ...defaultContext, + ...vueContext + }, + nvueContext: { + ...defaultContext, + ...nvueContext + } + } +} diff --git a/packages/uni-cli-shared/lib/util.js b/packages/uni-cli-shared/lib/util.js index e3a2f4d5e..9ec87b30a 100644 --- a/packages/uni-cli-shared/lib/util.js +++ b/packages/uni-cli-shared/lib/util.js @@ -2,21 +2,18 @@ const path = require('path') const hash = require('hash-sum') const crypto = require('crypto') -const PLATFORMS = [ - 'h5', - 'app-plus', - 'mp-qq', - 'mp-weixin', - 'mp-baidu', - 'mp-alipay', - 'mp-toutiao', - 'quickapp' -] - const isWin = /^win/.test(process.platform) const normalizePath = path => (isWin ? path.replace(/\\/g, '/') : path) +let aboutPkg +try { + aboutPkg = require(path.resolve(__dirname, '../../../../../about/package.json')) +} catch (e) {} + +const isInHBuilderX = !!aboutPkg +const isInHBuilderXAlpha = !!(isInHBuilderX && aboutPkg.alpha) + function removeExt (str, ext) { if (ext) { const reg = new RegExp(ext.replace(/\./, '\\.') + '$') @@ -48,11 +45,11 @@ const camelizeRE = /-(\w)/g const camelize = cached((str) => { return str.replace(camelizeRE, (_, c) => c ? c.toUpperCase() : '') -}) +}) function capitalize (str) { return str.charAt(0).toUpperCase() + str.slice(1) -} +} const hyphenateRE = /\B([A-Z])/g @@ -91,7 +88,20 @@ function hasModule (name) { return false } +const NODE_MODULES_REGEX = /(\.\.\/)?node_modules/g + +function normalizeNodeModules (str) { + str = str.replace(NODE_MODULES_REGEX, 'node-modules') + if (process.env.UNI_PLATFORM === 'mp-alipay') { + str = str.replace('node-modules/@', 'node-modules/npm-scope-') + } + return str +} + module.exports = { + isInHBuilderX, + isInHBuilderXAlpha, + normalizeNodeModules, md5, hasOwn (obj, key) { return hasOwnProperty.call(obj, key) @@ -99,7 +109,7 @@ module.exports = { hasModule, parseStyle (style = {}) { Object.keys(style).forEach(name => { - if (PLATFORMS.includes(name)) { + if (global.uniPlugin.platforms.includes(name)) { if (name === process.env.UNI_PLATFORM) { Object.assign(style, style[name] || {}) } @@ -110,7 +120,7 @@ module.exports = { }, hashify, removeExt, - camelize, + camelize, capitalize, hyphenate, normalizePath, @@ -124,4 +134,4 @@ module.exports = { getTemplatePath () { return path.join(__dirname, '../template') } -} +} diff --git a/packages/uni-h5/package.json b/packages/uni-h5/package.json index 99ed386e4..b1c65ff51 100644 --- a/packages/uni-h5/package.json +++ b/packages/uni-h5/package.json @@ -1,22 +1,27 @@ -{ - "name": "@dcloudio/uni-h5", - "version": "2.0.0-alpha-26420200309002", - "description": "uni-app h5", - "main": "dist/index.umd.min.js", - "repository": { - "type": "git", - "url": "git+https://github.com/dcloudio/uni-app.git", - "directory": "packages/uni-h5" - }, - "scripts": { - "test": "echo \"Error: no test specified\" && exit 1" - }, - "author": "fxy060608", - "license": "Apache-2.0", - "dependencies": { - "base64-arraybuffer": "^0.2.0", - "intersection-observer": "^0.7.0", - "safe-area-insets": "^1.4.1" - }, - "gitHead": "84e9cb1ca1898054d161f1514efadd1ab24fd804" +{ + "name": "@dcloudio/uni-h5", + "version": "2.0.0-alpha-26420200309002", + "description": "uni-app h5", + "main": "dist/index.umd.min.js", + "repository": { + "type": "git", + "url": "git+https://github.com/dcloudio/uni-app.git", + "directory": "packages/uni-h5" + }, + "scripts": { + "test": "echo \"Error: no test specified\" && exit 1" + }, + "author": "fxy060608", + "license": "Apache-2.0", + "dependencies": { + "base64-arraybuffer": "^0.2.0", + "intersection-observer": "^0.7.0", + "safe-area-insets": "^1.4.1" + }, + "uni-app": { + "name": "h5", + "title": "H5", + "main": "lib/h5/uni.config.js" + }, + "gitHead": "84e9cb1ca1898054d161f1514efadd1ab24fd804" } diff --git a/packages/uni-migration/lib/index.js b/packages/uni-migration/lib/index.js index 30012f4df..efe17b1c9 100644 --- a/packages/uni-migration/lib/index.js +++ b/packages/uni-migration/lib/index.js @@ -9,7 +9,7 @@ const migraters = { 'mp-weixin': require('./mp-weixin') } -module.exports = function migrate(input, out, options = {}) { +module.exports = function migrate (input, out, options = {}) { options.platform = options.platform || 'mp-weixin' const migrater = migraters[options.platform] if (!migrater) { @@ -42,7 +42,7 @@ module.exports = function migrate(input, out, options = {}) { try { fs.copySync(src, dest) } catch (e) { - //ignore Source and destination must not be the same + // ignore Source and destination must not be the same } } } else { diff --git a/packages/uni-migration/lib/util.js b/packages/uni-migration/lib/util.js index 1b82bade7..54f2746c0 100644 --- a/packages/uni-migration/lib/util.js +++ b/packages/uni-migration/lib/util.js @@ -4,14 +4,14 @@ const normalizePath = path => (isWin ? path.replace(/\\/g, '/') : path) const camelizeRE = /-(\w)/g -function camelize(str) { +function camelize (str) { return str.replace(camelizeRE, (_, c) => c ? c.toUpperCase() : '') } /** * Capitalize a string. */ -function capitalize(str) { +function capitalize (str) { return str.charAt(0).toUpperCase() + str.slice(1) } diff --git a/packages/uni-migration/lib/validate.js b/packages/uni-migration/lib/validate.js index 0c0c2f14d..b3c74ba31 100644 --- a/packages/uni-migration/lib/validate.js +++ b/packages/uni-migration/lib/validate.js @@ -5,7 +5,7 @@ const migraters = { 'mp-weixin': require('./mp-weixin') } -module.exports = function validate(input, out, options) { +module.exports = function validate (input, out, options) { if (!fs.existsSync(input)) { return console.error(`错误: '${input}' 不存在`) } diff --git a/packages/uni-migration/lib/vant.js b/packages/uni-migration/lib/vant.js index 3abb57df6..8d14969b5 100644 --- a/packages/uni-migration/lib/vant.js +++ b/packages/uni-migration/lib/vant.js @@ -5,7 +5,7 @@ const { normalizePath } = require('./util') -module.exports = function patchVant(files, assets, out) { +module.exports = function patchVant (files, assets, out) { files.forEach(file => { const filepath = normalizePath(file.path) let changed = false diff --git a/packages/uni-mp-alipay/lib/uni.config.js b/packages/uni-mp-alipay/lib/uni.config.js new file mode 100644 index 000000000..75105b5fc --- /dev/null +++ b/packages/uni-mp-alipay/lib/uni.config.js @@ -0,0 +1,20 @@ +module.exports = { + options: { + global: 'my', + cssVars: { + '--status-bar-height': '25px', + '--window-top': '0px', + '--window-bottom': '0px' + }, + extnames: { + style: '.acss', + template: '.axml', + filter: '.sjs' + }, + filterTag: 'sjs', + subPackages: true + }, + copyWebpackOptions (platformOptions, vueOptions) { + return ['mycomponents'] + } +} diff --git a/packages/uni-mp-alipay/package.json b/packages/uni-mp-alipay/package.json index 3e3e3f46f..ad3178a2c 100644 --- a/packages/uni-mp-alipay/package.json +++ b/packages/uni-mp-alipay/package.json @@ -1,17 +1,21 @@ -{ - "name": "@dcloudio/uni-mp-alipay", - "version": "2.0.0-alpha-26420200309002", - "description": "uni-app mp-alipay", - "main": "dist/index.js", - "repository": { - "type": "git", - "url": "git+https://github.com/dcloudio/uni-app.git", - "directory": "packages/uni-mp-alipay" - }, - "scripts": { - "test": "echo \"Error: no test specified\" && exit 1" - }, - "author": "fxy060608", - "license": "Apache-2.0", - "gitHead": "84e9cb1ca1898054d161f1514efadd1ab24fd804" +{ + "name": "@dcloudio/uni-mp-alipay", + "version": "2.0.0-alpha-26420200309002", + "description": "uni-app mp-alipay", + "main": "dist/index.js", + "repository": { + "type": "git", + "url": "git+https://github.com/dcloudio/uni-app.git", + "directory": "packages/uni-mp-alipay" + }, + "scripts": { + "test": "echo \"Error: no test specified\" && exit 1" + }, + "author": "fxy060608", + "license": "Apache-2.0", + "uni-app": { + "name": "mp-alipay", + "title": "支付宝小程序" + }, + "gitHead": "84e9cb1ca1898054d161f1514efadd1ab24fd804" } diff --git a/packages/uni-mp-baidu/lib/uni.config.js b/packages/uni-mp-baidu/lib/uni.config.js new file mode 100644 index 000000000..ca6c6f873 --- /dev/null +++ b/packages/uni-mp-baidu/lib/uni.config.js @@ -0,0 +1,20 @@ +module.exports = { + options: { + cssVars: { + '--status-bar-height': '25px', + '--window-top': '0px', + '--window-bottom': '0px' + }, + extnames: { + style: '.css', + template: '.swan', + filter: '.filter.js' + }, + filterTag: 'filter', + project: 'project.swan.json', + subPackages: true + }, + copyWebpackOptions (platformOptions, vueOptions) { + return ['swancomponents'] + } +} diff --git a/packages/uni-mp-baidu/package.json b/packages/uni-mp-baidu/package.json index cec6a81a0..17581b9cd 100644 --- a/packages/uni-mp-baidu/package.json +++ b/packages/uni-mp-baidu/package.json @@ -1,17 +1,21 @@ -{ - "name": "@dcloudio/uni-mp-baidu", - "version": "2.0.0-alpha-26420200309002", - "description": "uni-app mp-baidu", - "main": "dist/index.js", - "repository": { - "type": "git", - "url": "git+https://github.com/dcloudio/uni-app.git", - "directory": "packages/uni-mp-baidu" - }, - "scripts": { - "test": "echo \"Error: no test specified\" && exit 1" - }, - "author": "fxy060608", - "license": "Apache-2.0", - "gitHead": "84e9cb1ca1898054d161f1514efadd1ab24fd804" +{ + "name": "@dcloudio/uni-mp-baidu", + "version": "2.0.0-alpha-26420200309002", + "description": "uni-app mp-baidu", + "main": "dist/index.js", + "repository": { + "type": "git", + "url": "git+https://github.com/dcloudio/uni-app.git", + "directory": "packages/uni-mp-baidu" + }, + "scripts": { + "test": "echo \"Error: no test specified\" && exit 1" + }, + "author": "fxy060608", + "license": "Apache-2.0", + "uni-app": { + "name": "mp-baidu", + "title": "百度小程序" + }, + "gitHead": "84e9cb1ca1898054d161f1514efadd1ab24fd804" } diff --git a/packages/uni-mp-qq/lib/uni.config.js b/packages/uni-mp-qq/lib/uni.config.js new file mode 100644 index 000000000..bf83c787a --- /dev/null +++ b/packages/uni-mp-qq/lib/uni.config.js @@ -0,0 +1,41 @@ +const fs = require('fs') +const path = require('path') + +const COMPONENTS_DIR_NAME = 'wxcomponents' + +module.exports = { + options: { + cssVars: { + '--status-bar-height': '25px', + '--window-top': '0px', + '--window-bottom': '0px' + }, + extnames: { + style: '.qss', + template: '.qml', + filter: '.wxs' + }, + filterTag: 'wxs', + project: 'project.config.json', + subPackages: true + }, + copyWebpackOptions (platformOptions, vueOptions) { + const copyOptions = [ + // 'sitemap.json', + // 'ext.json', + 'custom-tab-bar' + ] + const workers = platformOptions.workers + workers && copyOptions.push(workers) + + const wxcomponentsDir = path.resolve(process.env.UNI_INPUT_DIR, COMPONENTS_DIR_NAME) + if (fs.existsSync(wxcomponentsDir)) { + copyOptions.push({ + from: wxcomponentsDir, + to: COMPONENTS_DIR_NAME, + ignore: ['**/*.vue', '**/*.css'] // v3 会自动转换生成vue,css文件,需要过滤 + }) + } + return copyOptions + } +} diff --git a/packages/uni-mp-qq/package.json b/packages/uni-mp-qq/package.json index 31699720f..be9156140 100644 --- a/packages/uni-mp-qq/package.json +++ b/packages/uni-mp-qq/package.json @@ -1,17 +1,21 @@ -{ - "name": "@dcloudio/uni-mp-qq", - "version": "2.0.0-alpha-26420200309002", - "description": "uni-app mp-qq", - "main": "dist/index.js", - "repository": { - "type": "git", - "url": "git+https://github.com/dcloudio/uni-app.git", - "directory": "packages/uni-mp-qq" - }, - "scripts": { - "test": "echo \"Error: no test specified\" && exit 1" - }, - "author": "fxy060608", - "license": "Apache-2.0", - "gitHead": "84e9cb1ca1898054d161f1514efadd1ab24fd804" +{ + "name": "@dcloudio/uni-mp-qq", + "version": "2.0.0-alpha-26420200309002", + "description": "uni-app mp-qq", + "main": "dist/index.js", + "repository": { + "type": "git", + "url": "git+https://github.com/dcloudio/uni-app.git", + "directory": "packages/uni-mp-qq" + }, + "scripts": { + "test": "echo \"Error: no test specified\" && exit 1" + }, + "author": "fxy060608", + "license": "Apache-2.0", + "uni-app": { + "name": "mp-qq", + "title": "QQ小程序" + }, + "gitHead": "84e9cb1ca1898054d161f1514efadd1ab24fd804" } diff --git a/packages/uni-mp-toutiao/lib/uni.config.js b/packages/uni-mp-toutiao/lib/uni.config.js new file mode 100644 index 000000000..bcd354912 --- /dev/null +++ b/packages/uni-mp-toutiao/lib/uni.config.js @@ -0,0 +1,17 @@ +module.exports = { + options: { + cssVars: { + '--status-bar-height': '25px', + '--window-top': '0px', + '--window-bottom': '0px' + }, + extnames: { + style: '.ttss', + template: '.ttml' + }, + project: 'project.tt.json' + }, + copyWebpackOptions (platformOptions, vueOptions) { + return ['ttcomponents'] + } +} diff --git a/packages/uni-mp-toutiao/package.json b/packages/uni-mp-toutiao/package.json index 74318ca82..ad8bdd6e2 100644 --- a/packages/uni-mp-toutiao/package.json +++ b/packages/uni-mp-toutiao/package.json @@ -1,17 +1,21 @@ -{ - "name": "@dcloudio/uni-mp-toutiao", - "version": "2.0.0-alpha-26420200309002", - "description": "uni-app mp-toutiao", - "main": "dist/index.js", - "repository": { - "type": "git", - "url": "git+https://github.com/dcloudio/uni-app.git", - "directory": "packages/uni-mp-toutiao" - }, - "scripts": { - "test": "echo \"Error: no test specified\" && exit 1" - }, - "author": "fxy060608", - "license": "Apache-2.0", - "gitHead": "84e9cb1ca1898054d161f1514efadd1ab24fd804" +{ + "name": "@dcloudio/uni-mp-toutiao", + "version": "2.0.0-alpha-26420200309002", + "description": "uni-app mp-toutiao", + "main": "dist/index.js", + "repository": { + "type": "git", + "url": "git+https://github.com/dcloudio/uni-app.git", + "directory": "packages/uni-mp-toutiao" + }, + "scripts": { + "test": "echo \"Error: no test specified\" && exit 1" + }, + "author": "fxy060608", + "license": "Apache-2.0", + "uni-app": { + "name": "mp-toutiao", + "title": "字节跳动小程序" + }, + "gitHead": "84e9cb1ca1898054d161f1514efadd1ab24fd804" } diff --git a/packages/uni-mp-weixin/lib/uni.config.js b/packages/uni-mp-weixin/lib/uni.config.js new file mode 100644 index 000000000..c806a821b --- /dev/null +++ b/packages/uni-mp-weixin/lib/uni.config.js @@ -0,0 +1,41 @@ +const fs = require('fs') +const path = require('path') + +const COMPONENTS_DIR_NAME = 'wxcomponents' + +module.exports = { + options: { + cssVars: { + '--status-bar-height': '25px', + '--window-top': '0px', + '--window-bottom': '0px' + }, + extnames: { + style: '.wxss', + template: '.wxml', + filter: '.wxs' + }, + filterTag: 'wxs', + project: 'project.config.json', + subPackages: true + }, + copyWebpackOptions (platformOptions, vueOptions) { + const copyOptions = [ + 'sitemap.json', + 'ext.json', + 'custom-tab-bar' + ] + const workers = platformOptions.workers + workers && copyOptions.push(workers) + + const wxcomponentsDir = path.resolve(process.env.UNI_INPUT_DIR, COMPONENTS_DIR_NAME) + if (fs.existsSync(wxcomponentsDir)) { + copyOptions.push({ + from: wxcomponentsDir, + to: COMPONENTS_DIR_NAME, + ignore: ['**/*.vue', '**/*.css'] // v3 会自动转换生成vue,css文件,需要过滤 + }) + } + return copyOptions + } +} diff --git a/packages/uni-mp-weixin/package.json b/packages/uni-mp-weixin/package.json index 1206ee805..58f657afb 100644 --- a/packages/uni-mp-weixin/package.json +++ b/packages/uni-mp-weixin/package.json @@ -1,17 +1,21 @@ -{ - "name": "@dcloudio/uni-mp-weixin", - "version": "2.0.0-alpha-26420200309002", - "description": "uni-app mp-weixin", - "main": "dist/index.js", - "repository": { - "type": "git", - "url": "git+https://github.com/dcloudio/uni-app.git", - "directory": "packages/uni-mp-weixin" - }, - "scripts": { - "test": "echo \"Error: no test specified\" && exit 1" - }, - "author": "fxy060608", - "license": "Apache-2.0", - "gitHead": "84e9cb1ca1898054d161f1514efadd1ab24fd804" +{ + "name": "@dcloudio/uni-mp-weixin", + "version": "2.0.0-alpha-26420200309002", + "description": "uni-app mp-weixin", + "main": "dist/index.js", + "repository": { + "type": "git", + "url": "git+https://github.com/dcloudio/uni-app.git", + "directory": "packages/uni-mp-weixin" + }, + "scripts": { + "test": "echo \"Error: no test specified\" && exit 1" + }, + "author": "fxy060608", + "license": "Apache-2.0", + "uni-app": { + "name": "mp-weixin", + "title": "微信小程序" + }, + "gitHead": "84e9cb1ca1898054d161f1514efadd1ab24fd804" } diff --git a/packages/uni-quickapp/lib/chain-webpack.js b/packages/uni-quickapp/lib/chain-webpack.js index 96f3d1791..ff3b58ddc 100644 --- a/packages/uni-quickapp/lib/chain-webpack.js +++ b/packages/uni-quickapp/lib/chain-webpack.js @@ -1,14 +1,13 @@ const vueLoader = require('@dcloudio/uni-cli-shared/lib/vue-loader') -module.exports = config => { - +module.exports = config => { config.module .rule('vue') .test(vueLoader.test) .use('vue-loader') .loader(vueLoader.loader) .tap(options => Object.assign(options, vueLoader.options({}, { - quickapp: true, + quickapp: true }))) config.module diff --git a/packages/uni-quickapp/lib/compiler-module.js b/packages/uni-quickapp/lib/compiler-module.js index fde527550..7908b6c0e 100644 --- a/packages/uni-quickapp/lib/compiler-module.js +++ b/packages/uni-quickapp/lib/compiler-module.js @@ -1,5 +1,5 @@ module.exports = { - preTransformNode(el) { + preTransformNode (el) { if (el.tag === 'view') { // view 是最常用组件,直接映射为div标签,保证性能 el.tag = 'div' } diff --git a/packages/uni-quickapp/lib/configure-webpack.js b/packages/uni-quickapp/lib/configure-webpack.js index 4b92f72b4..2cbee1e45 100644 --- a/packages/uni-quickapp/lib/configure-webpack.js +++ b/packages/uni-quickapp/lib/configure-webpack.js @@ -27,37 +27,35 @@ const env = { const dslFilename = ('vue.' + (process.env.NODE_ENV === 'production' ? 'prod' : 'dev') + '.js') - const manifest = global.framework.manifest - -function genPriorities(entryPagePath) { - const o = [/^i18n\/.+\.json$/i, 'manifest.json', 'app.js', /^common\//i]; +function genPriorities (entryPagePath) { + const o = [/^i18n\/.+\.json$/i, 'manifest.json', 'app.js', /^common\//i] if (entryPagePath) { o.splice(3, 0, new RegExp(`^${entryPagePath}/$`), new RegExp(`^${entryPagePath}/.+`)) - } else console.error('未配置入口页面'); + } else console.error('未配置入口页面') return o } module.exports = { devtool: false, - entry() { + entry () { return process.UNI_ENTRY }, output: { - filename: '[name].js', - chunkFilename: '[name].js' + filename: '[name].js', + chunkFilename: '[name].js' }, optimization: { - splitChunks: false, - runtimeChunk: false + splitChunks: false, + runtimeChunk: false }, externals: { vue: 'Vue' }, module: { rules: [{ - //暂不考虑ts + // 暂不考虑ts test: path.resolve(process.env.UNI_INPUT_DIR, 'main.js'), use: [{ loader: path.resolve(__dirname, 'loader/main-loader') diff --git a/packages/uni-quickapp/lib/vue.config.js b/packages/uni-quickapp/lib/uni.config.js similarity index 100% rename from packages/uni-quickapp/lib/vue.config.js rename to packages/uni-quickapp/lib/uni.config.js diff --git a/packages/uni-quickapp/lib/validate.js b/packages/uni-quickapp/lib/validate.js index a3fd4f35b..43971c80d 100644 --- a/packages/uni-quickapp/lib/validate.js +++ b/packages/uni-quickapp/lib/validate.js @@ -1,7 +1,7 @@ const fs = require('fs') const path = require('path') -module.exports = function() { +module.exports = function () { const manifest = global.framework.manifest if (manifest.package === 'Bundle') { diff --git a/packages/uni-quickapp/package.json b/packages/uni-quickapp/package.json index d8588a6b1..b1158fb57 100644 --- a/packages/uni-quickapp/package.json +++ b/packages/uni-quickapp/package.json @@ -8,9 +8,9 @@ "url": "git+https://github.com/dcloudio/uni-app.git", "directory": "packages/uni-quickapp" }, - "files": [ - "bin", - "components", + "files": [ + "bin", + "components", "dist", "lib" ], @@ -20,6 +20,10 @@ "author": "fxy060608", "license": "Apache-2.0", "gitHead": "110501ffb0313e417858dec92acf07522d4ded00", + "uni-app": { + "name": "quickapp", + "title": "快应用" + }, "dependencies": { "@hap-toolkit/dsl-vue": "0.6.13", "@hap-toolkit/packager": "0.6.13", 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 2407578cd..d9fc96be9 100644 --- a/packages/vue-cli-plugin-hbuilderx/build/webpack.nvue.conf.js +++ b/packages/vue-cli-plugin-hbuilderx/build/webpack.nvue.conf.js @@ -8,10 +8,13 @@ const { getNVueMainEntry, nvueJsPreprocessOptions, nvueHtmlPreprocessOptions, - devtoolModuleFilenameTemplate, getTemplatePath } = require('@dcloudio/uni-cli-shared') +const { + devtoolModuleFilenameTemplate +} = require('../util') + const WebpackAppPlusNVuePlugin = process.env.UNI_USING_V3 ? require('../packages/webpack-app-plus-plugin') : require('../packages/webpack-app-plus-nvue-plugin') diff --git a/packages/vue-cli-plugin-hbuilderx/index.js b/packages/vue-cli-plugin-hbuilderx/index.js index 57bbaf18b..a6085f8fe 100644 --- a/packages/vue-cli-plugin-hbuilderx/index.js +++ b/packages/vue-cli-plugin-hbuilderx/index.js @@ -7,10 +7,6 @@ process.env.UNI_HBUILDERX_PLUGINS = process.env.UNI_HBUILDERX_PLUGINS || path.re require('./module-alias') -const { - devtoolModuleFilenameTemplate -} = require('@dcloudio/uni-cli-shared') - module.exports = (api, options) => { // 仅处理 app-plus 相关逻辑 if (process.env.UNI_PLATFORM !== 'app-plus') { return @@ -40,6 +36,10 @@ module.exports = (api, options) => { // 仅处理 app-plus 相关逻辑 plugins.push(new WebpackAppPlusPlugin()) + const { + devtoolModuleFilenameTemplate + } = require('./util') + // sourcemap 输出相对路径 output.devtoolModuleFilenameTemplate = devtoolModuleFilenameTemplate diff --git a/packages/vue-cli-plugin-hbuilderx/module-alias.js b/packages/vue-cli-plugin-hbuilderx/module-alias.js index d6d54afe7..a5f60812e 100644 --- a/packages/vue-cli-plugin-hbuilderx/module-alias.js +++ b/packages/vue-cli-plugin-hbuilderx/module-alias.js @@ -1,16 +1,20 @@ +const fs = require('fs') const path = require('path') const moduleAlias = require('module-alias') const { - hasModule, - isInHBuilderX -} = require('@dcloudio/uni-cli-shared') + hasModule +} = require('@dcloudio/uni-cli-shared/lib/util') + +const isInHBuilderX = fs.existsSync(path.resolve(process.env.UNI_CLI_CONTEXT, 'bin/uniapp-cli.js')) // nvue override moduleAlias.addAlias('weex-styler', path.resolve(__dirname, 'packages/weex-styler')) moduleAlias.addAlias('weex-template-compiler', path.resolve(__dirname, 'packages/weex-template-compiler')) -moduleAlias.addAlias('@vue/component-compiler-utils', require.resolve('@dcloudio/vue-cli-plugin-uni/packages/@vue/component-compiler-utils')) -moduleAlias.addAlias('@vue/component-compiler-utils/package.json', require.resolve('@dcloudio/vue-cli-plugin-uni/packages/@vue/component-compiler-utils/package.json')) +moduleAlias.addAlias('@vue/component-compiler-utils', require.resolve( + '@dcloudio/vue-cli-plugin-uni/packages/@vue/component-compiler-utils')) +moduleAlias.addAlias('@vue/component-compiler-utils/package.json', require.resolve( + '@dcloudio/vue-cli-plugin-uni/packages/@vue/component-compiler-utils/package.json')) if (isInHBuilderX) { moduleAlias.addAlias('typescript', path.resolve(process.env.UNI_HBUILDERX_PLUGINS, diff --git a/packages/vue-cli-plugin-hbuilderx/util.js b/packages/vue-cli-plugin-hbuilderx/util.js new file mode 100644 index 000000000..db25b888b --- /dev/null +++ b/packages/vue-cli-plugin-hbuilderx/util.js @@ -0,0 +1,64 @@ +const path = require('path') + +const { + normalizePath, + isInHBuilderX +} = require('@dcloudio/uni-cli-shared/lib/util') + +let sourceRoot = false + +function devtoolModuleFilenameTemplate (info) { + if (!sourceRoot) { + if (isInHBuilderX) { + sourceRoot = normalizePath(process.env.UNI_INPUT_DIR) + } else { + sourceRoot = normalizePath(process.env.UNI_CLI_CONTEXT) + } + } + let filePath = false + const absoluteResourcePath = normalizePath(info.absoluteResourcePath) + if ( + absoluteResourcePath.indexOf(sourceRoot) !== -1 && + ( + absoluteResourcePath.endsWith('.js') || + absoluteResourcePath.endsWith('.ts') + ) + ) { + filePath = normalizePath(path.relative(sourceRoot, absoluteResourcePath)) + if ( + filePath.indexOf('node_modules/@dcloudio') === 0 || + filePath.indexOf('node_modules/vue-loader') === 0 || + filePath.indexOf('node_modules/webpack') === 0 + ) { + filePath = false + } + } else if ( + !info.moduleId && + ( + absoluteResourcePath.endsWith('.vue') || + absoluteResourcePath.endsWith('.nvue') + ) + ) { + if ( + absoluteResourcePath.indexOf('src') !== 0 && + absoluteResourcePath.indexOf('node-modules') !== 0 + ) { + filePath = normalizePath(path.relative(sourceRoot, absoluteResourcePath)) + } else { + filePath = absoluteResourcePath + } + } + if ( + filePath && + filePath !== 'main.js' && + filePath !== 'main.ts' && + filePath !== 'src/main.js' && + filePath !== 'src/main.ts' + ) { + return `uni-app:///${filePath}` + } +} + +module.exports = { + devtoolModuleFilenameTemplate +} diff --git a/packages/vue-cli-plugin-uni/index.js b/packages/vue-cli-plugin-uni/index.js index e24c564e2..2ce41d534 100644 --- a/packages/vue-cli-plugin-uni/index.js +++ b/packages/vue-cli-plugin-uni/index.js @@ -22,7 +22,7 @@ module.exports = (api, options) => { if (process.env.UNI_PLATFORM === 'quickapp') { process.env.UNI_OUTPUT_DIR = path.resolve(process.env.UNI_OUTPUT_DIR, 'build') Object.assign(options, { - assetsDir, + assetsDir, parallel: false, outputDir: process.env.UNI_OUTPUT_DIR }) @@ -59,6 +59,13 @@ module.exports = (api, options) => { api.configureWebpack(require('./lib/configure-webpack')(platformOptions, manifestPlatformOptions, options, api)) api.chainWebpack(require('./lib/chain-webpack')(platformOptions, options, api)) + global.uniPlugin.configureWebpack.forEach(configureWebpack => { + api.configureWebpack(configureWebpack) + }) + global.uniPlugin.chainWebpack.forEach(chainWebpack => { + api.chainWebpack(chainWebpack) + }) + if ( process.env.UNI_PLATFORM === 'h5' || ( diff --git a/packages/vue-cli-plugin-uni/lib/configure-webpack.js b/packages/vue-cli-plugin-uni/lib/configure-webpack.js index 691432426..053bb5dcb 100644 --- a/packages/vue-cli-plugin-uni/lib/configure-webpack.js +++ b/packages/vue-cli-plugin-uni/lib/configure-webpack.js @@ -23,11 +23,14 @@ module.exports = function configureWebpack (platformOptions, manifestPlatformOpt runByHBuilderX, // 使用 HBuilderX 运行 isInHBuilderX, // 在 HBuilderX 的插件中 hasModule, - getPlatformVue, jsPreprocessOptions, htmlPreprocessOptions } = require('@dcloudio/uni-cli-shared') + const { + getPlatformVue + } = require('@dcloudio/uni-cli-shared/lib/platform') + const { getCopyWebpackPluginOptions } = require('./copy-webpack-options') @@ -184,9 +187,16 @@ module.exports = function configureWebpack (platformOptions, manifestPlatformOpt webpackConfig.resolve.modules = webpackConfig.resolve.modules.filter(module => module !== 'node_modules') - const plugins = [ - new CopyWebpackPlugin(getCopyWebpackPluginOptions(manifestPlatformOptions)) - ] + const plugins = [] + + const isAppView = process.env.UNI_PLATFORM === 'app-plus' && + vueOptions.pluginOptions && + vueOptions.pluginOptions['uni-app-plus'] && + vueOptions.pluginOptions['uni-app-plus']['view'] + + if (!isAppView) { // app-plus view不需要copy + plugins.push(new CopyWebpackPlugin(getCopyWebpackPluginOptions(manifestPlatformOptions, vueOptions))) + } if (process.UNI_SCRIPT_ENV && Object.keys(process.UNI_SCRIPT_ENV).length) { // custom define diff --git a/packages/vue-cli-plugin-uni/lib/copy-webpack-options.js b/packages/vue-cli-plugin-uni/lib/copy-webpack-options.js index 86cd00a44..f4ad42742 100644 --- a/packages/vue-cli-plugin-uni/lib/copy-webpack-options.js +++ b/packages/vue-cli-plugin-uni/lib/copy-webpack-options.js @@ -1,15 +1,69 @@ +const fs = require('fs') +const path = require('path') + const assetsDir = 'static' -function getCopyWebpackPluginOptions (manifestPlatformOptions, vueOptions) { - const { - getPlatformCopy - } = require('@dcloudio/uni-cli-shared/lib/platform') +function getAssetsCopyOption (from, options = {}) { + if (path.isAbsolute(from)) { + if (fs.existsSync(from)) { + return Object.assign({ + from, + to: path.resolve(process.env.UNI_OUTPUT_DIR) + }, options) + } + } + const to = from + from = path.resolve(process.env.UNI_INPUT_DIR, from) + if (fs.existsSync(from)) { + return Object.assign({ + from, + to: path.resolve(process.env.UNI_OUTPUT_DIR, to) + }, options) + } +} +// 暂未考虑动态添加static目录 +function getAssetsCopyOptions (assetsDir) { + const ignore = [] + + global.uniPlugin.platforms.forEach(platform => { + if (global.uniPlugin.name !== platform) { + ignore.push(platform + '/**/*') + } + }) + + const copyOptions = [] + // 主包静态资源 + const mainAssetsCopyOption = getAssetsCopyOption(assetsDir, { + ignore + }) + if (mainAssetsCopyOption) { + copyOptions.push(mainAssetsCopyOption) + } + // 分包静态资源 + process.UNI_SUBPACKAGES && Object.keys(process.UNI_SUBPACKAGES).forEach(root => { + const subAssetsCopyOption = getAssetsCopyOption(path.join(root, assetsDir), { + ignore + }) + if (subAssetsCopyOption) { + copyOptions.push(subAssetsCopyOption) + } + }) + return copyOptions +} - return getPlatformCopy()({ - assetsDir, - manifestPlatformOptions, - vueOptions +function getCopyWebpackPluginOptions (platformOptions, vueOptions) { + const copyOptions = getAssetsCopyOptions(assetsDir) + global.uniPlugin.copyWebpackOptions.forEach(copyWebpackOptions => { + const platformCopyOptions = copyWebpackOptions(platformOptions, vueOptions) || [] + platformCopyOptions.forEach(copyOption => { + if (typeof copyOption === 'string') { + copyOption = getAssetsCopyOption(copyOption) + } + copyOption && copyOptions.push(copyOption) + }) }) + console.log('debug:::', copyOptions) + return copyOptions } module.exports = { diff --git a/packages/vue-cli-plugin-uni/lib/env.js b/packages/vue-cli-plugin-uni/lib/env.js index 0d7245450..558a83bd0 100644 --- a/packages/vue-cli-plugin-uni/lib/env.js +++ b/packages/vue-cli-plugin-uni/lib/env.js @@ -3,6 +3,24 @@ const path = require('path') const mkdirp = require('mkdirp') const loaderUtils = require('loader-utils') +const defaultInputDir = 'src' +if (process.env.UNI_INPUT_DIR && process.env.UNI_INPUT_DIR.indexOf('./') === 0) { + process.env.UNI_INPUT_DIR = path.resolve(process.cwd(), process.env.UNI_INPUT_DIR) +} +process.env.UNI_INPUT_DIR = process.env.UNI_INPUT_DIR || path.resolve(process.cwd(), defaultInputDir) + +// 初始化全局插件对象 +global.uniPlugin = require('@dcloudio/uni-cli-shared/lib/plugin').init() +console.log('debug:::', global.uniPlugin) +const manifestJsonObj = require('@dcloudio/uni-cli-shared/lib/manifest').getManifestJson() +const platformOptions = manifestJsonObj[process.env.UNI_SUB_PLATFORM || process.env.UNI_PLATFORM] || {} +// 插件校验环境 +global.uniPlugin.validate.forEach(validate => { + validate(platformOptions, manifestJsonObj) +}) + +process.UNI_MANIFEST = manifestJsonObj + process.UNI_CLOUD = false process.UNI_CLOUD_TCB = false process.UNI_CLOUD_ALIYUN = false @@ -49,21 +67,16 @@ if ( } // 初始化环境变量 -const defaultInputDir = '../../../../src' const defaultOutputDir = '../../../../dist/' + (process.env.NODE_ENV === 'production' ? 'build' : 'dev') + '/' + - process.env.UNI_PLATFORM + (process.env.UNI_SUB_PLATFORM || process.env.UNI_PLATFORM) -if (process.env.UNI_INPUT_DIR && process.env.UNI_INPUT_DIR.indexOf('./') === 0) { - process.env.UNI_INPUT_DIR = path.resolve(process.cwd(), process.env.UNI_INPUT_DIR) -} if (process.env.UNI_OUTPUT_DIR && process.env.UNI_OUTPUT_DIR.indexOf('./') === 0) { process.env.UNI_OUTPUT_DIR = path.resolve(process.cwd(), process.env.UNI_OUTPUT_DIR) } process.env.UNI_PLATFORM = process.env.UNI_PLATFORM || 'h5' process.env.VUE_APP_PLATFORM = process.env.UNI_PLATFORM -process.env.UNI_INPUT_DIR = process.env.UNI_INPUT_DIR || path.resolve(__dirname, defaultInputDir) process.env.UNI_OUTPUT_DIR = process.env.UNI_OUTPUT_DIR || path.resolve(__dirname, defaultOutputDir) if (process.env.UNI_PLATFORM === 'app-plus') { @@ -82,9 +95,7 @@ const { normalizePath, isSupportSubPackages, runByHBuilderX, - // isInHBuilderXAlpha, - getPagesJson, - getManifestJson + getPagesJson } = require('@dcloudio/uni-cli-shared') const pagesJsonObj = getPagesJson() @@ -107,11 +118,7 @@ if (Array.isArray(pagesJsonObj.subPackages)) { }) } -const manifestJsonObj = getManifestJson() -const platformOptions = manifestJsonObj[process.env.UNI_PLATFORM] || {} - process.UNI_PAGES = pagesJsonObj -process.UNI_MANIFEST = manifestJsonObj if (manifestJsonObj.debug) { process.env.VUE_APP_DEBUG = true @@ -178,7 +185,7 @@ if (process.env.UNI_PLATFORM === 'app-plus') { ) { delete process.env.UNI_USING_CACHE if (platformOptions.renderer === 'native') { - process.env.UNI_USING_V3_NATIVE = true + process.env.UNI_USING_V3_NATIVE = true } else { process.env.UNI_USING_V3 = true platformOptions.usingComponents = true @@ -269,7 +276,8 @@ const needWarning = !platformOptions.usingComponents || usingComponentsAbsent let hasNVue = false // 输出编译器版本等信息 if (process.env.UNI_USING_NATIVE || process.env.UNI_USING_V3_NATIVE) { - console.log('当前nvue编译模式' + (process.env.UNI_USING_V3_NATIVE ? '(v3)' : '') + ':' + (isNVueCompiler ? 'uni-app' : 'weex') + + console.log('当前nvue编译模式' + (process.env.UNI_USING_V3_NATIVE ? '(v3)' : '') + ':' + (isNVueCompiler ? 'uni-app' + : 'weex') + ' 。编译模式差异见:https://ask.dcloud.net.cn/article/36074') } else if (process.env.UNI_PLATFORM !== 'h5' && process.env.UNI_PLATFORM !== 'quickapp') { try { diff --git a/packages/webpack-uni-mp-loader/lib/template-new.js b/packages/webpack-uni-mp-loader/lib/template-new.js deleted file mode 100644 index 37673e881..000000000 --- a/packages/webpack-uni-mp-loader/lib/template-new.js +++ /dev/null @@ -1,73 +0,0 @@ -const path = require('path') - -const loaderUtils = require('loader-utils') - -const { - removeExt, - getPlatformExts, - getShadowTemplate -} = require('@dcloudio/uni-cli-shared') - -const { - getJsonFile, - getWXComponents, - updateSpecialMethods, - getGlobalUsingComponents, - updateGenericComponents, // resolve - updateComponentGenerics, // define - updateUsingGlobalComponents -} = require('@dcloudio/uni-cli-shared/lib/cache') - -const { - getPlatformFilterTag -} = require('@dcloudio/uni-cli-shared/lib/platform') - -const { - normalizeNodeModules -} = require('./shared') - -const templateExt = getPlatformExts().template -const filterTagName = getPlatformFilterTag() || '' - -function parseFilterModules (filterModules) { - if (filterModules) { - return JSON.parse(Buffer.from(filterModules, 'base64').toString('ascii')) - } - return {} -} - -module.exports = function (content) { - this.cacheable && this.cacheable() - - const vueLoaderOptions = this.loaders.find(loader => loader.ident === 'vue-loader-options') - if (vueLoaderOptions) { - const globalUsingComponents = getGlobalUsingComponents() - const realResourcePath = path.relative(process.env.UNI_INPUT_DIR, this.resourcePath) - const resourcePath = normalizeNodeModules(removeExt(realResourcePath) + templateExt) - const wxComponents = getWXComponents(resourcePath.replace(path.extname(resourcePath), '')) - - const params = loaderUtils.parseQuery(this.resourceQuery) - /* eslint-disable no-mixed-operators */ - const filterModules = parseFilterModules(params && params['filter-modules']) - Object.assign(vueLoaderOptions.options.compilerOptions, { - mp: { - platform: process.env.UNI_PLATFORM - }, - filterModules, - filterTagName, - resourcePath, - emitFile: this.emitFile, - wxComponents, - getJsonFile, - getShadowTemplate, - updateSpecialMethods, - globalUsingComponents, - updateGenericComponents, - updateComponentGenerics, - updateUsingGlobalComponents - }) - } else { - throw new Error('vue-loader-options parse error') - } - return content -} diff --git a/packages/webpack-uni-mp-loader/lib/template.bak.js b/packages/webpack-uni-mp-loader/lib/template.bak.js new file mode 100644 index 000000000..27556018f --- /dev/null +++ b/packages/webpack-uni-mp-loader/lib/template.bak.js @@ -0,0 +1,69 @@ +const path = require('path') + +const qs = require('querystring') + +const { + md5, + removeExt, + getPlatformExts +} = require('@dcloudio/uni-cli-shared') + +const { + cacheTemplate, + cacheCompilerOptions, + getPlatformTarget +} = require('./shared') + +const templateExt = getPlatformExts().template +module.exports = function (content) { + if (process.env.UNI_USING_COMPONENTS) { + return require('./template-new').call(this, content) + } + this.cacheable && this.cacheable() + + const realResourcePath = path.relative(process.env.UNI_INPUT_DIR, this.resourcePath) + + if (process.env.UNI_USING_COMPONENTS) { + // 向 uni-template-compier 传递 emitFile + const vueLoaderOptions = this.loaders.find(loader => loader.ident === 'vue-loader-options') + if (vueLoaderOptions) { + Object.assign(vueLoaderOptions.options.compilerOptions, { + resourcePath: removeExt(realResourcePath) + templateExt, + emitFile: this.emitFile + }) + } else { + throw new Error('vue-loader-options parse error') + } + } else { + if (!content.trim()) { + content = '' + } + + cacheTemplate(realResourcePath, content) + + const query = qs.parse(this.resourceQuery.slice(1)) + + const { + id + } = query + + const compilerOptions = { + scopeId: query.scoped ? `data-v-${id}` : null, + target: getPlatformTarget(), + md5: md5(content.trim() + process.env.UNI_PLATFORM), + realResourcePath + } + + cacheCompilerOptions(realResourcePath, compilerOptions) + + // 向 vue-loader templateLoader 传递 compilerOptions + const vueLoaderOptions = this.loaders.find(loader => loader.ident === 'vue-loader-options') + if (vueLoaderOptions) { + Object.assign(vueLoaderOptions.options.compilerOptions, compilerOptions) + } else { + throw new Error('vue-loader-options parse error') + } + } + + return content +} diff --git a/packages/webpack-uni-mp-loader/lib/template.js b/packages/webpack-uni-mp-loader/lib/template.js index 27556018f..37673e881 100644 --- a/packages/webpack-uni-mp-loader/lib/template.js +++ b/packages/webpack-uni-mp-loader/lib/template.js @@ -1,69 +1,73 @@ const path = require('path') -const qs = require('querystring') +const loaderUtils = require('loader-utils') const { - md5, removeExt, - getPlatformExts + getPlatformExts, + getShadowTemplate } = require('@dcloudio/uni-cli-shared') const { - cacheTemplate, - cacheCompilerOptions, - getPlatformTarget + getJsonFile, + getWXComponents, + updateSpecialMethods, + getGlobalUsingComponents, + updateGenericComponents, // resolve + updateComponentGenerics, // define + updateUsingGlobalComponents +} = require('@dcloudio/uni-cli-shared/lib/cache') + +const { + getPlatformFilterTag +} = require('@dcloudio/uni-cli-shared/lib/platform') + +const { + normalizeNodeModules } = require('./shared') const templateExt = getPlatformExts().template -module.exports = function (content) { - if (process.env.UNI_USING_COMPONENTS) { - return require('./template-new').call(this, content) +const filterTagName = getPlatformFilterTag() || '' + +function parseFilterModules (filterModules) { + if (filterModules) { + return JSON.parse(Buffer.from(filterModules, 'base64').toString('ascii')) } + return {} +} + +module.exports = function (content) { this.cacheable && this.cacheable() - const realResourcePath = path.relative(process.env.UNI_INPUT_DIR, this.resourcePath) + const vueLoaderOptions = this.loaders.find(loader => loader.ident === 'vue-loader-options') + if (vueLoaderOptions) { + const globalUsingComponents = getGlobalUsingComponents() + const realResourcePath = path.relative(process.env.UNI_INPUT_DIR, this.resourcePath) + const resourcePath = normalizeNodeModules(removeExt(realResourcePath) + templateExt) + const wxComponents = getWXComponents(resourcePath.replace(path.extname(resourcePath), '')) - if (process.env.UNI_USING_COMPONENTS) { - // 向 uni-template-compier 传递 emitFile - const vueLoaderOptions = this.loaders.find(loader => loader.ident === 'vue-loader-options') - if (vueLoaderOptions) { - Object.assign(vueLoaderOptions.options.compilerOptions, { - resourcePath: removeExt(realResourcePath) + templateExt, - emitFile: this.emitFile - }) - } else { - throw new Error('vue-loader-options parse error') - } + const params = loaderUtils.parseQuery(this.resourceQuery) + /* eslint-disable no-mixed-operators */ + const filterModules = parseFilterModules(params && params['filter-modules']) + Object.assign(vueLoaderOptions.options.compilerOptions, { + mp: { + platform: process.env.UNI_PLATFORM + }, + filterModules, + filterTagName, + resourcePath, + emitFile: this.emitFile, + wxComponents, + getJsonFile, + getShadowTemplate, + updateSpecialMethods, + globalUsingComponents, + updateGenericComponents, + updateComponentGenerics, + updateUsingGlobalComponents + }) } else { - if (!content.trim()) { - content = '' - } - - cacheTemplate(realResourcePath, content) - - const query = qs.parse(this.resourceQuery.slice(1)) - - const { - id - } = query - - const compilerOptions = { - scopeId: query.scoped ? `data-v-${id}` : null, - target: getPlatformTarget(), - md5: md5(content.trim() + process.env.UNI_PLATFORM), - realResourcePath - } - - cacheCompilerOptions(realResourcePath, compilerOptions) - - // 向 vue-loader templateLoader 传递 compilerOptions - const vueLoaderOptions = this.loaders.find(loader => loader.ident === 'vue-loader-options') - if (vueLoaderOptions) { - Object.assign(vueLoaderOptions.options.compilerOptions, compilerOptions) - } else { - throw new Error('vue-loader-options parse error') - } + throw new Error('vue-loader-options parse error') } - return content } -- GitLab