docs: update dev-log - AIPredictiveAnalytics 拆分
This commit is contained in:
1 parent
11c97cd885
commit
8da6ca15db
1 file changed
+25
@@ -1173,3 +1173,28 @@ cd ~/devops/aiops
|
||||
- 前端仍有接近700行可拆分: AIPredictiveAnalytics.tsx(670)、ApprovalFlow.tsx(666)、CloudBilling.tsx(663)、CronJobManager.tsx(652)、AppRelease.tsx(650)
|
||||
- sidebar.tsx(689行) 为 shadcn 标准 UI 组件,context 已提取,剩余无需拆分
|
||||
- 后端 sql_audit.go(435行) 属已移除菜单死代码(保留不拆)
|
||||
|
||||
|
||||
## 2026-06-16 自动推进(cron)
|
||||
|
||||
- **任务**: 拆分 AIPredictiveAnalytics.tsx(670行→417行),远离700行硬上限
|
||||
- **背景**: dev-log 上次建议的预防性维护项(继 AgentMonitor 拆分后,AIPredictiveAnalytics 是 AI 模块下一个最接近 700 行限制的业务组件)
|
||||
- **拆分方案**:
|
||||
- `frontend/src/components/aiops/predictUtils.ts` — **新建**(320行):集中导出 3 个 interface(PredictionMetric/CapacityForecast/AnomalyPrediction)+ 3 个常量(METRIC_DEFS/TIME_RANGE_LABELS/TIME_RANGE_HOURS)+ 5 个纯函数(linearRegression/extractSeries/parseThreshold/capacityRecommendation/anomalyAction)+ 1 个聚合推算函数 `computePredictions(inputs): ComputedPredictions`(统一指标预测+容量规划+异常预测的三大计算)+ `trendColorClass` 渲染辅助
|
||||
- `frontend/src/components/aiops/AIPredictiveAnalytics.tsx` — 主组件从 670 行降至 417 行(-253);删去 4 个本地 interface/3 const map/5 helper/3 段计算逻辑块;改为单次 `const {...} = computePredictions({ rawMetrics, serverStats, alertEvents, alertRules, selectedTimeRange })`;保留 `export type { CapacityForecast }` 兼容旧 import 路径;清理未使用 icon import (ArrowUpRight/Database)
|
||||
- `frontend/src/components/aiops/PredictiveCapacityTab.tsx` — CapacityForecast 类型改从 `./predictUtils` 导入(新规范位置)
|
||||
- **结果**:
|
||||
- `npx tsc --noEmit` 零错误 ✅
|
||||
- `npm run build` 通过(3.13s, 2598 modules) ✅
|
||||
- `./run.sh restart` 后 /health 正常 + 前端 200 ✅
|
||||
- 浏览器验证 `/aiops/predictive`(容量预测菜单):3 个 Tab 均正常渲染
|
||||
- 指标预测 Tab:CPU 10%→6%(下降)/内存 46%→46%(平稳)/磁盘 40%→40%(平稳),基于 48 个真实时序点
|
||||
- 容量规划 Tab:3 个资源卡片均显示(CPU 10%→-22%、内存 46%→43%、磁盘正常)
|
||||
- 异常预测 Tab:3 个告警预测(服务不可用60%/内存超阈值52%/磁盘超阈值48%)
|
||||
- 时间范围选择器验证:默认 24h→"预测值(24小时后)",切换到 7天→"预测值(7天后)"且 CPU 预测值更新为 0%(horizonHours 从 24→168),证明 `computePredictions()` 在 React state 变化时正确重算
|
||||
- console 零 JS 错误 ✅
|
||||
- git push 成功 (commit 11c97cd) ✅
|
||||
- **下一步建议**:
|
||||
- 前端仍有接近700行可拆分: ApprovalFlow.tsx(666)、CloudBilling.tsx(663)、CronJobManager.tsx(652)、AppRelease.tsx(650)
|
||||
- sidebar.tsx(689行) 为 shadcn 标准 UI 组件,context 已提取,剩余无需拆分
|
||||
- 后端 sql_audit.go(435行) 属已移除菜单死代码(保留不拆)
|
||||
Reference in new issue
Block a user