-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
1 changed file
with
31 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
// 下载wgt文件 | ||
//var wgtUrl="http://demo.dcloud.net.cn/test/update/H5EF3C469.wgt"; | ||
function downWgt(wgtUrl){ | ||
plus.nativeUI.showWaiting("下载wgt文件..."); | ||
plus.downloader.createDownload( wgtUrl, {filename:"_doc/update/"}, function(d,status){ | ||
if ( status == 200 ) { | ||
//console.log("下载wgt成功:"+d.filename); | ||
installWgt(d.filename); // 安装wgt包 | ||
} else { | ||
//console.log("下载wgt失败!"); | ||
plus.nativeUI.alert("下载wgt失败!"); | ||
} | ||
plus.nativeUI.closeWaiting(); | ||
}).start(); | ||
} | ||
|
||
// 更新应用资源 | ||
function installWgt(path){ | ||
plus.nativeUI.showWaiting("安装wgt文件..."); | ||
plus.runtime.install(path,{},function(){ | ||
plus.nativeUI.closeWaiting(); | ||
//console.log("安装wgt文件成功!"); | ||
plus.nativeUI.alert("应用资源更新完成!",function(){ | ||
plus.runtime.restart(); | ||
}); | ||
},function(e){ | ||
plus.nativeUI.closeWaiting(); | ||
//console.log("安装wgt文件失败["+e.code+"]:"+e.message); | ||
plus.nativeUI.alert("安装wgt文件失败["+e.code+"]:"+e.message); | ||
}); | ||
} |