From f953ba32488d1e1fd96ff01856b74e345b1fe3b3 Mon Sep 17 00:00:00 2001 From: attacker Date: Sat, 11 Jul 2026 10:22:34 +0800 Subject: [PATCH] =?UTF-8?q?fix(U20):=20ESLint=20static-components=20?= =?UTF-8?q?=E6=B8=85=E9=9B=B6=20+=20CredDetailDialog=20=E5=86=85=E8=81=94?= =?UTF-8?q?=E7=BB=84=E4=BB=B6=E4=BF=AE=E5=A4=8D=20+=20i18n=20=E6=8D=9F?= =?UTF-8?q?=E5=9D=8F=E4=BF=AE=E5=A4=8D?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - CredDetailDialog.tsx: Field 内联组件提取为模块级 CredField (react-hooks/static-components 23→0) - 修复 8 处被批量正则损坏的 i18n.t() 调用 (i18n.t('>名称:') → 语义化键) - 6 处硬编码中文清零 (凭据详情/密钥数据/无/创建时间/更新时间/安全提示) - 新增 deploy.cred.sensitiveWarn i18n 键 (zh/en 对齐) - ESLint warnings 66→43 (-35%), errors=0, any=0, unused=0 - tsc -b=0, npm build✓ (17.29s), go build=0, 17/17 测试通过 --- PROJECT_EVALUATION.md | 2 +- ROADMAP.md | 1 + TDD_PLAN.md | 17 ++ .../credential-manager/CredDetailDialog.tsx | 160 ++++++++++-------- frontend/src/locales/en-US.json | 3 +- frontend/src/locales/zh-CN.json | 3 +- 6 files changed, 110 insertions(+), 76 deletions(-) diff --git a/PROJECT_EVALUATION.md b/PROJECT_EVALUATION.md index 9f8c942..b0d6f09 100644 --- a/PROJECT_EVALUATION.md +++ b/PROJECT_EVALUATION.md @@ -137,7 +137,7 @@ |------|------|:----------:| | 前端未使用变量/导入(ESLint no-unused-vars) | ~~218 处~~ → **0 处** | ~~P1~~ ✅ done | | 前端 console.log/console.error | ~~93 处~~ → **3 处** | ~~P1~~ ✅ done | -| 前端 React Hooks 关键规则(exhaustive-deps/set-state-in-effect/purity/immutability 等 6 大规则) | ~~82 处回归~~ → **0 处**(U12 修复 i18n 全量改造引入的回归) | ~~P1~~ ✅ done (U12) | +|| 前端 React Hooks 关键规则(exhaustive-deps/set-state-in-effect/purity/immutability/static-components 等 7 大规则) | ~~82 处回归~~ → **0 处**(U12 修复 i18n 全量改造引入的回归 + U20 修复 CredDetailDialog 内联组件 static-components 23→0) | ~~P1~~ ✅ done | | 后端 `_ =` 忽略错误 | ~~13 处(3 处中风险)~~ → **controller/middleware 层 DB 写入零忽略**(Q4+Q5 全量治理) | ~~P2~~ ✅ done | | 前端硬编码内网 IP(10.10.10.75 等) | 6+ 处 | P2 | | 后端告警引擎分布式安全 | ✅ Redis 分布式锁(SetNX + 60s TTL) | 后端 | ~~P2~~ done | diff --git a/ROADMAP.md b/ROADMAP.md index d8db8fd..c33d07a 100644 --- a/ROADMAP.md +++ b/ROADMAP.md @@ -513,6 +513,7 @@ services/api.ts (1324L) | Q38 | 前端巨型组件拆分(UnifiedQueryPanel 529L→353L (-33%),提取 unified-query/useLogQueryEngine.ts 295L 查询执行引擎 Hook + useLogExport.ts 62L 导出/复制 Hook,全项目最后一个 ≥500L 业务组件清零) | P0 | **done** | | U17 | K8s 残余组件 i18n 补全(NodeDetailPage 16 处硬编码中文清零 + 8 个 hash 键替换为语义化 k8s.nodeDetail.* 键 + DeploymentWorkload 12 处 toast/confirm 硬编码中文清零,zh/en 7564→7597 +33 键对齐) | P3 | **done** | | U19 | i18n hash 键清理(删除 866 个死 hash 键 + 重命名 21 个高频 live hash 键为语义化键名,zh/en 7597→6731 keys 对齐,文件 328KB→276KB (-16%),tsc -b=0,npm build✓,ESLint=0/66/0,17/17 测试通过) | P3 | **done** | +| U20 | ESLint static-components 清零 + CredDetailDialog 内联组件修复 + i18n 批量迁移损坏修复(CredDetailDialog.tsx `Field` 内联组件提取为模块级 `CredField` — 23 处 react-hooks/static-components 警告清零;修复 8 处被批量正则损坏的 `i18n.t()` 调用(`i18n.t('>名称:')` 等 → 语义化键);6 处硬编码中文清零;新增 `deploy.cred.sensitiveWarn` 键;ESLint warnings 66→43 (-35%),tsc -b=0,npm build✓ (17.29s),17/17 测试通过) | P3 | **done** | --- diff --git a/TDD_PLAN.md b/TDD_PLAN.md index 8914461..5740afc 100644 --- a/TDD_PLAN.md +++ b/TDD_PLAN.md @@ -1502,3 +1502,20 @@ curl -s -o /dev/null -w "%{http_code}" -H "Authorization: Bearer ${TOKEN}" "http - [x] Docker 部署 healthy,前端页面正常加载(HTTP 200) - [x] Pod 日志查看器功能不变(容器选择/行数限制/previous/sinceTime/关键字过滤+高亮/下载/刷新/实时流/暂停继续/全屏切换全部正常) +--- + +## U20: ESLint static-components 清零 + CredDetailDialog 内联组件修复 + i18n 损坏修复 [done] + +### 通过标准 +- [x] `react-hooks/static-components` 警告从 23 降至 **0**(CredDetailDialog.tsx `Field` 内联组件提取为模块级 `CredField`) +- [x] ESLint warnings 从 66 降至 **43**(-35%,全部剩余为 react-refresh/only-export-components 架构性约束 + 1 个 @tanstack/react-virtual 兼容性) +- [x] ESLint errors 保持 **0** +- [x] 修复 8 处被批量正则损坏的 `i18n.t()` 调用(`i18n.t('>名称:')` 等 → 语义化键如 `common.name`、`common.createdAt`) +- [x] 6 处硬编码中文清零(凭据详情、密钥数据、无、创建时间、更新时间、安全提示) +- [x] 新增 `deploy.cred.sensitiveWarn` i18n 键(zh/en 对齐) +- [x] `tsc -b` 零错误 +- [x] `npm run build` 零错误(✓ built in 17.29s) +- [x] `go build` 零错误 +- [x] 17/17 集成回归测试通过(零回归) +- [x] Docker 部署 healthy + diff --git a/frontend/src/components/deploy/credential-manager/CredDetailDialog.tsx b/frontend/src/components/deploy/credential-manager/CredDetailDialog.tsx index 021570e..441b226 100644 --- a/frontend/src/components/deploy/credential-manager/CredDetailDialog.tsx +++ b/frontend/src/components/deploy/credential-manager/CredDetailDialog.tsx @@ -19,7 +19,52 @@ export interface CredDetailDialogProps { credId: number | null; } -// 凭据详情弹窗 // Logan.Li +// --- Module-level Field component (avoids remount on parent re-render) --- + +interface CredFieldProps { + label: string; + value: unknown; + sensitive?: boolean; + fieldKey?: string; + showMap: Record; + onToggle: (key: string) => void; + onCopy: (val: string) => void; +} + +function CredField({ label, value, sensitive, fieldKey, showMap, onToggle, onCopy }: CredFieldProps) { + if (value === undefined || value === null || value === '') return null; + const isLong = typeof value === 'string' && value.length > 80; + const show = fieldKey ? showMap[fieldKey] : false; + return ( +
+
+ {label} +
+
+ {isLong ? ( +