重构: 前端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:
2026-06-19 12:11:19 +08:00
parent 64ece1d3a0
commit 7748e3ecbc
14 changed files with 177 additions and 212 deletions

View File

@@ -39,7 +39,7 @@
import { computed } from 'vue'
import { useI18n } from 'vue-i18n'
import { useProjectStore } from '@/stores/project'
import { parseTs } from '@/utils/time'
import { formatRelativeZh } from '@/utils/time'
const store = useProjectStore()
const { t } = useI18n()
@@ -59,17 +59,9 @@ function getProjectTaskCount(projectId: string): number {
return store.tasks.filter(t => t.project_id === projectId && t.status === 'in_progress').length
}
function formatLastActivity(iso: string): string {
const ms = parseTs(iso)
if (ms == null) return '—'
const diffMin = Math.floor((Date.now() - ms) / 60000)
if (diffMin < 1) return t('common.justNow')
if (diffMin < 60) return t('common.minutesAgo', { n: diffMin })
const diffH = Math.floor(diffMin / 60)
if (diffH < 24) return t('common.hoursAgo', { n: diffH })
const diffD = Math.floor(diffH / 24)
return t('common.dayAgo', { n: diffD })
}
// 相对时间复用 utils/time.formatRelativeZh(与 Tasks/AuditLog/MessageList 等同源,根治 NaN)
// 原 formatLastActivity 是其逐行复制,提取为单一来源。
const formatLastActivity = formatRelativeZh
const displayProjects = computed(() =>
store.projects.map(p => {