ow
This commit is contained in:
1 parent
d97a8884aa
commit
e9af73007e
5 files changed
+38
-68
No files matched your search
@@ -128,7 +128,7 @@ const BENIGN_ROUTER_PATTERNS = [
|
||||
];
|
||||
|
||||
function isBenignRouterRejection(text: string): boolean {
|
||||
return BENIGN_ROUTER_PATTERNS.some(pattern => text.includes(pattern));
|
||||
return BENIGN_ROUTER_PATTERNS.some((pattern) => text.includes(pattern));
|
||||
}
|
||||
|
||||
/** 开发期弹窗最长占用时间:过了这个点就允许下一条弹窗顶上 */
|
||||
|
||||
@@ -1027,4 +1027,4 @@
|
||||
"r404_3": "页面已下线或改名,收藏夹里还是旧地址",
|
||||
"r404_4": "服务器刚重启、菜单还没加载出来,刷新一次即可"
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -179,29 +179,26 @@ function downloadApk(info: AppUpdateInfo): Promise<string> {
|
||||
},
|
||||
);
|
||||
// 事件名是 statechanged(带 d),且进度字段挂在下载对象上(部分版本在 event.target),旧代码写错名/取错层→一直 0%
|
||||
task.addEventListener(
|
||||
"statechanged",
|
||||
(event: any) => {
|
||||
const t = event?.target ?? event;
|
||||
updateProgress.downloaded = Number(t?.downloadedSize ?? 0);
|
||||
updateProgress.total = Number(t?.totalSize ?? 0);
|
||||
const state = Number(t?.state ?? 0);
|
||||
// state:3 开始接收数据 / 4 下载中 / 5 完成 / 6 失败
|
||||
if (state === 4 || state === 3) {
|
||||
updateProgress.percent =
|
||||
updateProgress.total > 0
|
||||
? Math.min(
|
||||
99,
|
||||
Math.floor(
|
||||
(updateProgress.downloaded / updateProgress.total) * 100,
|
||||
),
|
||||
)
|
||||
: -1; // 无 Content-Length:不确定态动画
|
||||
} else if (state === 6) {
|
||||
reject(new Error(`下载中断\n${url}`));
|
||||
}
|
||||
},
|
||||
);
|
||||
task.addEventListener("statechanged", (event: any) => {
|
||||
const t = event?.target ?? event;
|
||||
updateProgress.downloaded = Number(t?.downloadedSize ?? 0);
|
||||
updateProgress.total = Number(t?.totalSize ?? 0);
|
||||
const state = Number(t?.state ?? 0);
|
||||
// state:3 开始接收数据 / 4 下载中 / 5 完成 / 6 失败
|
||||
if (state === 4 || state === 3) {
|
||||
updateProgress.percent =
|
||||
updateProgress.total > 0
|
||||
? Math.min(
|
||||
99,
|
||||
Math.floor(
|
||||
(updateProgress.downloaded / updateProgress.total) * 100,
|
||||
),
|
||||
)
|
||||
: -1; // 无 Content-Length:不确定态动画
|
||||
} else if (state === 6) {
|
||||
reject(new Error(`下载中断\n${url}`));
|
||||
}
|
||||
});
|
||||
task.start();
|
||||
});
|
||||
}
|
||||
@@ -319,7 +316,11 @@ export async function checkAppUpdate(
|
||||
reason,
|
||||
});
|
||||
uni.showModal({
|
||||
title: msg(failedInstall ? "AppUpdate.installFailed" : "AppUpdate.downloadFailed"),
|
||||
title: msg(
|
||||
failedInstall
|
||||
? "AppUpdate.installFailed"
|
||||
: "AppUpdate.downloadFailed",
|
||||
),
|
||||
content: reason,
|
||||
showCancel: false,
|
||||
confirmText: msg("AppUpdate.gotIt"),
|
||||
|
||||
Reference in new issue
Block a user