From 7748e3ecbc435f277dd8535769b7d5cdd332d26f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=BB=9D=E5=B0=98?= <237809796@qq.com> Date: Fri, 19 Jun 2026 12:11:19 +0800 Subject: [PATCH] =?UTF-8?q?=E9=87=8D=E6=9E=84:=20=E5=89=8D=E7=AB=AFDRY(sty?= =?UTF-8?q?le=E5=85=A8=E5=B1=80=E6=B2=89=E6=B7=80=20+=20ts/js=E5=85=AC?= =?UTF-8?q?=E5=85=B1=E6=B2=89=E6=B7=80)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 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未动 --- .../dashboard/ActiveProjectsPanel.vue | 16 +--- src/components/knowledge/KnowledgeDetail.vue | 30 ++----- src/components/project/ProjectCard.vue | 14 ---- src/components/task/TaskOutputCard.vue | 24 +----- src/composables/ai/aiShared.ts | 19 +++++ src/composables/ai/useAiContext.ts | 22 +----- src/composables/ai/useAiSend.ts | 24 +----- src/main.ts | 1 + src/stores/knowledge.ts | 34 ++++++++ src/styles/components.css | 79 +++++++++++++++++++ src/views/Knowledge.vue | 28 +++---- src/views/ProjectDetail.vue | 45 ++--------- src/views/Projects.vue | 17 +--- src/views/TaskDetail.vue | 36 +-------- 14 files changed, 177 insertions(+), 212 deletions(-) create mode 100644 src/styles/components.css diff --git a/src/components/dashboard/ActiveProjectsPanel.vue b/src/components/dashboard/ActiveProjectsPanel.vue index b7013b6..602721d 100644 --- a/src/components/dashboard/ActiveProjectsPanel.vue +++ b/src/components/dashboard/ActiveProjectsPanel.vue @@ -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 => { diff --git a/src/components/knowledge/KnowledgeDetail.vue b/src/components/knowledge/KnowledgeDetail.vue index f5c2ce6..7abc760 100644 --- a/src/components/knowledge/KnowledgeDetail.vue +++ b/src/components/knowledge/KnowledgeDetail.vue @@ -107,7 +107,13 @@