|
@@ -16,15 +16,16 @@ export async function checkAndUpdate() {
|
|
|
|
|
|
// 1. 拉取元数据
|
|
|
const meta = await fetch(UPDATE_URL).then((r) => r.json());
|
|
|
- console.log("2. 基本校验", meta);
|
|
|
+ console.log("更新", meta);
|
|
|
|
|
|
// 2. 基本校验
|
|
|
const current = await CapacitorUpdater.current();
|
|
|
const { version } = await App.getInfo();
|
|
|
|
|
|
+ console.log("版本:", current.bundle.version, meta.version)
|
|
|
if (
|
|
|
current.bundle.version != "builtin" &&
|
|
|
- semver.lt(current.bundle.version, meta.version)
|
|
|
+ semver.gte(current.bundle.version, meta.version)
|
|
|
) {
|
|
|
console.log("无新版本");
|
|
|
return;
|
|
@@ -40,19 +41,16 @@ export async function checkAndUpdate() {
|
|
|
checksum: meta.checksum,
|
|
|
});
|
|
|
|
|
|
+ await CapacitorUpdater.set(update); // 设置新版本
|
|
|
// 通知
|
|
|
if (meta.mandatory) {
|
|
|
- showDialog({
|
|
|
+ await showDialog({
|
|
|
title: `v ${meta.version} 已發布`,
|
|
|
confirmButtonText: "立即體驗",
|
|
|
message: meta.upDataDescription,
|
|
|
}).then(async () => {
|
|
|
- // 重启
|
|
|
- await CapacitorUpdater.set(update); // 设置新版本
|
|
|
console.log("✅ 已切换到新版本,准备重启");
|
|
|
await App.exitApp(); // 冷启动加载新 bundle
|
|
|
});
|
|
|
- } else {
|
|
|
- await CapacitorUpdater.set(update);
|
|
|
- }
|
|
|
+ }
|
|
|
}
|