优化: CR-08 P1-2 Dashboard暂无项目+P1-9 useAiStream看门狗文案走i18n(各建zh/en key,composable用全局i18n实例)

This commit is contained in:
2026-06-15 13:37:24 +08:00
parent fb68c731a4
commit f95fa5ee8f
6 changed files with 16 additions and 5 deletions

View File

@@ -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',