重构: 前端架构审查降技术债·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:
2026-06-19 12:25:10 +08:00
parent cfae6027d2
commit 11b579eb87
13 changed files with 48 additions and 52 deletions

View File

@@ -1,6 +1,6 @@
import { reactive, computed } from 'vue'
import { knowledgeApi } from '@/api'
import i18n from '@/i18n'
import { t } from '@/i18n/i18n-helpers'
import type {
KnowledgeRecord,
KnowledgeDetailPayload,
@@ -10,9 +10,6 @@ import type {
KnowledgeConfig,
} from '@/api/types'
// composable 外全局 i18n 实例(非 setup 上下文)
const t = ((i18n as any).global.t as (k: string) => string).bind((i18n as any).global)
// ── 全局响应式状态(单例) ──
const state = reactive({

View File

@@ -1,10 +1,7 @@
import { ideaApi } from '@/api'
import i18n from '@/i18n'
import { t } from '@/i18n/i18n-helpers'
import { state } from './state'
// composable 外全局 i18n 实例(非 setup 上下文)
const t = ((i18n as any).global.t as (k: string) => string).bind((i18n as any).global)
/** 灵感 CRUD 子 store(共享全局 state) */
export function createIdeasStore() {
async function loadIdeas() {

View File

@@ -1,11 +1,8 @@
import { projectApi } from '@/api'
import type { ImportProjectInput } from '@/api/project'
import i18n from '@/i18n'
import { t } from '@/i18n/i18n-helpers'
import { state, clearError } from './state'
// composable 外全局 i18n 实例(非 setup 上下文)
const t = ((i18n as any).global.t as (k: string) => string).bind((i18n as any).global)
/** 项目 CRUD 子 store(共享全局 state) */
export function createProjectsStore() {
async function loadProjects() {

View File

@@ -1,10 +1,7 @@
import { taskApi } from '@/api'
import i18n from '@/i18n'
import { t } from '@/i18n/i18n-helpers'
import { state } from './state'
// composable 外全局 i18n 实例(非 setup 上下文)
const t = ((i18n as any).global.t as (k: string) => string).bind((i18n as any).global)
/** 任务 CRUD 子 store(共享全局 state) */
export function createTasksStore() {
async function loadTasks(projectId?: string) {

View File

@@ -1,10 +1,7 @@
import { workflowApi } from '@/api'
import i18n from '@/i18n'
import { t } from '@/i18n/i18n-helpers'
import { state, _eventUnlisten, setEventUnlisten } from './state'
// composable 外全局 i18n 实例(非 setup 上下文)
const t = ((i18n as any).global.t as (k: string) => string).bind((i18n as any).global)
// B-03b-R10(⑦ 互斥): 审批响应/取消 IPC 进行中标记(模块级单例,createWorkflowStore 每会话只跑一次)。
// 防双击/连点在同一轮 IPC 未返回前发起第二次(后端无幂等键,第二次会重复消费 Request 触发
// "node already completed" 类报错)。store 层守卫优于按钮 disabled: 共享单例 state,跨调用方统一。