From 5b1ebac9c4ce7b7f66da2ad1ce2af63698bc0da6 Mon Sep 17 00:00:00 2001 From: Seven Date: Tue, 30 Dec 2025 18:18:02 +0700 Subject: [PATCH] =?UTF-8?q?feat:=20=E6=B7=BB=E5=8A=A0=E5=BA=94=E7=94=A8?= =?UTF-8?q?=E7=89=88=E6=9C=AC=E6=A3=80=E6=9F=A5=E4=B8=8E=E6=9B=B4=E6=96=B0?= =?UTF-8?q?=E6=8F=90=E7=A4=BA=E5=8A=9F=E8=83=BD=EF=BC=9B=E6=9B=B4=E6=96=B0?= =?UTF-8?q?=E7=8E=AF=E5=A2=83=E5=8F=98=E9=87=8F=E4=BB=A5=E6=94=AF=E6=8C=81?= =?UTF-8?q?=E7=89=88=E6=9C=AC=E7=AE=A1=E7=90=86?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .env.development | 3 ++- .env.production | 3 ++- src/App.vue | 4 ++++ src/composables/useAppUpdate.ts | 18 ++++++++++-------- types/env.d.ts | 1 + vite.config.ts | 3 +++ 6 files changed, 22 insertions(+), 10 deletions(-) diff --git a/.env.development b/.env.development index a376891..3d63d7f 100644 --- a/.env.development +++ b/.env.development @@ -1,3 +1,4 @@ VITE_API_URL=http://192.168.1.3:9528 VITE_TRADINGVIEW_LIBRARY_URL=http://192.168.1.5:6173 -VITE_TRADINGVIEW_DATA_API_URL=https://demo-feed-data.tradingview.com \ No newline at end of file +VITE_TRADINGVIEW_DATA_API_URL=https://demo-feed-data.tradingview.com +VITE_APP_VERSION=0.0.1 \ No newline at end of file diff --git a/.env.production b/.env.production index 28ba411..2c09e7e 100644 --- a/.env.production +++ b/.env.production @@ -1,3 +1,4 @@ VITE_API_URL=http://192.168.1.3:9527 VITE_TRADINGVIEW_LIBRARY_URL=http://192.168.1.5:6173 -VITE_TRADINGVIEW_DATA_API_URL=https://demo-feed-data.tradingview.com \ No newline at end of file +VITE_TRADINGVIEW_DATA_API_URL=https://demo-feed-data.tradingview.com +VITE_APP_VERSION=0.0.1 \ No newline at end of file diff --git a/src/App.vue b/src/App.vue index 894aff4..5b20fc1 100644 --- a/src/App.vue +++ b/src/App.vue @@ -7,6 +7,7 @@ const { locale, loadSavedLanguage } = useLanguage(); const { initializeWallet } = useWalletStore(); const { updateProfile } = useUserStore(); const platform = usePlatform(); +const { checkAndPromptUpdate } = useAppUpdate(); onMounted(() => { if (!isAuthenticated.value) @@ -18,6 +19,9 @@ onMounted(() => { userStore.updateProfile(); } }); + useTimeoutFn(() => { + checkAndPromptUpdate(); + }, 3000); }); onBeforeMount(() => { diff --git a/src/composables/useAppUpdate.ts b/src/composables/useAppUpdate.ts index 93817b8..919816b 100644 --- a/src/composables/useAppUpdate.ts +++ b/src/composables/useAppUpdate.ts @@ -1,6 +1,6 @@ import type { VersionInfo } from "@/api/types"; import { App } from "@capacitor/app"; -import { alertController, modalController } from "@ionic/vue"; +import { alertController } from "@ionic/vue"; import { client } from "@/api"; import { i18n } from "@/locales"; @@ -28,8 +28,14 @@ function compareVersion(version1: string, version2: string): number { return 0; } +const updateUrls = { + ios: "https://apps.apple.com/app/id123456789", + android: "https://play.google.com/store/apps/details?id=riwa.ionic.app", + browser: "", +} as const; + /** - * 应用更新检查组合式函数 + * 应用更新检查 */ export function useAppUpdate() { const isChecking = ref(false); @@ -53,7 +59,7 @@ export function useAppUpdate() { } // Web 平台从环境变量或 package.json 获取 - return import.meta.env.VITE_APP_VERSION || "0.0.1"; + return import.meta.env.VITE_APP_VERSION; } catch (error) { console.error("获取当前版本失败:", error); @@ -93,11 +99,7 @@ export function useAppUpdate() { version: "0.0.2", // 模拟有新版本 forceUpdate: false, updateMessage: "修复了一些问题并优化了性能", - updateUrl: platform === "ios" - ? "https://apps.apple.com/app/id123456789" - : platform === "android" - ? "https://play.google.com/store/apps/details?id=riwa.ionic.app" - : "", + updateUrl: updateUrls[platform] || "", minSupportVersion: "0.0.1", }; diff --git a/types/env.d.ts b/types/env.d.ts index d7590c3..31ee272 100644 --- a/types/env.d.ts +++ b/types/env.d.ts @@ -12,6 +12,7 @@ interface ImportMetaEnv { readonly VITE_API_URL: string; readonly VITE_TRADINGVIEW_LIBRARY_URL: string; readonly VITE_TRADINGVIEW_DATA_API_URL: string; + readonly VITE_APP_VERSION: string; } interface ImportMeta { diff --git a/vite.config.ts b/vite.config.ts index eafe448..e9cc781 100644 --- a/vite.config.ts +++ b/vite.config.ts @@ -35,6 +35,9 @@ export default defineConfig({ resolvers: [IonicResolver(), iconsResolver({ prefix: "i" })], }), ], + define: { + APP_VERSION: JSON.stringify(process.env.VITE_APP_VERSION || "0.0.1"), + }, resolve: { alias: { "@": path.resolve(__dirname, "./src"),