重构: 前端架构审查降技术债·i18n收口(高ROI)
- 新建 src/i18n/i18n-helpers.ts: 类型安全 t + currentLocale(any中转内部1处带注释)
- 12文件改 i18n as any 样板收口: utils/time + stores(knowledge/project/{ideas,projects,tasks,workflow}) + composables(aiShared/useAiConversations/useAiEvents/useAiSend/useAiStream/useToolCard)
- as any 22→10(i18n 13→0对外), 签名统一(key, named?)
- useToolCard文档块同步(防AI被过时注释误导)
This commit is contained in:
@@ -11,22 +11,18 @@
|
||||
//! 及原 <script setup> 中仅依赖 i18n.t 的 toolResultSummary)。零行为变更,纯搬迁。
|
||||
//!
|
||||
//! 设计:
|
||||
//! - composable 内非组件上下文(无 setup),用 vue-i18n 全局实例的 t(对齐 aiShared.ts/
|
||||
//! useAiEvents.ts/useAiStream.ts 等同款约定),而非 useI18n()。
|
||||
//! - 非组件上下文(无 setup),用 @/i18n/i18n-helpers 的类型安全 t(规避 vue-i18n TS2589)。
|
||||
//! - 全部为纯函数(入参出参,无响应式无副作用),供 ToolCard.vue 模板/setup 直接 import 调用。
|
||||
//! - store 依赖的工具显示名(toolDisplayName/displayArgValue/projectNameById/taskNameById)
|
||||
//! 仍留 ToolCard.vue setup(耦合 projectStore,非纯函数)。
|
||||
//!
|
||||
//! 耦合:
|
||||
//! - i18n.global.t(翻译)
|
||||
//! - i18n 翻译(经 @/i18n/i18n-helpers)
|
||||
//! - AiToolCallInfo(@/api/types)
|
||||
|
||||
import i18n from '@/i18n'
|
||||
import { t } from '@/i18n/i18n-helpers'
|
||||
import type { AiToolCallInfo } from '@/api/types'
|
||||
|
||||
// composable 内非组件上下文(无 setup),用 vue-i18n 全局实例的 t 而非 useI18n()。
|
||||
const t = ((i18n as any).global.t as (k: string, p?: Record<string, unknown>) => string).bind((i18n as any).global)
|
||||
|
||||
/** 工具结果 JSON 已知字段(全可选;list_* 运行时返回数组,靠 Array.isArray 区分) */
|
||||
export interface ToolResult {
|
||||
path?: string
|
||||
|
||||
Reference in New Issue
Block a user