-
+
-
+ />
+
-
+
新增用户
-
+
批量删除
@@ -62,33 +56,45 @@
- 修改
- 删除
+ 修改
+ 删除
+
-
+
-
+
+
+
+
+
+
+
+
From 45b7332342d60f1136f4f00e66d1cd7a83de8716 Mon Sep 17 00:00:00 2001
From: cshaptx4869 <994774638@qq.com>
Date: Fri, 11 Sep 2026 16:28:56 +0800
Subject: [PATCH 2/2] =?UTF-8?q?feat:=20:sparkles:=20=E5=8A=A0=E7=89=88?=
=?UTF-8?q?=E6=9C=AC=E6=A3=80=E6=9F=A5=E5=8A=9F=E8=83=BD?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
src/App.vue | 6 +++
src/composables/useVersionCheck.ts | 66 ++++++++++++++++++++++++++++++
vite.config.ts | 17 +++++++-
3 files changed, 88 insertions(+), 1 deletion(-)
create mode 100644 src/composables/useVersionCheck.ts
diff --git a/src/App.vue b/src/App.vue
index bc6d8b0f..87cb5475 100644
--- a/src/App.vue
+++ b/src/App.vue
@@ -15,6 +15,7 @@
import { useAppStore, useSettingsStore } from "@/stores";
import { appConfig } from "@/settings";
import { ThemeMode, ComponentSize } from "@/enums";
+import { useVersionCheck } from "@/composables/useVersionCheck";
const appStore = useAppStore();
const settingsStore = useSettingsStore();
@@ -30,4 +31,9 @@ const fontColor = computed(() => {
? "rgba(255, 255, 255, .15)"
: "rgba(0, 0, 0, .15)";
});
+
+// 初始化版本检查
+if (!import.meta.env.DEV) {
+ useVersionCheck(5 * 60_000);
+}
diff --git a/src/composables/useVersionCheck.ts b/src/composables/useVersionCheck.ts
new file mode 100644
index 00000000..e6bfef93
--- /dev/null
+++ b/src/composables/useVersionCheck.ts
@@ -0,0 +1,66 @@
+import { ElNotification } from "element-plus";
+import { onMounted, onUnmounted, ref } from "vue";
+
+/** 版本检查 */
+export function useVersionCheck(interval = 60_000) {
+ const hasNewVersion = ref(false);
+ let notified = false;
+ const safeInterval = Math.max(10_000, interval);
+
+ const checkVersion = async () => {
+ try {
+ const base = import.meta.env.BASE_URL;
+ const baseUrl = base.endsWith("/") ? base : `${base}/`;
+ // 时间戳防 CDN/代理缓存,no-cache 防浏览器磁盘缓存
+ const res = await fetch(`${baseUrl}version.json?t=${Date.now()}`, {
+ cache: "no-cache",
+ });
+ if (!res.ok) return; // 非核心功能,网络异常不影响正常使用
+
+ const data = await res.json();
+ if (data.version && data.version !== __APP_INFO__.buildTimestamp) {
+ hasNewVersion.value = true;
+ showUpdateNotice();
+ }
+ } catch (e) {
+ console.warn("版本检测失败", e);
+ }
+ };
+
+ const showUpdateNotice = () => {
+ if (notified) return;
+ notified = true;
+
+ // 使用 Notification 而非 Modal,不打断用户操作
+ ElNotification({
+ title: "🎉 发现新版本",
+ message: "系统已更新,点击刷新以获取最新功能",
+ duration: 0, // 不自动关闭
+ position: "bottom-right",
+ onClick: () => window.location.reload(),
+ onClose: () => {
+ notified = false;
+ },
+ customClass: "version-update-notice",
+ });
+ };
+
+ let timer: ReturnType