1 line
5.3 KiB
JavaScript
1 line
5.3 KiB
JavaScript
(global["webpackJsonp"]=global["webpackJsonp"]||[]).push([["uni_modules/uni-upgrade-center-app/pages/upgrade-popup"],{"6bc0":function(e,t,n){"use strict";(function(e){var i=n("4ea4");Object.defineProperty(t,"__esModule",{value:!0}),t.default=void 0;var a,r=i(n("2eee")),o=i(n("c973")),c="UNI_ADMIN_UPGRADE_CENTER_LOCAL_FILE_PATH",u=null;var s={data:function(){return{installForBeforeFilePath:"",installed:!1,installing:!1,downloadSuccess:!1,downloading:!1,downLoadPercent:0,downloadedSize:0,packageFileSize:0,tempFilePath:"",title:"更新日志",contents:"",is_mandatory:!1,subTitle:"发现新版本",downLoadBtnTextiOS:"立即跳转更新",downLoadBtnText:"立即下载更新",downLoadingText:"安装包下载中,请稍后"}},onLoad:function(t){var n=t.local_storage_key;if(!n)return console.error("local_storage_key为空,请检查后重试"),void e.navigateBack();var i=e.getStorageSync(n);if(!i)return console.error("安装包信息为空,请检查后重试"),void e.navigateBack();var a=["version","url","type"];for(var r in i)if(-1!==a.indexOf(r)&&!i[r])return console.error("参数 ".concat(r," 必填,请检查后重试")),void e.navigateBack();Object.assign(this,i),this.checkLocalStoragePackage()},onBackPress:function(){if(this.is_mandatory)return!0;u&&u.abort()},onHide:function(){a=null},computed:{isWGT:function(){return"wgt"===this.type},isiOS:function(){return!this.isWGT&&this.platform.includes("iOS")},isAppStore:function(){return this.isiOS||!this.isiOS&&!this.isWGT&&-1===this.url.indexOf(".apk")}},methods:{checkLocalStoragePackage:function(){var t=e.getStorageSync(c);if(t){var n=t.version,i=t.savedFilePath,a=t.installed;a||0!==function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:"0",t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:"0";e=String(e).split("."),t=String(t).split(".");for(var n=Math.min(e.length,t.length),i=0,a=0;a<n;a++){var r=Number(e[a]),o=Number(t[a]);if(r>o){i=1;break}if(r<o){i=-1;break}}if(0===i&&e.length!==t.length)for(var c=e.length>t.length,u=c?e:t,s=n;s<u.length;s++){var l=Number(u[s]);if(l>0){i=c?1:-1;break}}return i}(n,this.version)?this.deleteSavedFile(i):(this.downloadSuccess=!0,this.installForBeforeFilePath=i,this.tempFilePath=i)}},closeUpdate:function(){var t=this;return(0,o.default)(r.default.mark((function n(){return r.default.wrap((function(n){while(1)switch(n.prev=n.next){case 0:if(!t.downloading){n.next=5;break}if(!t.is_mandatory){n.next=3;break}return n.abrupt("return",e.showToast({title:"下载中,请稍后……",icon:"none",duration:500}));case 3:return e.showModal({title:"是否取消下载?",cancelText:"否",confirmText:"是",success:function(t){t.confirm&&(u&&u.abort(),e.navigateBack())}}),n.abrupt("return");case 5:if(!t.downloadSuccess||!t.tempFilePath){n.next=10;break}return n.next=8,t.saveFile(t.tempFilePath,t.version);case 8:return e.navigateBack(),n.abrupt("return");case 10:e.navigateBack();case 11:case"end":return n.stop()}}),n)})))()},updateApp:function(){var e=this;this.checkStoreScheme().catch((function(){e.downloadPackage()}))},checkStoreScheme:function(){var e=(this.store_list||[]).filter((function(e){return e.enable}));return e&&e.length?(e.sort((function(e,t){return t.priority-e.priority})).map((function(e){return e.scheme})).reduce((function(e,t,n){return a=(e||(e=Promise.reject())).catch((function(){return new Promise((function(e,n){plus.runtime.openURL(t,(function(e){n(e)}))}))})),a}),a),a):Promise.reject()},downloadPackage:function(){var t=this;this.downloading=!0,u=e.downloadFile({url:this.url,success:function(e){200==e.statusCode&&(t.downloadSuccess=!0,t.tempFilePath=e.tempFilePath,t.is_mandatory&&t.installPackage())},complete:function(){t.downloading=!1,t.downLoadPercent=0,t.downloadedSize=0,t.packageFileSize=0,u=null}}),u.onProgressUpdate((function(e){t.downLoadPercent=e.progress,t.downloadedSize=(e.totalBytesWritten/Math.pow(1024,2)).toFixed(2),t.packageFileSize=(e.totalBytesExpectedToWrite/Math.pow(1024,2)).toFixed(2)}))},installPackage:function(){},restart:function(){this.installed=!1},saveFile:function(t,n){return new Promise((function(i,a){e.saveFile({tempFilePath:t,success:function(t){var i=t.savedFilePath;e.setStorageSync(c,{version:n,savedFilePath:i})},complete:function(){i()}})}))},deleteSavedFile:function(t){return e.removeStorageSync(c),e.removeSavedFile({filePath:t})},jumpToAppStore:function(){plus.runtime.openURL(this.url)}}};t.default=s}).call(this,n("543d")["default"])},"9bce":function(e,t,n){"use strict";(function(e,t){var i=n("4ea4");n("b03e");i(n("66fd"));var a=i(n("9ed8"));e.__webpack_require_UNI_MP_PLUGIN__=n,t(a.default)}).call(this,n("bc2e")["default"],n("543d")["createPage"])},"9ed8":function(e,t,n){"use strict";n.r(t);var i=n("fc4c"),a=n("bb89");for(var r in a)["default"].indexOf(r)<0&&function(e){n.d(t,e,(function(){return a[e]}))}(r);n("c932");var o=n("f0c5"),c=Object(o["a"])(a["default"],i["b"],i["c"],!1,null,null,null,!1,i["a"],void 0);t["default"]=c.exports},a90c:function(e,t,n){},bb89:function(e,t,n){"use strict";n.r(t);var i=n("6bc0"),a=n.n(i);for(var r in i)["default"].indexOf(r)<0&&function(e){n.d(t,e,(function(){return i[e]}))}(r);t["default"]=a.a},c932:function(e,t,n){"use strict";var i=n("a90c"),a=n.n(i);a.a},fc4c:function(e,t,n){"use strict";n.d(t,"b",(function(){return i})),n.d(t,"c",(function(){return a})),n.d(t,"a",(function(){}));var i=function(){var e=this.$createElement;this._self._c},a=[]}},[["9bce","common/runtime","common/vendor"]]]); |