From 745ffb135356ed98808a4fe83a8d82671033de15 Mon Sep 17 00:00:00 2001 From: Cccc_ Date: Tue, 5 May 2026 16:23:24 +0800 Subject: [PATCH] fix(frontend): refine token refresh controls --- apps/frontend/package.json | 2 +- apps/frontend/src/views/DashboardView.vue | 35 ++++++++-- .../src/views/dashboard-license.test.ts | 67 +++++++++++++++++++ apps/frontend/src/views/dashboard-license.ts | 38 +++++++++++ 4 files changed, 134 insertions(+), 8 deletions(-) create mode 100644 apps/frontend/src/views/dashboard-license.test.ts create mode 100644 apps/frontend/src/views/dashboard-license.ts diff --git a/apps/frontend/package.json b/apps/frontend/package.json index 4119c24..ebb9b13 100644 --- a/apps/frontend/package.json +++ b/apps/frontend/package.json @@ -7,7 +7,7 @@ "dev": "vite", "build": "vue-tsc -b && vite build", "preview": "vite preview", - "test": "node --test --experimental-strip-types src/app/theme.test.ts src/components/templates/template-config.test.ts", + "test": "node --test --experimental-strip-types src/app/theme.test.ts src/components/templates/template-config.test.ts src/views/dashboard-license.test.ts", "typecheck": "vue-tsc -b", "lint": "eslint . --fix", "lint:check": "eslint .", diff --git a/apps/frontend/src/views/DashboardView.vue b/apps/frontend/src/views/DashboardView.vue index 13c85b0..e6fa339 100644 --- a/apps/frontend/src/views/DashboardView.vue +++ b/apps/frontend/src/views/DashboardView.vue @@ -24,6 +24,7 @@ import { useRouter } from '@/app/router' import StateBlock from '@/components/StateBlock.vue' import { alertClass, cardClass, inputClass, sectionHeaderClass, toneClass } from '@/components/ui' import { Button } from '@/components/ui/button' +import { Tooltip, TooltipContent, TooltipProvider, TooltipTrigger } from '@/components/ui/tooltip' import { cronLabel, extractErrorMessage, @@ -31,6 +32,11 @@ import { statusLabel, statusTone, } from '@/utils/format' +import { + canRefreshAuthorization, + formatAuthorizationExpiryTooltip, + formatRemainingDays, +} from './dashboard-license' const router = useRouter() const auth = useAuth() @@ -71,6 +77,9 @@ const tokenDetail = computed(() => { if (tokenStatus.value.expiring_soon) return 'Token 即将过期,建议准备刷新授权。' return `业务 Token 正常,${tokenStatus.value.days_until_expiry ?? '未知'} 天后过期。` }) +const remainingDaysLabel = computed(() => formatRemainingDays(tokenStatus.value?.days_until_expiry)) +const expiryTooltip = computed(() => formatAuthorizationExpiryTooltip(tokenStatus.value)) +const canRefreshToken = computed(() => canRefreshAuthorization(tokenStatus.value)) const needsEmail = computed(() => !auth.state.user?.email) const needsPassword = computed(() => auth.state.user?.has_password === false) @@ -295,12 +304,23 @@ onMounted(load)
剩余 - - {{ - tokenStatus?.days_until_expiry == null - ? '未知' - : `${tokenStatus.days_until_expiry} 天` - }} + + + + + {{ remainingDaysLabel }} + + + + {{ expiryTooltip }} + + + + + {{ remainingDaysLabel }}
@@ -309,7 +329,8 @@ onMounted(load)
{{ tokenDetail }}