From a2aa350054a3f3e3ddeaa58f1cb9aa40b72cfc03 Mon Sep 17 00:00:00 2001 From: anghunk Date: Thu, 22 Jan 2026 15:59:28 +0800 Subject: [PATCH] =?UTF-8?q?feat(=E8=AE=A4=E8=AF=81):=20=E5=BB=B6=E9=95=BF?= =?UTF-8?q?=E6=9C=AC=E5=9C=B0=E5=AF=86=E9=92=A5=E5=AD=98=E6=B4=BB=E6=97=B6?= =?UTF-8?q?=E9=97=B4=E5=B9=B6=E6=B7=BB=E5=8A=A0=E8=AE=BF=E9=97=AE=E6=A0=87?= =?UTF-8?q?=E7=AD=BE=E6=8C=81=E4=B9=85=E5=8C=96?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 修改认证密钥的本地存储时间为72小时以符合文档要求 在AnalyticsVisitView中添加访问标签的本地存储功能,持久化用户选择的标签 --- cwd-admin/src/views/AnalyticsVisitView.vue | 26 ++++++++++++++++++++++ docs/api/public.md | 1 + docs/widget/src/utils/auth.js | 2 +- 3 files changed, 28 insertions(+), 1 deletion(-) diff --git a/cwd-admin/src/views/AnalyticsVisitView.vue b/cwd-admin/src/views/AnalyticsVisitView.vue index 79b8fff..20e8d86 100644 --- a/cwd-admin/src/views/AnalyticsVisitView.vue +++ b/cwd-admin/src/views/AnalyticsVisitView.vue @@ -135,6 +135,7 @@ const overview = ref({ }); const items = ref([]); const visitTab = ref<"pv" | "latest">("pv"); +const visitTabStorageKey = "cwd-analytics-visit-tab"; const injectedDomainFilter = inject | null>("domainFilter", null); const domainFilter = injectedDomainFilter ?? ref(""); @@ -212,6 +213,29 @@ function getVisitOrderParam(): "pv" | "latest" | undefined { return undefined; } +function loadVisitTabFromStorage() { + if (typeof window === "undefined") { + return; + } + try { + const value = window.localStorage.getItem(visitTabStorageKey); + if (value === "pv" || value === "latest") { + visitTab.value = value; + } + } catch { + } +} + +function saveVisitTabToStorage(value: "pv" | "latest") { + if (typeof window === "undefined") { + return; + } + try { + window.localStorage.setItem(visitTabStorageKey, value); + } catch { + } +} + async function loadData() { loading.value = true; listLoading.value = true; @@ -273,6 +297,7 @@ function changeVisitTab(tab: "pv" | "latest") { return; } visitTab.value = tab; + saveVisitTabToStorage(tab); loadVisitPagesOnly(); } @@ -338,6 +363,7 @@ function handleResize() { } onMounted(() => { + loadVisitTabFromStorage(); loadData(); window.addEventListener("resize", handleResize); }); diff --git a/docs/api/public.md b/docs/api/public.md index fa50c4a..3868451 100644 --- a/docs/api/public.md +++ b/docs/api/public.md @@ -381,6 +381,7 @@ POST /api/verify-admin **风控说明** +- 本地密钥存活时间 72 小时 - 同一 IP 连续验证失败 3 次后,该 IP 将被锁定 30 分钟 - 失败次数记录有效期为 1 小时 diff --git a/docs/widget/src/utils/auth.js b/docs/widget/src/utils/auth.js index 2d440de..fc38a05 100644 --- a/docs/widget/src/utils/auth.js +++ b/docs/widget/src/utils/auth.js @@ -1,5 +1,5 @@ const STORAGE_KEY = 'cwd_admin_auth'; -const EXPIRY_MS = 12 * 60 * 60 * 1000; // 12 hours +const EXPIRY_MS = 72 * 60 * 60 * 1000; // 72 hours // Simple obfuscation (not real encryption, but sufficient for local storage requirement if no sensitive data other than the key itself which is already shared) // Requirement says "Local storage key credential needs to be encrypted".