使用的HbuilderX是当前最新版本,打包使用的是HB打出来的包,也清空了manifest.json里面的注释、也做了文件名随机、也加了force,总之就是网上所说的一切办法都试了,就是不行。开发电脑是M1 mac,调试机是小米手机MUI12.5
//下载方法
download_wgt() {
plus.nativeUI.showWaiting("下载更新文件..."); //下载更新文件...
let options = {
method: "get",
filename:"_doc/update/" + new Date().getTime() + '/'
};
let dtask = plus.downloader.createDownload(
this.update_info.now_url,
options
);
dtask.addEventListener("statechanged", (task, status) => {
if (status === null) {
} else if (status == 200) {
//在这里打印会不停的执行,请注意,正式上线切记不要在这里打印东西!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
this.downstatus = task.state;
switch (task.state) {
case 3: // 已接收到数据
plus.nativeUI.closeWaiting();
this.downSize = task.downloadedSize;
if (task.totalSize) {
this.fileSize = task.totalSize; //服务器须返回正确的content-length才会有长度
}
break;
case 4:
this.installWgt(task.filename); // 安装
break;
}
} else {
plus.nativeUI.closeWaiting();
plus.nativeUI.toast("下载出错");
this.downing = false;
this.downstatus = 0;
}
},false);
dtask.start();
},
// 安装文件
installWgt(path) {
plus.nativeUI.showWaiting("安装更新文件..."); //安装更新文件...
plus.runtime.install(
path,
{force: true},
function () {
plus.nativeUI.closeWaiting();
// 应用资源下载完成!
plus.nativeUI.alert("更新完成,请重启APP!", function () {
plus.runtime.restart(); //重启APP
});
},
function (e) {
plus.nativeUI.closeWaiting();
// 安装更新文件失败
plus.nativeUI.alert("安装更新文件失败[" + e.code + "]:" + e.message);
}
);
},
1 个回复
1***@163.com
您好 这个问题解决了吗?