Sfoglia il codice sorgente

feat: 版本管理

liming 2 settimane fa
parent
commit
44011bb15a

+ 1 - 1
src/i18n/zhHk/settings.js

@@ -1,7 +1,7 @@
 export default {
   ServiceAndPrivacyPolicy: "服務條款及隱私政策",
   OfficialWebsite: "官方網站",
-  VersionUpdate: "版本更新",
+  VersionUpdate: "版本",
 
   Language: "語言",
   MonetaryUnit: "貨幣單位",

+ 14 - 18
src/updater/index.js

@@ -1,4 +1,4 @@
- import { CapacitorUpdater } from "@capgo/capacitor-updater";
+import { CapacitorUpdater } from "@capgo/capacitor-updater";
 import { App } from "@capacitor/app";
 import semver from "semver";
 import { showDialog } from "vant";
@@ -18,14 +18,6 @@ export async function checkAndUpdate() {
   const meta = await fetch(UPDATE_URL).then((r) => r.json());
   console.log("2. 基本校验", meta);
 
-  //  通知
-  if (meta.mandatory) {
-    showDialog({
-      title: meta.notificationTitle,
-      message: meta.notificationBody,
-    }).then(async () => {});
-  }
-
   // 2. 基本校验
   const current = await CapacitorUpdater.current();
   const { version } = await App.getInfo();
@@ -49,14 +41,18 @@ export async function checkAndUpdate() {
   });
 
   // 通知
-  showDialog({
-    title: `v ${meta.version} 已發布`,
-    confirmButtonText: "立即體驗",
-    message: meta.upDataDescription,
-  }).then(async () => {
-    // 重启
+  if (meta.mandatory) {
+    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);
-    console.log("✅ 已切换到新版本,准备重启");
-    await App.exitApp(); // 冷启动加载新 bundle
-  });
+  }
 }

+ 3 - 5
src/updater/update.json

@@ -1,11 +1,9 @@
 {
   "version": "1.0.1",
   "releaseDate": "2025-07-29", 
-  "checksum": "4a232ff37f282fa507bf3e92292577e40097a56501b9a3fbeab1c55aa5221dba",
+  "checksum": "a10e05f75f27f9402646f12d743ec5804ecafcc4fb0e30645e7dff5aae75906d",
   "minBinaryVersion": "1.0.0",
   "mandatory": true,
-  "upDataDescription":"✨修正一些錯誤!",
-  
-  "notificationTitle": "公告",
-  "notificationBody": "更新了!"
+  "upDataDescription":"✨修正一些錯誤!"
+   
 }

+ 19 - 4
src/views/settings/aboutUs/index.vue

@@ -3,7 +3,7 @@
     <div class="logo-box">
       <svg-icon name="acc_logo" class="acc-logo" />
       <span class="logo-text">Angel Token</span>
-      <span class="logo-version">1.0.0</span>
+      <span class="logo-version">{{ version }}</span>
     </div>
 
     <van-list class="user-bar-list">
@@ -29,17 +29,32 @@
 </template>
 
 <script setup> 
+import { CapacitorUpdater } from "@capgo/capacitor-updater"
+
 const router = useRouter();
+const version = ref('');
 
-const vanListConfig = [
+const vanListConfig = ref([
   { title: $t('settings.ServiceAndPrivacyPolicy'), icon:"ingot",  url: 'agreement' },
   { title: $t('settings.OfficialWebsite'),   txt:"https://wallet.angeltokens.io" },
-  { title: $t('settings.VersionUpdate'),   url: 'nodeDividend' },
-]
+  { title: $t('settings.VersionUpdate'),   txt: '' },
+])
 
 const evGoPath = (path)=>{
   if(path == "agreement") router.push(path)
 }
+onMounted(async ()=>{
+  const current = await CapacitorUpdater.current();
+
+  if(current.bundle.version == "builtin" || current.bundle.version == ""){
+    version.value = "1.0.0"
+    vanListConfig.value[2].txt = "1.0.0" 
+    return
+  }
+  version.value = current.bundle.version
+  vanListConfig.value[2].txt = current.bundle.version
+   
+})
 
 </script>