From 0dea10de9a3f03cb03ac4352428d1dad5d930f27 Mon Sep 17 00:00:00 2001 From: wangcuijuan Date: Thu, 15 Oct 2020 21:00:07 +0800 Subject: [PATCH] =?UTF-8?q?=E8=A1=A5=E5=85=85switchbar=E9=83=A8=E5=88=86?= =?UTF-8?q?=E6=8F=90=E4=BA=A4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- examples/mpx-webview/H5/webviewbridge.min.js | 4 ++-- .../lib/runtime/components/web/mpx-web-view.vue | 6 +++++- .../dist/webviewbridge.esm.browser.js | 16 ++++++---------- .../dist/webviewbridge.esm.browser.min.js | 4 ++-- .../webview-bridge/dist/webviewbridge.esm.js | 14 +++++--------- packages/webview-bridge/dist/webviewbridge.js | 14 +++++--------- .../webview-bridge/dist/webviewbridge.min.js | 4 ++-- packages/webview-bridge/src/common.js | 10 +++------- 8 files changed, 30 insertions(+), 42 deletions(-) diff --git a/examples/mpx-webview/H5/webviewbridge.min.js b/examples/mpx-webview/H5/webviewbridge.min.js index f982aa030b..11aacb5a3c 100644 --- a/examples/mpx-webview/H5/webviewbridge.min.js +++ b/examples/mpx-webview/H5/webviewbridge.min.js @@ -1,6 +1,6 @@ /** - * mpxjs webview bridge v2.5.30 + * mpxjs webview bridge v2.6.11 * (c) 2020 @mpxjs team * @license Apache */ -var e,o;e=this,o=function(){"use strict";function e(e,o,a){return o in e?Object.defineProperty(e,o,{value:a,enumerable:!0,configurable:!0,writable:!0}):e[o]=a,e}var o,a={wx:"https://res.wx.qq.com/open/js/jweixin-1.3.2.js",qq:"https://qqq.gtimg.cn/miniprogram/webview_jssdk/qqjssdk-1.0.0.js",ali:"https://appx/web-view.min.js",baidu:"https://b.bdstatic.com/searchbox/icms/searchbox/js/swan-2.0.4.js",tt:"https://s3.pstatp.com/toutiao/tmajssdk/jssdk.js"},t={wx:["wx","miniProgram"],qq:["qq","miniProgram"],ali:["my"],baidu:["swan","webView"],tt:["tt","miniProgram"]},n=null;window.addEventListener("message",function(e){(o=e.data===e.origin)&&(n="web",window.parent.postMessage({type:"load",detail:{load:!0}},"*"))},!1);var r=navigator.userAgent;r.indexOf("AlipayClient")>-1?n="ali":r.indexOf("miniProgram")>-1||r.indexOf("miniprogram")>-1?n=r.indexOf("QQ")>-1?"qq":"wx":r.indexOf("swan")>-1?n="baidu":r.indexOf("toutiao")>-1?n="tt":window.parent.postMessage({type:"load",detail:{load:!0}},"*");var i={},c=function(e){var a={navigateTo:"navigateTo",navigateBack:"navigateBack",switchTab:"switchTab",reLaunch:"reLaunch",redirectTo:"redirectTo",getEnv:"getEnv",postMessage:"postMessage",getLoadError:"getLoadError",onMessage:{ali:!0}},r=function(r){var c="string"==typeof a[r]?a[r]:!!a[r][n]&&("string"==typeof a[r][n]?a[r][n]:r);i[r]=function(){for(var a=arguments.length,i=new Array(a),s=0;s1&&void 0!==arguments[1]?arguments[1]:{},a=o.time,t=void 0===a?5e3:a,n=o.crossOrigin,r=void 0!==n&&n;return Promise.race([new Promise(function(o,a){var t=document.createElement("script");t.type="text/javascript",t.async="async",r&&(t.crossOrigin="anonymous"),t.onload=t.onreadystatechange=function(){this.readyState&&!/^(loaded|complete)$/.test(this.readyState)||(o(),t.onload=t.onreadystatechange=null)},t.onerror=function(){a(new Error("load ".concat(e," error"))),t.onerror=null},t.src=e,document.getElementsByTagName("head")[0].appendChild(t)}),new Promise(function(o,a){setTimeout(function(){a(new Error("load ".concat(e," timeout")))},t)})])}(a[n]):Promise.reject(new Error("\u672a\u627e\u5230\u5bf9\u5e94\u7684sdk"));c(e)}(),function(o){for(var a=1;a-1?n="ali":r.indexOf("miniProgram")>-1||r.indexOf("miniprogram")>-1?n=r.indexOf("QQ")>-1?"qq":"wx":r.indexOf("swan")>-1?n="baidu":r.indexOf("toutiao")>-1?n="tt":window.parent.postMessage({type:"load",detail:{load:!0}},"*");var i={},c=function(e){var a={navigateTo:"navigateTo",navigateBack:"navigateBack",switchTab:"switchTab",reLaunch:"reLaunch",redirectTo:"redirectTo",getEnv:"getEnv",postMessage:"postMessage",getLoadError:"getLoadError",onMessage:{ali:!0}},r=function(r){var c="string"==typeof a[r]?a[r]:!!a[r][n]&&("string"==typeof a[r][n]?a[r][n]:r);i[r]=function(){for(var a=arguments.length,i=new Array(a),s=0;s1&&void 0!==arguments[1]?arguments[1]:{},a=o.time,t=void 0===a?5e3:a,n=o.crossOrigin,r=void 0!==n&&n;return Promise.race([new Promise(function(o,a){var t=document.createElement("script");t.type="text/javascript",t.async="async",r&&(t.crossOrigin="anonymous"),t.onload=t.onreadystatechange=function(){this.readyState&&!/^(loaded|complete)$/.test(this.readyState)||(o(),t.onload=t.onreadystatechange=null)},t.onerror=function(){a(new Error("load ".concat(e," error"))),t.onerror=null},t.src=e,document.getElementsByTagName("head")[0].appendChild(t)}),new Promise(function(o,a){setTimeout(function(){a(new Error("load ".concat(e," timeout")))},t)})])}(a[n]):Promise.reject(new Error("\u672a\u627e\u5230\u5bf9\u5e94\u7684sdk"));c(e)}(),function(o){for(var a=1;a import getInnerListeners, { getCustomEvent } from './getInnerListeners' - import { redirectTo, navigateTo, navigateBack, reLaunch } from '@mpxjs/api-proxy/src/web/api/index' + import { redirectTo, navigateTo, navigateBack, reLaunch, switchTab} from '@mpxjs/api-proxy/src/web/api/index' const eventLoad = 'load' const eventError = 'error' @@ -81,6 +81,10 @@ this.isActived = false redirectTo(value) break + case 'switchTab': + this.isActived = false + switchTab(value) + break case 'reLaunch': this.isActived = false reLaunch(value) diff --git a/packages/webview-bridge/dist/webviewbridge.esm.browser.js b/packages/webview-bridge/dist/webviewbridge.esm.browser.js index 9a1b92f1dd..814d645243 100644 --- a/packages/webview-bridge/dist/webviewbridge.esm.browser.js +++ b/packages/webview-bridge/dist/webviewbridge.esm.browser.js @@ -1,5 +1,5 @@ /** - * mpxjs webview bridge v2.5.30 + * mpxjs webview bridge v2.6.11 * (c) 2020 @mpxjs team * @license Apache */ @@ -92,7 +92,7 @@ if (systemUA.indexOf('AlipayClient') > -1) { }, '*'); } -function postMessage(type, data) { +function postMessage (type, data) { let eventType; switch (type) { case 'postMessage': @@ -107,9 +107,9 @@ function postMessage(type, data) { case 'redirectTo': eventType = 'redirectTo'; break - // case 'switchTab': - // eventType = 'switchTab' - // break + case 'switchTab': + eventType = 'switchTab'; + break case 'reLaunch': eventType = 'reLaunch'; break @@ -171,11 +171,7 @@ const getWebviewApi = (sdkReady) => { webviewApiList[item] = (...args) => { if (env === 'web') { - if (item === 'switchTab') { - console.log(`此环境不支持 ${item} 方法`); - return - } - return postMessage(item, ...args); + return postMessage(item, ...args) // console.log(`${env}小程序不支持 ${item} 方法`) } else { return sdkReady.then(() => { diff --git a/packages/webview-bridge/dist/webviewbridge.esm.browser.min.js b/packages/webview-bridge/dist/webviewbridge.esm.browser.min.js index 018d1deb9a..13a41de9b6 100644 --- a/packages/webview-bridge/dist/webviewbridge.esm.browser.min.js +++ b/packages/webview-bridge/dist/webviewbridge.esm.browser.min.js @@ -1,6 +1,6 @@ /** - * mpxjs webview bridge v2.5.30 + * mpxjs webview bridge v2.6.11 * (c) 2020 @mpxjs team * @license Apache */ -const e={wx:"https://res.wx.qq.com/open/js/jweixin-1.3.2.js",qq:"https://qqq.gtimg.cn/miniprogram/webview_jssdk/qqjssdk-1.0.0.js",ali:"https://appx/web-view.min.js",baidu:"https://b.bdstatic.com/searchbox/icms/searchbox/js/swan-2.0.4.js",tt:"https://s3.pstatp.com/toutiao/tmajssdk/jssdk.js"},a={wx:["wx","miniProgram"],qq:["qq","miniProgram"],ali:["my"],baidu:["swan","webView"],tt:["tt","miniProgram"]};let o,t=null;window.addEventListener("message",e=>{(o=e.data===e.origin)&&(t="web",window.parent.postMessage({type:"load",detail:{load:!0}},"*"))},!1);let i=navigator.userAgent;function n(e,a){let t;switch(e){case"postMessage":t="message";break;case"navigateBack":t="navigateBack";break;case"navigateTo":t="navigateTo";break;case"redirectTo":t="redirectTo";break;case"reLaunch":t="reLaunch";break;case"getEnv":t="getEnv"}"getEnv"!==e&&o?window.parent.postMessage({type:t,detail:{data:a}},"*"):a({miniprogram:!1})}i.indexOf("AlipayClient")>-1?t="ali":i.indexOf("miniProgram")>-1||i.indexOf("miniprogram")>-1?t=i.indexOf("QQ")>-1?"qq":"wx":i.indexOf("swan")>-1?t="baidu":i.indexOf("toutiao")>-1?t="tt":window.parent.postMessage({type:"load",detail:{load:!0}},"*");const r={};const s=e=>{const o={navigateTo:"navigateTo",navigateBack:"navigateBack",switchTab:"switchTab",reLaunch:"reLaunch",redirectTo:"redirectTo",getEnv:"getEnv",postMessage:"postMessage",getLoadError:"getLoadError",onMessage:{ali:!0}};for(let i in o){const s="string"==typeof o[i]?o[i]:!!o[i][t]&&("string"==typeof o[i][t]?o[i][t]:i);r[i]=(...o)=>"web"===t?"switchTab"===i?void console.log(`\u6b64\u73af\u5883\u4e0d\u652f\u6301 ${i} \u65b9\u6cd5`):n(i,...o):e.then(()=>{if("getLoadError"===s)return Promise.resolve("js\u52a0\u8f7d\u5b8c\u6210");a[t].reduce((e,a)=>e[a],window)[s](...o)})}};(()=>{if(null===t)return console.log("mpxjs/webview: \u672a\u8bc6\u522b\u7684\u73af\u5883\uff0c\u5f53\u524d\u4ec5\u652f\u6301 \u5fae\u4fe1\u3001\u652f\u4ed8\u5b9d\u3001\u767e\u5ea6\u3001\u5934\u6761 QQ \u5c0f\u7a0b\u5e8f"),void s();const a=window[t]?Promise.resolve():e[t]?function(e,{time:a=5e3,crossOrigin:o=!1}={}){return Promise.race([new Promise((a,t)=>{let i=document.createElement("script");i.type="text/javascript",i.async="async",o&&(i.crossOrigin="anonymous"),i.onload=i.onreadystatechange=function(){this.readyState&&!/^(loaded|complete)$/.test(this.readyState)||(a(),i.onload=i.onreadystatechange=null)},i.onerror=function(){t(new Error(`load ${e} error`)),i.onerror=null},i.src=e,document.getElementsByTagName("head")[0].appendChild(i)}),new Promise((o,t)=>{setTimeout(()=>{t(new Error(`load ${e} timeout`))},a)})])}(e[t]):Promise.reject(new Error("\u672a\u627e\u5230\u5bf9\u5e94\u7684sdk"));s(a)})();const c={...r,getAdvancedApi:(e,o)=>{if(!o)return void console.log("\u9700\u8981\u63d0\u4f9b\u6302\u8f7d\u65b9\u6cd5\u7684mpx\u5bf9\u8c61");if(window.wx){if(e)return void console.log("\b\u5fae\u4fe1\u73af\u5883\u4e0b\u9700\u8981\u914d\u7f6ewx.config\u624d\u80fd\u6302\u8f7d\u65b9\u6cd5");window.wx.config(e)}const i={checkJSApi:{wx:"checkJSApi"},chooseImage:{wx:"chooseImage",baidu:"chooseImage",ali:"chooseImage"},previewImage:{wx:"previewImage",baidu:"previewImage",ali:"previewImage"},uploadImage:{wx:"uploadImage"},downloadImage:{wx:"downloadImage"},getLocalImgData:{wx:"getLocalImgData"},startRecord:{wx:"startRecord"},stopRecord:{wx:"stopRecord"},onVoiceRecordEnd:{wx:"onVoiceRecordEnd"},playVoice:{wx:"playVoice"},pauseVoice:{wx:"pauseVoice"},stopVoice:{wx:"stopVoice"},onVoicePlayEnd:{wx:"onVoicePlayEnd"},uploadVoice:{wx:"uploadVoice"},downloadVoice:{wx:"downloadVoice"},translateVoice:{wx:"translateVoice"},getNetworkType:{wx:"getNetworkType",baidu:"getNetworkType",ali:"getNetworkType"},openLocation:{wx:"openLocation",baidu:"openLocation",ali:"openLocation"},getLocation:{wx:"getLocation",baidu:"getLocation",ali:"getLocation"},startSearchBeacons:{wx:"startSearchBeacons"},stopSearchBeacons:{wx:"stopSearchBeacons"},onSearchBeacons:{wx:"onSearchBeacons"},scanQRCode:{wx:"scanQRCode"},chooseCard:{wx:"chooseCard"},addCard:{wx:"addCard"},openCard:{wx:"openCard"},alert:{ali:"alert"},showLoading:{ali:"showLoading"},hideLoading:{ali:"hideLoading"},setStorage:{ali:"setStorage"},getStorage:{ali:"getStorage"},removeStorage:{ali:"removeStorage"},clearStorage:{ali:"clearStorage"},getStorageInfo:{ali:"getStorageInfo"},startShare:{ali:"startShare"},tradePay:{ali:"tradePay"},onMessage:{ali:"onMessage"}};for(let e in i)o[e]=(...o)=>{i[e][t]?(console.log(i[e][t],"ApiList[item][env]"),window[a[t][0]][i[e][t]](...o)):console.error(`\u6b64\u73af\u5883\u4e0d\u652f\u6301${e}\u65b9\u6cd5`)}},mpxEnv:t},{navigateTo:d,navigateBack:g,switchTab:w,reLaunch:l,redirectTo:p,getEnv:m,postMessage:x,getLoadError:h}=r,{getAdvancedApi:u}=c;export default c;export{u as getAdvancedApi,m as getEnv,h as getLoadError,g as navigateBack,d as navigateTo,x as postMessage,l as reLaunch,p as redirectTo,w as switchTab}; \ No newline at end of file +const e={wx:"https://res.wx.qq.com/open/js/jweixin-1.3.2.js",qq:"https://qqq.gtimg.cn/miniprogram/webview_jssdk/qqjssdk-1.0.0.js",ali:"https://appx/web-view.min.js",baidu:"https://b.bdstatic.com/searchbox/icms/searchbox/js/swan-2.0.4.js",tt:"https://s3.pstatp.com/toutiao/tmajssdk/jssdk.js"},a={wx:["wx","miniProgram"],qq:["qq","miniProgram"],ali:["my"],baidu:["swan","webView"],tt:["tt","miniProgram"]};let o,t=null;window.addEventListener("message",e=>{(o=e.data===e.origin)&&(t="web",window.parent.postMessage({type:"load",detail:{load:!0}},"*"))},!1);let i=navigator.userAgent;function n(e,a){let t;switch(e){case"postMessage":t="message";break;case"navigateBack":t="navigateBack";break;case"navigateTo":t="navigateTo";break;case"redirectTo":t="redirectTo";break;case"switchTab":t="switchTab";break;case"reLaunch":t="reLaunch";break;case"getEnv":t="getEnv"}"getEnv"!==e&&o?window.parent.postMessage({type:t,detail:{data:a}},"*"):a({miniprogram:!1})}i.indexOf("AlipayClient")>-1?t="ali":i.indexOf("miniProgram")>-1||i.indexOf("miniprogram")>-1?t=i.indexOf("QQ")>-1?"qq":"wx":i.indexOf("swan")>-1?t="baidu":i.indexOf("toutiao")>-1?t="tt":window.parent.postMessage({type:"load",detail:{load:!0}},"*");const r={};const s=e=>{const o={navigateTo:"navigateTo",navigateBack:"navigateBack",switchTab:"switchTab",reLaunch:"reLaunch",redirectTo:"redirectTo",getEnv:"getEnv",postMessage:"postMessage",getLoadError:"getLoadError",onMessage:{ali:!0}};for(let i in o){const s="string"==typeof o[i]?o[i]:!!o[i][t]&&("string"==typeof o[i][t]?o[i][t]:i);r[i]=(...o)=>"web"===t?n(i,...o):e.then(()=>{if("getLoadError"===s)return Promise.resolve("js\u52a0\u8f7d\u5b8c\u6210");a[t].reduce((e,a)=>e[a],window)[s](...o)})}};(()=>{if(null===t)return console.log("mpxjs/webview: \u672a\u8bc6\u522b\u7684\u73af\u5883\uff0c\u5f53\u524d\u4ec5\u652f\u6301 \u5fae\u4fe1\u3001\u652f\u4ed8\u5b9d\u3001\u767e\u5ea6\u3001\u5934\u6761 QQ \u5c0f\u7a0b\u5e8f"),void s();const a=window[t]?Promise.resolve():e[t]?function(e,{time:a=5e3,crossOrigin:o=!1}={}){return Promise.race([new Promise((a,t)=>{let i=document.createElement("script");i.type="text/javascript",i.async="async",o&&(i.crossOrigin="anonymous"),i.onload=i.onreadystatechange=function(){this.readyState&&!/^(loaded|complete)$/.test(this.readyState)||(a(),i.onload=i.onreadystatechange=null)},i.onerror=function(){t(new Error(`load ${e} error`)),i.onerror=null},i.src=e,document.getElementsByTagName("head")[0].appendChild(i)}),new Promise((o,t)=>{setTimeout(()=>{t(new Error(`load ${e} timeout`))},a)})])}(e[t]):Promise.reject(new Error("\u672a\u627e\u5230\u5bf9\u5e94\u7684sdk"));s(a)})();const c={...r,getAdvancedApi:(e,o)=>{if(!o)return void console.log("\u9700\u8981\u63d0\u4f9b\u6302\u8f7d\u65b9\u6cd5\u7684mpx\u5bf9\u8c61");if(window.wx){if(e)return void console.log("\b\u5fae\u4fe1\u73af\u5883\u4e0b\u9700\u8981\u914d\u7f6ewx.config\u624d\u80fd\u6302\u8f7d\u65b9\u6cd5");window.wx.config(e)}const i={checkJSApi:{wx:"checkJSApi"},chooseImage:{wx:"chooseImage",baidu:"chooseImage",ali:"chooseImage"},previewImage:{wx:"previewImage",baidu:"previewImage",ali:"previewImage"},uploadImage:{wx:"uploadImage"},downloadImage:{wx:"downloadImage"},getLocalImgData:{wx:"getLocalImgData"},startRecord:{wx:"startRecord"},stopRecord:{wx:"stopRecord"},onVoiceRecordEnd:{wx:"onVoiceRecordEnd"},playVoice:{wx:"playVoice"},pauseVoice:{wx:"pauseVoice"},stopVoice:{wx:"stopVoice"},onVoicePlayEnd:{wx:"onVoicePlayEnd"},uploadVoice:{wx:"uploadVoice"},downloadVoice:{wx:"downloadVoice"},translateVoice:{wx:"translateVoice"},getNetworkType:{wx:"getNetworkType",baidu:"getNetworkType",ali:"getNetworkType"},openLocation:{wx:"openLocation",baidu:"openLocation",ali:"openLocation"},getLocation:{wx:"getLocation",baidu:"getLocation",ali:"getLocation"},startSearchBeacons:{wx:"startSearchBeacons"},stopSearchBeacons:{wx:"stopSearchBeacons"},onSearchBeacons:{wx:"onSearchBeacons"},scanQRCode:{wx:"scanQRCode"},chooseCard:{wx:"chooseCard"},addCard:{wx:"addCard"},openCard:{wx:"openCard"},alert:{ali:"alert"},showLoading:{ali:"showLoading"},hideLoading:{ali:"hideLoading"},setStorage:{ali:"setStorage"},getStorage:{ali:"getStorage"},removeStorage:{ali:"removeStorage"},clearStorage:{ali:"clearStorage"},getStorageInfo:{ali:"getStorageInfo"},startShare:{ali:"startShare"},tradePay:{ali:"tradePay"},onMessage:{ali:"onMessage"}};for(let e in i)o[e]=(...o)=>{i[e][t]?(console.log(i[e][t],"ApiList[item][env]"),window[a[t][0]][i[e][t]](...o)):console.error(`\u6b64\u73af\u5883\u4e0d\u652f\u6301${e}\u65b9\u6cd5`)}},mpxEnv:t},{navigateTo:d,navigateBack:g,switchTab:w,reLaunch:l,redirectTo:p,getEnv:m,postMessage:x,getLoadError:h}=r,{getAdvancedApi:u}=c;export default c;export{u as getAdvancedApi,m as getEnv,h as getLoadError,g as navigateBack,d as navigateTo,x as postMessage,l as reLaunch,p as redirectTo,w as switchTab}; \ No newline at end of file diff --git a/packages/webview-bridge/dist/webviewbridge.esm.js b/packages/webview-bridge/dist/webviewbridge.esm.js index 5d8706d7db..4136ab0a0f 100644 --- a/packages/webview-bridge/dist/webviewbridge.esm.js +++ b/packages/webview-bridge/dist/webviewbridge.esm.js @@ -1,5 +1,5 @@ /** - * mpxjs webview bridge v2.5.30 + * mpxjs webview bridge v2.6.11 * (c) 2020 @mpxjs team * @license Apache */ @@ -150,9 +150,10 @@ function postMessage(type, data) { case 'redirectTo': eventType = 'redirectTo'; break; - // case 'switchTab': - // eventType = 'switchTab' - // break + + case 'switchTab': + eventType = 'switchTab'; + break; case 'reLaunch': eventType = 'reLaunch'; @@ -224,11 +225,6 @@ var getWebviewApi = function getWebviewApi(sdkReady) { } if (env === 'web') { - if (item === 'switchTab') { - console.log("\u6B64\u73AF\u5883\u4E0D\u652F\u6301 ".concat(item, " \u65B9\u6CD5")); - return; - } - return postMessage.apply(void 0, [item].concat(args)); // console.log(`${env}小程序不支持 ${item} 方法`) } else { return sdkReady.then(function () { diff --git a/packages/webview-bridge/dist/webviewbridge.js b/packages/webview-bridge/dist/webviewbridge.js index 68af031b0e..3cf7cd70c9 100644 --- a/packages/webview-bridge/dist/webviewbridge.js +++ b/packages/webview-bridge/dist/webviewbridge.js @@ -1,5 +1,5 @@ /** - * mpxjs webview bridge v2.5.30 + * mpxjs webview bridge v2.6.11 * (c) 2020 @mpxjs team * @license Apache */ @@ -156,9 +156,10 @@ case 'redirectTo': eventType = 'redirectTo'; break; - // case 'switchTab': - // eventType = 'switchTab' - // break + + case 'switchTab': + eventType = 'switchTab'; + break; case 'reLaunch': eventType = 'reLaunch'; @@ -230,11 +231,6 @@ } if (env === 'web') { - if (item === 'switchTab') { - console.log("\u6B64\u73AF\u5883\u4E0D\u652F\u6301 ".concat(item, " \u65B9\u6CD5")); - return; - } - return postMessage.apply(void 0, [item].concat(args)); // console.log(`${env}小程序不支持 ${item} 方法`) } else { return sdkReady.then(function () { diff --git a/packages/webview-bridge/dist/webviewbridge.min.js b/packages/webview-bridge/dist/webviewbridge.min.js index f982aa030b..11aacb5a3c 100644 --- a/packages/webview-bridge/dist/webviewbridge.min.js +++ b/packages/webview-bridge/dist/webviewbridge.min.js @@ -1,6 +1,6 @@ /** - * mpxjs webview bridge v2.5.30 + * mpxjs webview bridge v2.6.11 * (c) 2020 @mpxjs team * @license Apache */ -var e,o;e=this,o=function(){"use strict";function e(e,o,a){return o in e?Object.defineProperty(e,o,{value:a,enumerable:!0,configurable:!0,writable:!0}):e[o]=a,e}var o,a={wx:"https://res.wx.qq.com/open/js/jweixin-1.3.2.js",qq:"https://qqq.gtimg.cn/miniprogram/webview_jssdk/qqjssdk-1.0.0.js",ali:"https://appx/web-view.min.js",baidu:"https://b.bdstatic.com/searchbox/icms/searchbox/js/swan-2.0.4.js",tt:"https://s3.pstatp.com/toutiao/tmajssdk/jssdk.js"},t={wx:["wx","miniProgram"],qq:["qq","miniProgram"],ali:["my"],baidu:["swan","webView"],tt:["tt","miniProgram"]},n=null;window.addEventListener("message",function(e){(o=e.data===e.origin)&&(n="web",window.parent.postMessage({type:"load",detail:{load:!0}},"*"))},!1);var r=navigator.userAgent;r.indexOf("AlipayClient")>-1?n="ali":r.indexOf("miniProgram")>-1||r.indexOf("miniprogram")>-1?n=r.indexOf("QQ")>-1?"qq":"wx":r.indexOf("swan")>-1?n="baidu":r.indexOf("toutiao")>-1?n="tt":window.parent.postMessage({type:"load",detail:{load:!0}},"*");var i={},c=function(e){var a={navigateTo:"navigateTo",navigateBack:"navigateBack",switchTab:"switchTab",reLaunch:"reLaunch",redirectTo:"redirectTo",getEnv:"getEnv",postMessage:"postMessage",getLoadError:"getLoadError",onMessage:{ali:!0}},r=function(r){var c="string"==typeof a[r]?a[r]:!!a[r][n]&&("string"==typeof a[r][n]?a[r][n]:r);i[r]=function(){for(var a=arguments.length,i=new Array(a),s=0;s1&&void 0!==arguments[1]?arguments[1]:{},a=o.time,t=void 0===a?5e3:a,n=o.crossOrigin,r=void 0!==n&&n;return Promise.race([new Promise(function(o,a){var t=document.createElement("script");t.type="text/javascript",t.async="async",r&&(t.crossOrigin="anonymous"),t.onload=t.onreadystatechange=function(){this.readyState&&!/^(loaded|complete)$/.test(this.readyState)||(o(),t.onload=t.onreadystatechange=null)},t.onerror=function(){a(new Error("load ".concat(e," error"))),t.onerror=null},t.src=e,document.getElementsByTagName("head")[0].appendChild(t)}),new Promise(function(o,a){setTimeout(function(){a(new Error("load ".concat(e," timeout")))},t)})])}(a[n]):Promise.reject(new Error("\u672a\u627e\u5230\u5bf9\u5e94\u7684sdk"));c(e)}(),function(o){for(var a=1;a-1?n="ali":r.indexOf("miniProgram")>-1||r.indexOf("miniprogram")>-1?n=r.indexOf("QQ")>-1?"qq":"wx":r.indexOf("swan")>-1?n="baidu":r.indexOf("toutiao")>-1?n="tt":window.parent.postMessage({type:"load",detail:{load:!0}},"*");var i={},c=function(e){var a={navigateTo:"navigateTo",navigateBack:"navigateBack",switchTab:"switchTab",reLaunch:"reLaunch",redirectTo:"redirectTo",getEnv:"getEnv",postMessage:"postMessage",getLoadError:"getLoadError",onMessage:{ali:!0}},r=function(r){var c="string"==typeof a[r]?a[r]:!!a[r][n]&&("string"==typeof a[r][n]?a[r][n]:r);i[r]=function(){for(var a=arguments.length,i=new Array(a),s=0;s1&&void 0!==arguments[1]?arguments[1]:{},a=o.time,t=void 0===a?5e3:a,n=o.crossOrigin,r=void 0!==n&&n;return Promise.race([new Promise(function(o,a){var t=document.createElement("script");t.type="text/javascript",t.async="async",r&&(t.crossOrigin="anonymous"),t.onload=t.onreadystatechange=function(){this.readyState&&!/^(loaded|complete)$/.test(this.readyState)||(o(),t.onload=t.onreadystatechange=null)},t.onerror=function(){a(new Error("load ".concat(e," error"))),t.onerror=null},t.src=e,document.getElementsByTagName("head")[0].appendChild(t)}),new Promise(function(o,a){setTimeout(function(){a(new Error("load ".concat(e," timeout")))},t)})])}(a[n]):Promise.reject(new Error("\u672a\u627e\u5230\u5bf9\u5e94\u7684sdk"));c(e)}(),function(o){for(var a=1;a { webviewApiList[item] = (...args) => { if (env === 'web') { - if (item === 'switchTab') { - console.log(`此环境不支持 ${item} 方法`) - return - } return postMessage(item, ...args) // console.log(`${env}小程序不支持 ${item} 方法`) } else {