修复: vite加@路径别名(解决linter改i18n为@/i18n后5文件import解析失败)+CR-08 P2-7 store error fallback i18n(projects/ideas/workflow/knowledge/tasks补err块+全局t)

This commit is contained in:
lxy
2026-06-15 15:04:49 +08:00
parent d8f1d97804
commit d6eb8551da
6 changed files with 48 additions and 23 deletions
+7 -3
View File
@@ -1,13 +1,17 @@
import { ideaApi } from '../../api'
import i18n from '@/i18n'
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() {
try {
state.ideas = await ideaApi.list()
} catch (e: any) {
state.error = e?.toString() ?? '加载灵感失败'
state.error = e?.toString() ?? t('ideas.err.loadFailed')
}
}
@@ -17,7 +21,7 @@ export function createIdeasStore() {
state.ideas.push(record)
return record
} catch (e: any) {
state.error = e?.toString() ?? '创建灵感失败'
state.error = e?.toString() ?? t('ideas.err.createFailed')
return null
}
}
@@ -35,7 +39,7 @@ export function createIdeasStore() {
await ideaApi.delete(id)
state.ideas = state.ideas.filter(i => i.id !== id)
} catch (e: any) {
state.error = e?.toString() ?? '删除灵感失败'
state.error = e?.toString() ?? t('ideas.err.deleteFailed')
}
}