From 813bed66a3c0936227ab7ab03f738c7ebad508d4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E9=BB=84=E8=87=AA=E8=BE=BE?= <980324341@qq.com> Date: Sun, 25 Oct 2026 00:46:29 +0800 Subject: [PATCH] =?UTF-8?q?fix(=E5=89=8D=E7=AB=AF):=20=E4=BB=A3=E7=90=86IP?= =?UTF-8?q?=E5=85=B1=E7=94=A8=E5=BC=B9=E7=AA=97=E6=94=B9=E4=B8=BA=E7=B2=BE?= =?UTF-8?q?=E7=AE=80=E5=8F=A3=E8=AF=AD=E6=96=87=E6=A1=88?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- frontend-vue/src/shared/components/CostGuardAlert.vue | 3 ++- frontend-vue/src/shared/utils/cost-guard-alert.ts | 5 +++++ frontend-vue/tests/cost-guard-alert.test.ts | 11 +++++++++++ 3 files changed, 18 insertions(+), 1 deletion(-) diff --git a/frontend-vue/src/shared/components/CostGuardAlert.vue b/frontend-vue/src/shared/components/CostGuardAlert.vue index 395d4736e..ae4d542a5 100644 --- a/frontend-vue/src/shared/components/CostGuardAlert.vue +++ b/frontend-vue/src/shared/components/CostGuardAlert.vue @@ -20,6 +20,7 @@ import { AUTH_TOKEN_KEY } from '@/shared/auth/session-keys' import { COST_GUARD_POLL_MS, pausedPromptKey, + proxySharedToastText, sharedWarningKey, usageLine, } from '@/shared/utils/cost-guard-alert' @@ -68,7 +69,7 @@ function notifySharedWarnings(warnings: SharedSecretWarning[]): void { const key = sharedWarningKey(warning) if (warnedSharedKeys.has(key)) continue warnedSharedKeys.add(key) - ElMessage.warning({ message: warning.message, duration: 8000, showClose: true }) + ElMessage.warning({ message: proxySharedToastText(warning), duration: 8000, showClose: true }) } } diff --git a/frontend-vue/src/shared/utils/cost-guard-alert.ts b/frontend-vue/src/shared/utils/cost-guard-alert.ts index 2064f9323..c8163cf34 100644 --- a/frontend-vue/src/shared/utils/cost-guard-alert.ts +++ b/frontend-vue/src/shared/utils/cost-guard-alert.ts @@ -27,3 +27,8 @@ export function pausedPromptKey(status: CostGuardStatus | null): string { export function sharedWarningKey(warning: SharedSecretWarning): string { return `${warning.type}|${warning.moduleLabel}|${warning.accounts}` } + +/** 代理 IP 共用弹窗文案:精简口语版,不搬运后端的技术口径。 */ +export function proxySharedToastText(warning: SharedSecretWarning): string { + return `这把代理链接被 ${warning.accounts} 个账号共用,别人用多了你就不够用了。建议在「密钥设置」里配一把自己的。` +} diff --git a/frontend-vue/tests/cost-guard-alert.test.ts b/frontend-vue/tests/cost-guard-alert.test.ts index e31f1980d..4b6a325e1 100644 --- a/frontend-vue/tests/cost-guard-alert.test.ts +++ b/frontend-vue/tests/cost-guard-alert.test.ts @@ -81,6 +81,17 @@ test('密钥共用提示只走通知,不再常驻界面', () => { assert.ok(component.includes("warning.type !== 'proxy'"), 'LLM 密钥共用可接受,弹窗只放行代理 IP 类型') }) +test('代理 IP 共用弹窗是精简口语文案,不搬运后端长口径', async () => { + const { proxySharedToastText } = await import('../src/shared/utils/cost-guard-alert.ts') + const text = proxySharedToastText({ type: 'proxy', moduleLabel: '代理设置', accounts: 3, threshold: 3, message: 'x' }) + + assert.match(text, /被 3 个账号共用/) + assert.match(text, /密钥设置/) + assert.ok(!text.includes('阈值'), '不应出现「阈值」这类技术词') + assert.ok(!text.includes('归因'), '不应出现后端长口径的书面语') + assert.ok(component.includes('proxySharedToastText'), '弹窗必须用前端精简文案,而不是后端 message 原文') +}) + test('全局挂载并在暂停时提供「继续任务」', () => { assert.ok(app.includes("import CostGuardAlert from '@/shared/components/CostGuardAlert.vue'")) assert.ok(app.includes(''), '组件没挂到 App.vue,异常时界面不会弹')