+ {{ t(hasOpenAIQuotaObservation
+ ? 'admin.accounts.usageWindow.quotaRefreshFailedCached'
+ : 'admin.accounts.usageWindow.quotaRefreshFailedUnknown') }}
+
+
+ {{ t('admin.accounts.usageWindow.quotaObservedAt') }}
+
+ {{ t('admin.accounts.usageWindow.quotaObservationUnknown') }}
+
cnQuotaCellVisible(props.account))
const loading = ref(false)
const error = ref(null)
-const data = ref(null)
+const probeData = ref(null)
+let probeGeneration = 0
// 后端周期任务/手动探测写入的 extra 快照键(_ 前缀,与后端
// cnQuotaExtraUpdates 对齐)。页面加载即有数据,无需等待探测。
@@ -118,6 +119,18 @@ const snapshotData = computed(() => {
return { success: true, tiers } as CNProviderQuotaProbeResult
})
+const data = computed(() => probeData.value ?? snapshotData.value)
+
+// A list refresh replaces account.extra even when its quota snapshot is
+// unchanged. Keep a manual probe until the quota values or snapshot version
+// actually change, rather than reverting it on unrelated account updates.
+watch(
+ [snapshotData, () => readExtraString(`${props.account.platform}_usage_updated_at`)],
+ (next, previous) => {
+ if (JSON.stringify(next) !== JSON.stringify(previous)) probeData.value = null
+ }
+)
+
// 快照是否过期(无更新时间或超过 staleness 窗口)→ 挂载时需要自动探测。
const snapshotIsStale = computed(() => {
const updatedAt = readExtraString(`${props.account.platform}_usage_updated_at`)
@@ -130,7 +143,6 @@ const snapshotIsStale = computed(() => {
// 避免静默失败导致单元格空白无提示)。
onMounted(() => {
if (!visible.value) return
- data.value = snapshotData.value
if (!snapshotIsStale.value) return
// 模块级去抖:列表页每行一个实例,翻页/筛选/刷新会重复挂载;同一账号
// 短时间内已自动探测过则跳过,避免对上游形成探测风暴。
@@ -168,27 +180,31 @@ const windowLabel = (window: string) => {
const handleProbe = async () => {
if (loading.value) return
+ const generation = ++probeGeneration
+ const accountID = props.account.id
loading.value = true
error.value = null
try {
- const result = await adminAPI.cnProviders.queryQuota(props.account.id)
+ const result = await adminAPI.cnProviders.queryQuota(accountID)
+ if (generation !== probeGeneration) return
// 失败时保留已渲染的快照条形图(仅显示错误行),成功才覆盖。
if (result.success) {
- data.value = result
+ probeData.value = result
} else {
error.value = result.error || t('common.error')
}
} catch (e) {
- error.value = extractErrorMessage(e)
+ if (generation === probeGeneration) error.value = extractErrorMessage(e)
} finally {
- loading.value = false
+ if (generation === probeGeneration) loading.value = false
}
}
watch(
- () => props.account.id,
+ [() => props.account.id, () => props.account.platform],
() => {
- data.value = null
+ probeGeneration++
+ probeData.value = null
error.value = null
loading.value = false
}
diff --git a/frontend/src/components/account/CreateAccountModal.vue b/frontend/src/components/account/CreateAccountModal.vue
index aa27e6e841..34906ac3e4 100644
--- a/frontend/src/components/account/CreateAccountModal.vue
+++ b/frontend/src/components/account/CreateAccountModal.vue
@@ -3299,6 +3299,7 @@
@@ -4715,6 +4730,7 @@ const applyGrokOAuthUpstreamConfig = (credentials: Record