优化: CR-08 P1-2 Dashboard暂无项目+P1-9 useAiStream看门狗文案走i18n(各建zh/en key,composable用全局i18n实例)
This commit is contained in:
@@ -12,8 +12,13 @@
|
|||||||
//! 循环依赖;下沉到 aiShared 后本模块不再 import useAiEvents,环消除)
|
//! 循环依赖;下沉到 aiShared 后本模块不再 import useAiEvents,环消除)
|
||||||
|
|
||||||
import { state } from '../../stores/ai'
|
import { state } from '../../stores/ai'
|
||||||
|
import i18n from '../../i18n'
|
||||||
import { nextMsgId } from './aiShared'
|
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)+余量;
|
/// ≥ 后端 STREAM_IDLE_TIMEOUT(120s, ai.rs:848)+余量;
|
||||||
/// 前端若短于后端,慢首 token 会被前端先误杀
|
/// 前端若短于后端,慢首 token 会被前端先误杀
|
||||||
export const STREAM_TIMEOUT_MS = 130000
|
export const STREAM_TIMEOUT_MS = 130000
|
||||||
@@ -49,8 +54,8 @@ export function onStreamTimeout() {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
const content = hasCompletedTool
|
const content = hasCompletedTool
|
||||||
? '⚠ 工具已执行完成,后续回复中断(长时间无数据流)。可点继续重试。'
|
? t('ai.streamInterruptedAfterTool')
|
||||||
: '⚠ 响应中断(长时间无数据流)。可能是网络断连或后端异常,请重试。'
|
: t('ai.streamInterrupted')
|
||||||
state.messages.push({
|
state.messages.push({
|
||||||
id: `timeout-${nextMsgId()}`,
|
id: `timeout-${nextMsgId()}`,
|
||||||
role: 'assistant',
|
role: 'assistant',
|
||||||
|
|||||||
@@ -10,5 +10,7 @@ export default {
|
|||||||
errorAuth: 'Request failed: the API key is invalid or lacks permission.',
|
errorAuth: 'Request failed: the API key is invalid or lacks permission.',
|
||||||
errorTimeout: 'The response timed out. Please try again.',
|
errorTimeout: 'The response timed out. Please try again.',
|
||||||
errorNetwork: 'Network connection failed. Please check your network.',
|
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.',
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -27,7 +27,8 @@ export default {
|
|||||||
testing: 'Testing',
|
testing: 'Testing',
|
||||||
release: 'Release',
|
release: 'Release',
|
||||||
empty: {
|
empty: {
|
||||||
noProjects: 'No projects yet',
|
noProjects: 'No projects yet, go',
|
||||||
|
noProjectsLink: 'create one',
|
||||||
noIdeas: 'No ideas yet, click above to capture',
|
noIdeas: 'No ideas yet, click above to capture',
|
||||||
noData: 'No data',
|
noData: 'No data',
|
||||||
},
|
},
|
||||||
|
|||||||
@@ -10,5 +10,7 @@ export default {
|
|||||||
errorAuth: '调用失败:API Key 无效或无权限',
|
errorAuth: '调用失败:API Key 无效或无权限',
|
||||||
errorTimeout: '响应超时,请重试',
|
errorTimeout: '响应超时,请重试',
|
||||||
errorNetwork: '网络连接失败,请检查网络',
|
errorNetwork: '网络连接失败,请检查网络',
|
||||||
|
streamInterruptedAfterTool: '⚠ 工具已执行完成,后续回复中断(长时间无数据流)。可点继续重试。',
|
||||||
|
streamInterrupted: '⚠ 响应中断(长时间无数据流)。可能是网络断连或后端异常,请重试。',
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -27,7 +27,8 @@ export default {
|
|||||||
testing: '测试中',
|
testing: '测试中',
|
||||||
release: '发布中',
|
release: '发布中',
|
||||||
empty: {
|
empty: {
|
||||||
noProjects: '暂无项目,去创建一个',
|
noProjects: '暂无项目,去',
|
||||||
|
noProjectsLink: '创建一个',
|
||||||
noIdeas: '暂无灵感,点击上方按钮捕捉',
|
noIdeas: '暂无灵感,点击上方按钮捕捉',
|
||||||
noData: '暂无数据',
|
noData: '暂无数据',
|
||||||
},
|
},
|
||||||
|
|||||||
@@ -73,7 +73,7 @@
|
|||||||
<span class="project-meta-time">{{ p.lastActivity }}</span>
|
<span class="project-meta-time">{{ p.lastActivity }}</span>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<div v-if="displayProjects.length === 0" class="empty-hint">暂无项目,去 <router-link to="/projects" class="df-link">创建一个</router-link></div>
|
<div v-if="displayProjects.length === 0" class="empty-hint">{{ t('dashboard.empty.noProjects') }} <router-link to="/projects" class="df-link">{{ t('dashboard.empty.noProjectsLink') }}</router-link></div>
|
||||||
</div>
|
</div>
|
||||||
</section>
|
</section>
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user