From f95fa5ee8f6f8eb366f948e1989784cd93c9a6f3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=BB=9D=E5=B0=98?= <237809796@qq.com> Date: Mon, 15 Jun 2026 13:37:24 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BC=98=E5=8C=96:=20CR-08=20P1-2=20Dashboard?= =?UTF-8?q?=E6=9A=82=E6=97=A0=E9=A1=B9=E7=9B=AE+P1-9=20useAiStream?= =?UTF-8?q?=E7=9C=8B=E9=97=A8=E7=8B=97=E6=96=87=E6=A1=88=E8=B5=B0i18n(?= =?UTF-8?q?=E5=90=84=E5=BB=BAzh/en=20key,composable=E7=94=A8=E5=85=A8?= =?UTF-8?q?=E5=B1=80i18n=E5=AE=9E=E4=BE=8B)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/composables/ai/useAiStream.ts | 9 +++++++-- src/i18n/en/ai.ts | 2 ++ src/i18n/en/dashboard.ts | 3 ++- src/i18n/zh-CN/ai.ts | 2 ++ src/i18n/zh-CN/dashboard.ts | 3 ++- src/views/Dashboard.vue | 2 +- 6 files changed, 16 insertions(+), 5 deletions(-) diff --git a/src/composables/ai/useAiStream.ts b/src/composables/ai/useAiStream.ts index 0b302d5..57ed7dc 100644 --- a/src/composables/ai/useAiStream.ts +++ b/src/composables/ai/useAiStream.ts @@ -12,8 +12,13 @@ //! 循环依赖;下沉到 aiShared 后本模块不再 import useAiEvents,环消除) import { state } from '../../stores/ai' +import i18n from '../../i18n' import { nextMsgId } from './aiShared' +// composable 内非组件上下文(无 setup),用 vue-i18n 全局实例的 t 而非 useI18n()。 +// 通过 any 中转规避 vue-i18n 深度 message schema 泛型导致的 TS2589(类型实例化过深)。 +const t = ((i18n as any).global.t as (key: string) => string).bind((i18n as any).global) + /// ≥ 后端 STREAM_IDLE_TIMEOUT(120s, ai.rs:848)+余量; /// 前端若短于后端,慢首 token 会被前端先误杀 export const STREAM_TIMEOUT_MS = 130000 @@ -49,8 +54,8 @@ export function onStreamTimeout() { } } const content = hasCompletedTool - ? '⚠ 工具已执行完成,后续回复中断(长时间无数据流)。可点继续重试。' - : '⚠ 响应中断(长时间无数据流)。可能是网络断连或后端异常,请重试。' + ? t('ai.streamInterruptedAfterTool') + : t('ai.streamInterrupted') state.messages.push({ id: `timeout-${nextMsgId()}`, role: 'assistant', diff --git a/src/i18n/en/ai.ts b/src/i18n/en/ai.ts index 47e4694..4da3c24 100644 --- a/src/i18n/en/ai.ts +++ b/src/i18n/en/ai.ts @@ -10,5 +10,7 @@ export default { errorAuth: 'Request failed: the API key is invalid or lacks permission.', errorTimeout: 'The response timed out. Please try again.', errorNetwork: 'Network connection failed. Please check your network.', + streamInterruptedAfterTool: '⚠ The tool finished, but the following reply was interrupted (no data stream for a long time). You can click Continue to retry.', + streamInterrupted: '⚠ The response was interrupted (no data stream for a long time). This may be due to a network disconnection or a backend error. Please try again.', }, } diff --git a/src/i18n/en/dashboard.ts b/src/i18n/en/dashboard.ts index e6948ca..a06f144 100644 --- a/src/i18n/en/dashboard.ts +++ b/src/i18n/en/dashboard.ts @@ -27,7 +27,8 @@ export default { testing: 'Testing', release: 'Release', empty: { - noProjects: 'No projects yet', + noProjects: 'No projects yet, go', + noProjectsLink: 'create one', noIdeas: 'No ideas yet, click above to capture', noData: 'No data', }, diff --git a/src/i18n/zh-CN/ai.ts b/src/i18n/zh-CN/ai.ts index b66c568..af05afd 100644 --- a/src/i18n/zh-CN/ai.ts +++ b/src/i18n/zh-CN/ai.ts @@ -10,5 +10,7 @@ export default { errorAuth: '调用失败:API Key 无效或无权限', errorTimeout: '响应超时,请重试', errorNetwork: '网络连接失败,请检查网络', + streamInterruptedAfterTool: '⚠ 工具已执行完成,后续回复中断(长时间无数据流)。可点继续重试。', + streamInterrupted: '⚠ 响应中断(长时间无数据流)。可能是网络断连或后端异常,请重试。', }, } diff --git a/src/i18n/zh-CN/dashboard.ts b/src/i18n/zh-CN/dashboard.ts index 6e2eb3f..48beaf7 100644 --- a/src/i18n/zh-CN/dashboard.ts +++ b/src/i18n/zh-CN/dashboard.ts @@ -27,7 +27,8 @@ export default { testing: '测试中', release: '发布中', empty: { - noProjects: '暂无项目,去创建一个', + noProjects: '暂无项目,去', + noProjectsLink: '创建一个', noIdeas: '暂无灵感,点击上方按钮捕捉', noData: '暂无数据', }, diff --git a/src/views/Dashboard.vue b/src/views/Dashboard.vue index 8933c14..c52662e 100644 --- a/src/views/Dashboard.vue +++ b/src/views/Dashboard.vue @@ -73,7 +73,7 @@ -