From 4e3499c0d7b66edaf099f8881e4c570b376ca32f Mon Sep 17 00:00:00 2001 From: IanShaw027 <131567472+IanShaw027@users.noreply.github.com> Date: Sun, 28 Dec 2025 10:32:04 +0800 Subject: [PATCH] =?UTF-8?q?fix(frontend):=20=E6=94=B9=E8=BF=9B=E8=AE=A2?= =?UTF-8?q?=E9=98=85=E7=8A=B6=E6=80=81=E5=AE=9E=E6=97=B6=E5=88=B7=E6=96=B0?= =?UTF-8?q?=E6=9C=BA=E5=88=B6?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - 在 Dashboard 页面加载时强制刷新订阅状态 - 在兑换订阅卡密后立即刷新订阅状态 - 清理订阅轮询相关注释 --- frontend/src/stores/subscriptions.ts | 4 ++-- frontend/src/views/user/DashboardView.vue | 7 +++++++ frontend/src/views/user/RedeemView.vue | 7 +++++++ 3 files changed, 16 insertions(+), 2 deletions(-) diff --git a/frontend/src/stores/subscriptions.ts b/frontend/src/stores/subscriptions.ts index e63707f7..2bda1e1a 100644 --- a/frontend/src/stores/subscriptions.ts +++ b/frontend/src/stores/subscriptions.ts @@ -79,7 +79,7 @@ export const useSubscriptionStore = defineStore('subscriptions', () => { } /** - * Start auto-refresh polling (every 5 minutes) + * Start auto-refresh polling */ function startPolling() { if (pollerInterval) return @@ -88,7 +88,7 @@ export const useSubscriptionStore = defineStore('subscriptions', () => { fetchActiveSubscriptions(true).catch((error) => { console.error('Subscription polling failed:', error) }) - }, 5 * 60 * 1000) // 5 minutes + }, 5 * 60 * 1000) } /** diff --git a/frontend/src/views/user/DashboardView.vue b/frontend/src/views/user/DashboardView.vue index f9d5ec42..1288ac48 100644 --- a/frontend/src/views/user/DashboardView.vue +++ b/frontend/src/views/user/DashboardView.vue @@ -661,6 +661,7 @@ import { ref, computed, onMounted, watch } from 'vue' import { useRouter } from 'vue-router' import { useI18n } from 'vue-i18n' import { useAuthStore } from '@/stores/auth' +import { useSubscriptionStore } from '@/stores/subscriptions' import { formatDateTime } from '@/utils/format' const { t } = useI18n() @@ -701,6 +702,7 @@ ChartJS.register( const router = useRouter() const authStore = useAuthStore() +const subscriptionStore = useSubscriptionStore() const user = computed(() => authStore.user) const stats = ref(null) @@ -1018,6 +1020,11 @@ onMounted(async () => { // Load critical data first await loadDashboardStats() + // Force refresh subscription status when entering dashboard (bypass cache) + subscriptionStore.fetchActiveSubscriptions(true).catch((error) => { + console.error('Failed to refresh subscription status:', error) + }) + // Initialize date range (synchronous) initializeDateRange() diff --git a/frontend/src/views/user/RedeemView.vue b/frontend/src/views/user/RedeemView.vue index 6e6c1600..7e35916d 100644 --- a/frontend/src/views/user/RedeemView.vue +++ b/frontend/src/views/user/RedeemView.vue @@ -445,6 +445,7 @@ import { ref, computed, onMounted } from 'vue' import { useI18n } from 'vue-i18n' import { useAuthStore } from '@/stores/auth' import { useAppStore } from '@/stores/app' +import { useSubscriptionStore } from '@/stores/subscriptions' import { redeemAPI, authAPI, type RedeemHistoryItem } from '@/api' import AppLayout from '@/components/layout/AppLayout.vue' import { formatDateTime } from '@/utils/format' @@ -452,6 +453,7 @@ import { formatDateTime } from '@/utils/format' const { t } = useI18n() const authStore = useAuthStore() const appStore = useAppStore() +const subscriptionStore = useSubscriptionStore() const user = computed(() => authStore.user) @@ -544,6 +546,11 @@ const handleRedeem = async () => { // Refresh user data to get updated balance/concurrency await authStore.refreshUser() + // If subscription type, immediately refresh subscription status + if (result.type === 'subscription') { + await subscriptionStore.fetchActiveSubscriptions(true) // force refresh + } + // Clear the input redeemCode.value = ''