2023-02-15 11:32:23 +08:00

11 lines
4.6 KiB
JavaScript
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

(global["webpackJsonp"]=global["webpackJsonp"]||[]).push([["components/update/app-update"],{"07b5":function(t,e,n){"use strict";(function(t){Object.defineProperty(e,"__esModule",{value:!0}),e.default=void 0;var a,i=n("e844"),o={name:"appUpdate",props:{tabbar:{type:Boolean,default:!1},getVer:{type:Boolean,default:!1}},data:function(){return{popup_show:!1,platform:"",version:"1.0.0",need_update:!1,downing:!1,downstatus:0,update_info:{os:"",version:"",info:""},fileSize:0,downSize:0,viewObj:null}},created:function(){a=this,this.getVer||this.update()},computed:{lengthWidth:function(){var t=this.downSize/this.fileSize*100;return t=t?t.toFixed(2):0,{width:t+"%"}},getHeight:function(){var t=0;return this.tabbar&&(t=50),{bottom:t+"px",height:"auto"}}},methods:{update:function(){},getUpdateInfo:function(){var e=this;(0,i.getUpdateInfo)("ios"===this.platform?2:1).then((function(n){if(Array.isArray(n.data))return e.$emit("isNew");var i=t.getStorageSync("app_update_time")||"",o=(new Date).toLocaleDateString();if(i===o||e.getVer){if(i!==o&&e.getVer){if(!n.data.is_force)return}else if(i==o&&!e.getVer&&!n.data.is_force)return}else t.setStorageSync("app_update_time",(new Date).toLocaleDateString());var u=n.data;a.update_info=u,a.update_info.platform&&a.checkUpdate()})).catch((function(t){a.popup_show=!1}))},checkUpdate:function(){a.need_update=a.compareVersion(a.version,a.update_info.version),a.need_update?(a.popup_show=!0,a.tabbar&&(a.viewObj=new plus.nativeObj.View("viewObj",{bottom:"0px",left:"0px",height:"50px",width:"100%",backgroundColor:"rgba(0,0,0,.6)"}),a.viewObj.show())):this.$emit("isNew")},closeUpdate:function(){a.update_info.is_force?"android"==this.platform?plus.runtime.quit():plus.ios.import("UIApplication").sharedApplication().performSelector("exit"):(a.popup_show=!1,a.viewObj&&a.viewObj.hide())},nowUpdate:function(){if(a.downing)return!1;a.downing=!0,/\.apk$/.test(a.update_info.url)||/\.wgt$/.test(a.update_info.url)?a.download_wgt():plus.runtime.openURL(a.update_info.url,(function(){plus.nativeUI.toast("打开错误")}))},download_wgt:function(){plus.nativeUI.showWaiting("下载更新文件...");var t={method:"get"},e=plus.downloader.createDownload(a.update_info.url,t,(function(t,e){}));e.addEventListener("statechanged",(function(t,e){if(null===e);else if(200==e)switch(a.downstatus=t.state,t.state){case 3:a.downSize=t.downloadedSize,t.totalSize&&(a.fileSize=t.totalSize);break;case 4:a.installWgt(t.filename);break}else plus.nativeUI.closeWaiting(),plus.nativeUI.toast("下载出错"),a.downing=!1,a.downstatus=0})),e.start()},installWgt:function(t){plus.nativeUI.showWaiting("安装更新文件..."),plus.runtime.install(t,{},(function(){plus.nativeUI.closeWaiting(),plus.nativeUI.alert("应用资源下载完成!",(function(){plus.runtime.restart()}))}),(function(t){plus.nativeUI.closeWaiting(),plus.nativeUI.alert("安装更新文件失败["+t.code+"]"+t.message)}))},compareVersion:function(t,e){if(!t||!e||""==t||""==e)return!1;for(var n=t.split(".",4),a=e.split(".",4),i=0;i<n.length&&i<a.length;i++){var o=n[i],u=parseInt(o),r=a[i],s=parseInt(r);if(s>u||r.length>o.length)return!0;if(s<u)return!1}return a.length>n.length&&0==e.indexOf(t)}}};e.default=o}).call(this,n("543d")["default"])},"0eee":function(t,e,n){"use strict";var a=n("5f93"),i=n.n(a);i.a},2979:function(t,e,n){"use strict";n.r(e);var a=n("aa8a"),i=n("60ad");for(var o in i)"default"!==o&&function(t){n.d(e,t,(function(){return i[t]}))}(o);n("0eee");var u,r=n("f0c5"),s=Object(r["a"])(i["default"],a["b"],a["c"],!1,null,"44f416fc",null,!1,a["a"],u);e["default"]=s.exports},"5f93":function(t,e,n){},"60ad":function(t,e,n){"use strict";n.r(e);var a=n("07b5"),i=n.n(a);for(var o in a)"default"!==o&&function(t){n.d(e,t,(function(){return a[t]}))}(o);e["default"]=i.a},aa8a:function(t,e,n){"use strict";var a;n.d(e,"b",(function(){return i})),n.d(e,"c",(function(){return o})),n.d(e,"a",(function(){return a}));var i=function(){var t=this,e=t.$createElement,n=(t._self._c,t.popup_show?t.$t("发现新版本"):null),a=t.popup_show&&t.downstatus<1?t.$t("立即升级"):null,i=!t.popup_show||t.downstatus<1?null:t.$t("下载进度"),o=!t.popup_show||t.downstatus<1?null:(t.downSize/1024/1024).toFixed(2),u=!t.popup_show||t.downstatus<1?null:(t.fileSize/1024/1024).toFixed(2);t.$mp.data=Object.assign({},{$root:{m0:n,m1:a,m2:i,g0:o,g1:u}})},o=[]}}]);
;(global["webpackJsonp"] = global["webpackJsonp"] || []).push([
'components/update/app-update-create-component',
{
'components/update/app-update-create-component':(function(module, exports, __webpack_require__){
__webpack_require__('543d')['createComponent'](__webpack_require__("2979"))
})
},
[['components/update/app-update-create-component']]
]);