重构: 前端DRY(style全局沉淀 + ts/js公共沉淀)
style-dry: - 新增 src/styles/components.css: .info-item*/.panel/.panel-header/.tech-tag/.card-tags 全局 - main.ts 注册 import - 删重复: ProjectDetail/TaskDetail/TaskOutputCard/ProjectCard/Projects(scoped删重复, 全局对子组件生效) - 未使用清理: Projects .card-progress dead(1处保守核对) tsjs-dry: - aiShared.ts: resolveAiLang(合并useAiSend.resolveLang + useAiContext.resolveLanguage) - stores/knowledge.ts: kindText/kindLabel/kindIcon/knowledgeStatusLabel/knowledgeConfidenceLabel(5公共) - 删重复: useAiSend/useAiContext(resolveLang) + Knowledge/KnowledgeDetail(4+5 helper) + ActiveProjectsPanel(formatLastActivity→formatRelativeZh复用) strategy: DRY收口, 公共沉淀(utils/store/shared); relativeTime非纯重复保留; .btn/.empty-hint局部override WATCH未动
This commit is contained in:
@@ -12,11 +12,30 @@
|
||||
|
||||
import { aiApi } from '@/api'
|
||||
import { state } from '@/stores/ai'
|
||||
import { useAppSettingsStore } from '@/stores/appSettings'
|
||||
import i18n from '@/i18n'
|
||||
import type { AiToolCallInfo } from '@/api/types'
|
||||
|
||||
const appSettings = useAppSettingsStore()
|
||||
|
||||
const t = ((i18n as any).global.t as (k: string, named?: Record<string, unknown>) => string).bind((i18n as any).global)
|
||||
|
||||
/**
|
||||
* 解析 AI 回复语言(useAiSend.sendMessage / useAiContext.compressContext 共用)。
|
||||
*
|
||||
* df-ai-language='auto' → 回落到 df-language(应用主语言);否则用 df-ai-language 指定值;
|
||||
* 兜底 'zh-CN'。
|
||||
*
|
||||
* 原分别在 useAiSend.resolveLang(三元)与 useAiContext.resolveLanguage(if/else)各一份,
|
||||
* 语义相同仅写法不同,提取至此共用。
|
||||
*/
|
||||
export function resolveAiLang(): string {
|
||||
const raw = appSettings.get<string>('df-ai-language', 'auto')
|
||||
return raw === 'auto'
|
||||
? appSettings.get<string>('df-language', 'zh-CN')
|
||||
: raw
|
||||
}
|
||||
|
||||
/** 客户端消息自增 id(全局唯一,多个 composable 共用 nextMsgId) */
|
||||
let _msgCounter = 0
|
||||
|
||||
|
||||
Reference in New Issue
Block a user