refactor(quality): Q14 前端巨型组件拆分 — ServerManager 652L→442L (-32%), 提取 ServerTableSection (265L, 表格+工具栏+分页受控展示组件) + server-export-utils (57L, CSV 导出纯函数), 移除 12 个不再使用的 import, 零逻辑变更
This commit is contained in:
1 parent
8a11acd086
commit
02f3d75f56
6 files changed
+441
-244
No files matched your search
+51
@@ -1329,3 +1329,54 @@ python3 /srv/aiops/tests/integration_test.py --host 127.0.0.1 --port 8080 | tail
|
||||
- [x] 17/17 集成回归测试通过(零回归)
|
||||
- [x] Docker 部署 healthy,前端页面正常加载(HTTP 200)
|
||||
- [x] 日志中心查询面板功能不变(Loki/ES 双引擎查询/直方图/标签过滤/Live Tail/分享链接/保存查询/告警创建全部正常)
|
||||
|
||||
---
|
||||
|
||||
## Q14: 前端巨型组件拆分 — ServerManager
|
||||
|
||||
### 验证用例
|
||||
|
||||
```bash
|
||||
# U1: Go 编译
|
||||
cd /srv/aiops/backend && go build ./...
|
||||
# 期望: 零错误
|
||||
|
||||
# U2: TypeScript 编译
|
||||
cd /srv/aiops/frontend && npx tsc -b
|
||||
# 期望: 零错误
|
||||
|
||||
# U3: Vite 构建
|
||||
npm run build 2>&1 | tail -3
|
||||
# 期望: built in Ns
|
||||
|
||||
# U4: 拆分后文件行数
|
||||
wc -l src/components/server/ServerManager.tsx src/components/server/ServerTableSection.tsx src/components/server/server-export-utils.ts
|
||||
# 期望: ServerManager < 500L, 其余 < 270L
|
||||
|
||||
# U5: ESLint 全局指标
|
||||
npx eslint src/ --format json | python3 -c "
|
||||
import json, sys
|
||||
d = json.load(sys.stdin)
|
||||
print(f'errors={sum(1 for r in d for m in r[\"messages\"] if m[\"severity\"]==2)}')
|
||||
print(f'any={sum(1 for r in d for m in r[\"messages\"] if m.get(\"ruleId\")==\"@typescript-eslint/no-explicit-any\")}')
|
||||
"
|
||||
# 期望: errors=0, any=0
|
||||
|
||||
# U6: 集成测试
|
||||
python3 tests/integration_test.py --host 127.0.0.1 --port 8080
|
||||
# 期望: 17/17 passed
|
||||
```
|
||||
|
||||
### 通过标准
|
||||
- [x] ServerManager.tsx 从 652 行降至 **442 行**(< 500 ✅,-32%)
|
||||
- [x] 2 个提取文件全部 < 270 行(server-export-utils 57L + ServerTableSection 265L)
|
||||
- [x] `tsc -b` 零错误
|
||||
- [x] `npm run build` 零错误(✓ built in 16.40s)
|
||||
- [x] ESLint errors 保持 **0**(3 个文件零 errors/warnings)
|
||||
- [x] ESLint warnings 保持 **64**(无新增)
|
||||
- [x] 全局 ESLint any 保持 **0**
|
||||
- [x] `go build` 零错误
|
||||
- [x] 17/17 集成回归测试通过(零回归)
|
||||
- [x] Docker 部署 healthy,前端页面正常加载(HTTP 200)
|
||||
- [x] 服务器管理页功能不变(列表/搜索/筛选/分页/选择/批量删除/CSV 导出/创建编辑/终端/RDP/文件浏览全部正常)
|
||||
|
||||
Reference in new issue
Block a user