From d1ce36038cab72b5dc1b320d0a708c261ffbdacb Mon Sep 17 00:00:00 2001 From: xiaojunnuo Date: Wed, 23 Jul 2025 00:10:15 +0800 Subject: [PATCH] =?UTF-8?q?perf:=20=E5=A2=9E=E5=8A=A0=E7=89=88=E6=9C=AC?= =?UTF-8?q?=E8=BF=87=E4=BD=8E=E6=8F=90=E7=A4=BA?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../certd-client/src/store/settings/index.ts | 8 +++++ .../views/framework/home/dashboard/index.vue | 32 ++++++++++++++----- 2 files changed, 32 insertions(+), 8 deletions(-) diff --git a/packages/ui/certd-client/src/store/settings/index.ts b/packages/ui/certd-client/src/store/settings/index.ts index 4d84491b..2f6bf9a6 100644 --- a/packages/ui/certd-client/src/store/settings/index.ts +++ b/packages/ui/certd-client/src/store/settings/index.ts @@ -46,6 +46,10 @@ export interface SettingState { price3: number; tooltip?: string; }; + app?: { + minVersion?: string; + minVersionTip?: string; + }; }; } @@ -107,6 +111,10 @@ export const useSettingStore = defineStore({ price: 399, price3: 899, }, + app: { + minVersion: "", + minVersionTip: "", + }, }, }), getters: { diff --git a/packages/ui/certd-client/src/views/framework/home/dashboard/index.vue b/packages/ui/certd-client/src/views/framework/home/dashboard/index.vue index 2f6496bc..25679112 100644 --- a/packages/ui/certd-client/src/views/framework/home/dashboard/index.vue +++ b/packages/ui/certd-client/src/views/framework/home/dashboard/index.vue @@ -156,32 +156,48 @@ import * as api from "./api"; import { useI18n } from "/src/locales"; const { t } = useI18n(); import { usePluginStore } from "/@/store/plugin"; +import { notification } from "ant-design-vue"; defineOptions({ name: "DashboardUser", }); const version = ref(import.meta.env.VITE_APP_VERSION); const latestVersion = ref(""); -const hasNewVersion = computed(() => { - if (!latestVersion.value) { + +function isNewVersion(version: string, latestVersion: string) { + if (!latestVersion) { return false; } - if (latestVersion.value === version.value) { + if (latestVersion === version) { return false; } //分段比较 - const current = version.value.split("."); - const latest = latestVersion.value.split("."); + const current = version.split("."); + const latest = latestVersion.split("."); for (let i = 0; i < current.length; i++) { - if (parseInt(latest[i]) < parseInt(current[i])) { - return false; + if (parseInt(latest[i]) > parseInt(current[i])) { + return true; } } - return true; + return false; +} + +const hasNewVersion = computed(() => { + return isNewVersion(version.value, latestVersion.value); }); async function loadLatestVersion() { latestVersion.value = await api.GetLatestVersion(); console.log("latestVersion", latestVersion.value); + + const minVersion = settingsStore.productInfo?.app?.minVersion; + if (minVersion) { + // + if (isNewVersion(version.value, minVersion)) { + notification.error({ + message: settingsStore.productInfo?.app?.minVersionTip ?? "版本过低,为了您的数据安全,请尽快升级", + }); + } + } } const settingStore = useSettingStore(); const siteInfo: Ref = computed(() => {