Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in / Register
Toggle navigation
Menu
Open sidebar
陈曦
sub2api
Commits
4e3499c0
Commit
4e3499c0
authored
Dec 28, 2025
by
IanShaw027
Browse files
fix(frontend): 改进订阅状态实时刷新机制
- 在 Dashboard 页面加载时强制刷新订阅状态 - 在兑换订阅卡密后立即刷新订阅状态 - 清理订阅轮询相关注释
parent
26cdb180
Changes
3
Hide whitespace changes
Inline
Side-by-side
frontend/src/stores/subscriptions.ts
View file @
4e3499c0
...
@@ -79,7 +79,7 @@ export const useSubscriptionStore = defineStore('subscriptions', () => {
...
@@ -79,7 +79,7 @@ export const useSubscriptionStore = defineStore('subscriptions', () => {
}
}
/**
/**
* Start auto-refresh polling
(every 5 minutes)
* Start auto-refresh polling
*/
*/
function
startPolling
()
{
function
startPolling
()
{
if
(
pollerInterval
)
return
if
(
pollerInterval
)
return
...
@@ -88,7 +88,7 @@ export const useSubscriptionStore = defineStore('subscriptions', () => {
...
@@ -88,7 +88,7 @@ export const useSubscriptionStore = defineStore('subscriptions', () => {
fetchActiveSubscriptions
(
true
).
catch
((
error
)
=>
{
fetchActiveSubscriptions
(
true
).
catch
((
error
)
=>
{
console
.
error
(
'
Subscription polling failed:
'
,
error
)
console
.
error
(
'
Subscription polling failed:
'
,
error
)
})
})
},
5
*
60
*
1000
)
// 5 minutes
},
5
*
60
*
1000
)
}
}
/**
/**
...
...
frontend/src/views/user/DashboardView.vue
View file @
4e3499c0
...
@@ -661,6 +661,7 @@ import { ref, computed, onMounted, watch } from 'vue'
...
@@ -661,6 +661,7 @@ import { ref, computed, onMounted, watch } from 'vue'
import
{
useRouter
}
from
'
vue-router
'
import
{
useRouter
}
from
'
vue-router
'
import
{
useI18n
}
from
'
vue-i18n
'
import
{
useI18n
}
from
'
vue-i18n
'
import
{
useAuthStore
}
from
'
@/stores/auth
'
import
{
useAuthStore
}
from
'
@/stores/auth
'
import
{
useSubscriptionStore
}
from
'
@/stores/subscriptions
'
import
{
formatDateTime
}
from
'
@/utils/format
'
import
{
formatDateTime
}
from
'
@/utils/format
'
const
{
t
}
=
useI18n
()
const
{
t
}
=
useI18n
()
...
@@ -701,6 +702,7 @@ ChartJS.register(
...
@@ -701,6 +702,7 @@ ChartJS.register(
const
router
=
useRouter
()
const
router
=
useRouter
()
const
authStore
=
useAuthStore
()
const
authStore
=
useAuthStore
()
const
subscriptionStore
=
useSubscriptionStore
()
const
user
=
computed
(()
=>
authStore
.
user
)
const
user
=
computed
(()
=>
authStore
.
user
)
const
stats
=
ref
<
UserDashboardStats
|
null
>
(
null
)
const
stats
=
ref
<
UserDashboardStats
|
null
>
(
null
)
...
@@ -1018,6 +1020,11 @@ onMounted(async () => {
...
@@ -1018,6 +1020,11 @@ onMounted(async () => {
// Load critical data first
// Load critical data first
await
loadDashboardStats
()
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)
// Initialize date range (synchronous)
initializeDateRange
()
initializeDateRange
()
...
...
frontend/src/views/user/RedeemView.vue
View file @
4e3499c0
...
@@ -445,6 +445,7 @@ import { ref, computed, onMounted } from 'vue'
...
@@ -445,6 +445,7 @@ import { ref, computed, onMounted } from 'vue'
import
{
useI18n
}
from
'
vue-i18n
'
import
{
useI18n
}
from
'
vue-i18n
'
import
{
useAuthStore
}
from
'
@/stores/auth
'
import
{
useAuthStore
}
from
'
@/stores/auth
'
import
{
useAppStore
}
from
'
@/stores/app
'
import
{
useAppStore
}
from
'
@/stores/app
'
import
{
useSubscriptionStore
}
from
'
@/stores/subscriptions
'
import
{
redeemAPI
,
authAPI
,
type
RedeemHistoryItem
}
from
'
@/api
'
import
{
redeemAPI
,
authAPI
,
type
RedeemHistoryItem
}
from
'
@/api
'
import
AppLayout
from
'
@/components/layout/AppLayout.vue
'
import
AppLayout
from
'
@/components/layout/AppLayout.vue
'
import
{
formatDateTime
}
from
'
@/utils/format
'
import
{
formatDateTime
}
from
'
@/utils/format
'
...
@@ -452,6 +453,7 @@ import { formatDateTime } from '@/utils/format'
...
@@ -452,6 +453,7 @@ import { formatDateTime } from '@/utils/format'
const
{
t
}
=
useI18n
()
const
{
t
}
=
useI18n
()
const
authStore
=
useAuthStore
()
const
authStore
=
useAuthStore
()
const
appStore
=
useAppStore
()
const
appStore
=
useAppStore
()
const
subscriptionStore
=
useSubscriptionStore
()
const
user
=
computed
(()
=>
authStore
.
user
)
const
user
=
computed
(()
=>
authStore
.
user
)
...
@@ -544,6 +546,11 @@ const handleRedeem = async () => {
...
@@ -544,6 +546,11 @@ const handleRedeem = async () => {
// Refresh user data to get updated balance/concurrency
// Refresh user data to get updated balance/concurrency
await
authStore
.
refreshUser
()
await
authStore
.
refreshUser
()
// If subscription type, immediately refresh subscription status
if
(
result
.
type
===
'
subscription
'
)
{
await
subscriptionStore
.
fetchActiveSubscriptions
(
true
)
// force refresh
}
// Clear the input
// Clear the input
redeemCode
.
value
=
''
redeemCode
.
value
=
''
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment