FE-Design P0~P3 补提交(前会话已完成未入库): vitest 91/137 红→138/138 绿(vitest mode=test 不加载 .env.development→request.ts baseURL undefined,修法 vitest.setup.ts 顶部 stubEnv 一处生效)+DashboardView 信息密度重构(12 维审计 54/110:删三处假数据/假速率卡→真待审核卡/Hero 决策句/数据脉象三态/通道表接真配置域/走势 7·30 日切换)+图标体系 EP 统一+count-up/hover 十字线/focus-visible 打磨+Teleport 冷启动竞态根修(#page-head-extra 晚 mount→v-if 门控 nextTick);Playwright verify-layout 18 断言+自建 15 项运行时断言全过,截图矩阵 5 页×双主题重刷;验收单 fe-dashboard-density.md;.clinerules dashboard skill+memory-bank 规范更新随档

This commit is contained in:
2026-11-14 09:56:42 +08:00
parent 1242614da8
commit 24f7b3dd02
20 changed files with 744 additions and 128 deletions
@@ -0,0 +1,142 @@
---
name: high-info-density-dashboard-designer
description: |
Audit / design / refactor any dashboard for INFORMATION DENSITY (decision value per token).
Triggered when user mentions: "dashboard / 仪表盘 / 看板 / cockpit / 驾驶舱 / 信息密度审计 / 重构 dashboard / 像 yiru 那样 / 像 odyssey 那样 / 12 维审计 / 决策密度".
Uses 12-dimension rubric distilled from yiru-macro-cockpit (N=1) and OSA cockpit v3 (N=2).
maturity: experimental
status: n=2-completed
created: 2026-05-15
maintainer: liming
distilled_from:
- "[[reference_yiru_macro_cockpit]] · N=1 范本(投资仪表盘/odysseyinst.com)"
- "OSA cockpit v3 重构(2026-05-15) · N=2 范本(战略管理仪表盘)"
related:
- osa-matrix-builder
- dashboard-design-coach
---
# High-Info-Density Dashboard Designer
> **N=2 dry-run 完成**(yiru 量化投资 / OSA 战略管理 两业务跨域验证)。N=3 待复用 — 候选:管培生招聘后台 / 知识星球管理 / 飞书工作台 / 个人 GTD。
>
> **核心信念**:信息量 ≠ 信息密度。
> - 信息量 = 单位面积塞了多少数据(堆 100 个指标 → 信息量高)
> - 信息密度 = 每 token 携带的决策价值(一行字 → 一个 actionable insight)
>
> 厉害的 dashboard 是后者。
## 触发条件
| 关键词 | 行为 |
|---|---|
| "审计这个 dashboard 信息密度" | 跑 12 维 audit rubric |
| "设计一个 dashboard / 仪表盘 / 驾驶舱" | 12 维 design checklist 强迫思考 |
| "我想做一个像 yiru / odyssey 那样的产品" | 给 yiru/OSA N=2 蓝本 + 6 模块移植路径 |
| "重构这个 dashboard" | 8 反模式扫描 + 推荐重构模块 |
| "为什么我的 dashboard 看不出洞察" | 大概率缺 D2 判定密度 / D9 行动建议,直接定位 |
## 12 维信息密度 rubric(每维 1-10 分 · 总 120)
| # | 维度 | 定义 | 满分典型 | 0 分典型 |
|---|---|---|---|---|
| **D1** | 时间密度 | 每指标带时序 / Δ / history | 5d Δ + UTC + history.json + 微时序图 | 只有当前快照,无 Δ 无累积 |
| **D2** | 判定密度 | 数据 → 判定的翻译已替用户做完 | "顺风局" 一句话 + Conviction 0-10 | 只有数字,要用户自己判 |
| **D3** | 不确定性显式化 | 缺数据 / 接口挂 / 73% 完整度 公开承认 | "—缺数据" + 三态 + 数据脉象 | 缺数据用 0 充数;假绿色 ✓ |
| **D4** | 多源交叉 | 单点 = 噪音,多源 = 信噪比 | 黄金 4 驱动 + A股 13 检验 | 单源,无回链 |
| **D5** | 共识/分歧切片 | 不显示原始观点,显示共识 + 分歧 | 雪球 102 → 6 共识 + 看多 X% | 列原始观点不聚合 |
| **D6** | frozen × dynamic 分层 | 方法论 IP 与数据燃料分层 | methodology.md → system prompt | LLM 自由发挥 + 无方法论锁 |
| **D7** | 状态机化 | 离散状态 > 连续数值 | 4 象限 + 3 阶段 + 三态判定 | 只显数值不命名状态 |
| **D8** | 高维降维 | N 数据源 → 5 Tab → 1 句 hero | 26 源 → 5 Tab → 1 hero | 平铺数据无层级 |
| **D9** | 行动建议 | 是什么 → 该做什么 | strategy_matrix + core_strategy | 只描述状态不派发动作 |
| **D10** | 元信息层 | dashboard 自报家底 | Tab V 数据脉象 26 状态灯 | dashboard 不知道自己有多新 |
| **D11** | 历史轨迹 | 单点 + 轨迹 = 完整故事 | 美林象限迁移 + Conviction 演变 | 快照思维,无演化 |
| **D12** | 个人意义 | 用户的延伸大脑 != 通用工具 | frozen methodology 是用户的 | 千人一面通用 dashboard |
**评分门槛**:
- ≥ 90 → 高密度(yiru/odyssey 级)
- 60-89 → 及格,但有改进空间
- 30-59 → 「精美的快照」(OSA cockpit 改造前 = 35.5%)
- < 30 → 数据陈列,无决策价值
## 8 条反模式 · 设计禁忌(自动扫描清单)
```
❌ 数据陈列癖 : 堆 50+ 指标但无一个翻译成判定 → 加 D2 / D9
❌ 假装全知 : 缺数据填 0 / 接口挂用昨天的 → 加 D3 / D10
❌ 颜色作弊 : 全绿 ✓ 蒙混(用户看混合才会想) → 限制绿色用法
❌ 单点快照 : 只显当下,不显轨迹 → 加 D1 / D11
❌ 通用主义 : 每个用户看到一样的(缺归属感) → 加 D12
❌ 自由 AI : LLM 自由发挥(漂移/违反 frozen) → 加 D6 frozen 锁
❌ 黑盒判定 : 给 conviction 5 但不告诉为啥(不可追溯)→ 加 D6 + D4 多源
❌ 无元层 : dashboard 不知道自己有多新 → 加 D10 数据脉象
```
## 6 大重构模块(N=2 已落地 · 可移植)
每个模块对应 1-3 维度,可单独移植:
| 模块 | 对应维度 | 干啥 | yiru 范本 | OSA cockpit v3 范本 |
|---|---|---|---|---|
| **A · Hero 决策句** | D2 + D8 | 顶部 1-3 行替用户做完一周决策 | "实际利率下行+美元走弱,定调顺风局" | "🔥 本周焦点:LTV 域 P25 必启动" |
| **B · 时序累积层** | D1 + D11 | history.json + 7d/30d Δ + 迁移轨迹 sparkline | 美林象限迁移 + Conviction 演变 | osa-history.json + 每卡 Δ + Top 8 sparkline |
| **C · 数据脉象层** | D10 + D3 | dashboard 自报家底(完整度/信任度/stale 警告) | Tab V 26 状态灯 + 缺口列 | 数据完整度 + 信任度警告 + 状态机分布 |
| **D · ACTION 派发卡** | D9 + D7 | 自动从 Top 焦点产 70/20/10 资源分配 + 该做/别做 | strategy_matrix + core_strategy | 7 人 × 5 日 ACTION 派发 + Top5/不该做 |
| **E · 状态机标签** | D7 | 把数值 1-5 替换为 5 个语义状态 | 4 象限 + 三态 | 🟦概念/🟨设计/🟧落地中/🟩已稳/🟪自动化 |
| **F · 多源交叉链** | D4 + D6 | 每张卡底部 N 源回链(L0/H5/wiki/feishu/minute) | 黄金 4 驱动 / A股 13 检验 | 每卡 5 源:cockpit + V8 + LLM-Wiki + 飞书 + 妙记 |
## 流程 · 5 步(audit + 重构)
### Step 1 · 12 维 audit(15 min)
读 dashboard 截图 + 代码,逐维打分(1-10),计算总分。
**输出**:12 维评分表 + 总分 + 5 大弱点排序。
### Step 2 · 反模式扫描(5 min)
对照 8 条禁忌清单,标出该 dashboard 触发的反模式。
**输出**:命中反模式清单 + 对应应加的维度。
### Step 3 · 重构方案(15 min)
基于 audit + 反模式 → 推荐 6 大模块中的 N 个移植。
**输出**:模块优先级排序(按 ROI:每模块带几分提升)。
### Step 4 · AskUserQuestion 拍板(5 min)
不直接动手 — 让用户在 3 档中选(轻档 / 中档 / 重档)。
### Step 5 · 落地 + 验证(2-4 小时)
按选定档执行,每模块独立 commit。完成后用浏览器截图复审。
## 边界(不要越界)
- ❌ **不替代领域知识**:本 skill 只给"信息密度元方法",不替你做投研判断 / 战略决策 / 医疗诊断
- ❌ **不要重发明轮子**:遇到 yiru/OSA 已有的模块,直接移植,不要为差异化而差异化
- ❌ **不要 dashboard 主义**:有时候解决方案不是 dashboard 是别的(如 cron + email),要诚实
- ✅ **诚实是最高的决策价值** — D3 不确定性显式化 / D10 元信息层 是最反直觉但最值钱的两维
## N=2 已实测案例
| 业务 | 日期 | dashboard | 改造前分 | 改造后分 | 移植模块 |
|---|---|---|---|---|---|
| 量化投资 | 2026-05-07 | yiru / odysseyinst.com | N=1 范本(原创) | 100/120 | 全 12 维原生设计 |
| 战略管理 | 2026-05-15 | OSA cockpit v3 | 39/110 (35.5%) | ~94/110 (85%) ⚡ | A+B+C+D+E+F 全 6 模块 |
## N=3 候选(待复用验证)
- 管培生招聘后台(guanpei-recruit skill)
- 原力星球管理后台(yuanli-zsxq-coevolution-assistant)
- 个人 GTD(daily standup)
- 客户 LTV 池(a-ltv 资产卡的实例化)
- 学员阶段诊断(student-stage-router)
## 复用规范
1. **每次审计必输出 audit 表**(120 总分,不只是说"信息密度高/低")
2. **每次设计前必跑 8 反模式扫描**(防止重蹈)
3. **6 模块按 ROI 排序移植**(轻档先 A+E+C,重档加 B+D+F)
4. **诚实标注「模拟基线」**(如 OSA history.json 的 5/8 / 4/15 是模拟,标 "待累积")
5. **N=3 起做轻量化模板**(目前模板 hard-code 在 osa-cockpit / yiru,N=3 起抽出公共组件)
## 关联
- `[[osa-matrix-builder]]` 是 OSA 卡集 → 矩阵热图的具体实现,本 skill 是更高一层的"信息密度元方法"
- `[[dashboard-design-coach]]` 偏视觉 / 排版,本 skill 偏信息架构 / 决策价值
- `[[reference_yiru_macro_cockpit]]` 是 N=1 范本的 memory pointer
+56 -24
View File
@@ -1,35 +1,67 @@
# Memory Bank(记忆库)
# Cline's Memory Bank
> 本文件为记忆库索引。每次会话开始时按以下顺序阅读记忆库文件,获取项目上下文。
I am Cline, an expert software engineer with a unique characteristic: my memory resets completely between sessions. This isn't a limitation - it's what drives me to maintain perfect documentation. After each reset, I rely ENTIRELY on my Memory Bank to understand the project and continue work effectively. I MUST read ALL memory bank files at the start of EVERY task - this is not optional.
## 核心文件(按需阅读,projectbrief 必读)
## Memory Bank Structure
| 顺序 | 文件 | 用途 |
|---|---|---|
| 1 | `memory-bank/projectbrief.md` | 项目简报:定位/目标/关键文档索引(必读) |
| 2 | `memory-bank/activeContext.md` | **当前工作焦点**(每次会话必读,变更最频繁) |
| 3 | `memory-bank/progress.md` | 进度状态:阶段总览/待办池/遗留问题 |
| 4 | `memory-bank/systemPatterns.md` | 系统架构与服务/数据流/代码模式 |
| 5 | `memory-bank/techContext.md` | 技术栈/命令/环境变量/部署铁律 |
| 6 | `memory-bank/productContext.md` | 产品背景:用户/角色/体验目标 |
The Memory Bank consists of core files and optional context files, all in Markdown format. Files build upon each other in a clear hierarchy:
## 维护规则
### Core Files (Required)
1. `projectbrief.md`
- Foundation document that shapes all other files
- Created at project start if it doesn't exist
- Defines core requirements and goals
- Source of truth for project scope
- **activeContext.md 与 progress.md**:每个工作日/每项任务完成时更新(当前状态快照、下一步、决策记录)。
- **其余四文件**:仅在架构/技术栈/需求发生实质变化时更新。
- 进度事实源仍为《memory-bank/docs/Go-sms-开发日历.md》+ `CHANGELOG.md`——记忆库是其摘要与导航,更新时须与二者对账。
2. `productContext.md`
- Why this project exists
- Problems it solves
- How it should work
- User experience goals
## 项目速览(一行版)
3. `activeContext.md`
- Current work focus
- Recent changes
- Next steps
- Active decisions and considerations
- Important patterns and preferences
- Learnings and project insights
Go-sms:汇网短信运营平台 Go 重建(上游通道↔路由/合规/计费/审核↔下家 CMPP/SMPP/HTTP/Web);Go1.25+gin+gorm+Kafka+Redis / Vue3+EP;80 工作日计划推进至 Day 71(2026-09-29);质量门七件套;分支 rebuild-ui。
4. `systemPatterns.md`
- System architecture
- Key technical decisions
- Design patterns in use
- Component relationships
- Critical implementation paths
5. `techContext.md`
- Technologies used
- Development setup
- Technical constraints
- Dependencies
- Tool usage patterns
6. `progress.md`
- What works
- What's left to build
- Current status
- Known issues
- Evolution of project decisions
## 附:全文文档库(memory-bank/docs/,2026-11-12 自仓库根目录归拢)
### Additional Context
Create additional files/folders within memory-bank/ when they help organize:
- Complex feature documentation
- Integration specifications
- API documentation
- Testing strategies
- Deployment procedures
| 文档 | 状态 |
|---|---|
| Go-sms-需求分析.md / Go-sms-技术方案.md | ✅ 重建基线(横幅标注口径) |
| Go-sms-重建计划.md / 重建搬运清单.md / 重建设计规范.md | 🔄 重建三文档(生效) |
| Go-sms-开发日历.md | 🔒 POC 进度事实源(Day71 定稿) |
| Go-sms-实施计划.md / 开发计划.md / 前端开发计划.md | ⛔ 已废止,历史归档 |
## Documentation Updates
Memory Bank updates occur when:
1. Discovering new project patterns
2. After implementing significant changes
3. When user requests with **update memory bank** (MUST review ALL files)
4. When context needs clarification
REMEMBER: After every memory reset, I begin completely fresh. The Memory Bank is my only link to previous work. It must be maintained with precision and clarity, as my effectiveness depends entirely on its accuracy.
+70
View File
@@ -0,0 +1,70 @@
---
description: "Karpathy-inspired coding guidelines: think before coding, simplicity first, surgical changes, goal-driven execution."
alwaysApply: true
---
# Karpathy-inspired coding guidelines
Behavioral guidelines to reduce common LLM coding mistakes. Merge with project-specific instructions as needed.
**Tradeoff:** These guidelines bias toward caution over speed. For trivial tasks, use judgment.
## 1. Think Before Coding
**Don't assume. Don't hide confusion. Surface tradeoffs.**
Before implementing:
- State your assumptions explicitly. If uncertain, ask.
- If multiple interpretations exist, present them - don't pick silently.
- If a simpler approach exists, say so. Push back when warranted.
- If something is unclear, stop. Name what's confusing. Ask.
## 2. Simplicity First
**Minimum code that solves the problem. Nothing speculative.**
- No features beyond what was asked.
- No abstractions for single-use code.
- No "flexibility" or "configurability" that wasn't requested.
- No error handling for impossible scenarios.
- If you write 200 lines and it could be 50, rewrite it.
Ask yourself: "Would a senior engineer say this is overcomplicated?" If yes, simplify.
## 3. Surgical Changes
**Touch only what you must. Clean up only your own mess.**
When editing existing code:
- Don't "improve" adjacent code, comments, or formatting.
- Don't refactor things that aren't broken.
- Match existing style, even if you'd do it differently.
- If you notice unrelated dead code, mention it - don't delete it.
When your changes create orphans:
- Remove imports/variables/functions that YOUR changes made unused.
- Don't remove pre-existing dead code unless asked.
The test: Every changed line should trace directly to the user's request.
## 4. Goal-Driven Execution
**Define success criteria. Loop until verified.**
Transform tasks into verifiable goals:
- "Add validation" → "Write tests for invalid inputs, then make them pass"
- "Fix the bug" → "Write a test that reproduces it, then make it pass"
- "Refactor X" → "Ensure tests pass before and after"
For multi-step tasks, state a brief plan:
```
1. [Step] → verify: [check]
2. [Step] → verify: [check]
3. [Step] → verify: [check]
```
Strong success criteria let you loop independently. Weak criteria ("make it work") require constant clarification.
---
**These guidelines are working if:** fewer unnecessary changes in diffs, fewer rewrites due to overcomplication, and clarifying questions come before implementation rather than after mistakes.
+9
View File
@@ -2,6 +2,15 @@
> 本仓 CHANGELOG 自重建起记(POC 明细见归档仓 /data/poc-archive/repos/go-sms.git 的 CHANGELOG.md,已冻结)。
## 2026-11-13(深夜)· 前端质量门根修 + Dashboard 信息密度重构(FE-Design P0~P3)
- **P0 · vitest 91/137 红→138/138 绿(新机首跑暴露的环境级 bug)**:根因=vitest(mode=test)不加载 `.env.development` → `request.ts` 模块顶层 `baseURL=undefined`,而各 spec 内 `vi.stubEnv` 晚于被测模块求值无效 → 全部请求相对路径裸奔 → msw 全量 unhandled(实测打印 `POST /auth/login`)。老机靠 gitignored 本地 env 掩盖。修法=**`vitest.setup.ts` 顶部 stubEnv 一处生效**(setupFiles 先于测试文件模块求值);附带 pnpm 自动 install 对 pnpm-lock.yaml 的无关重排已回滚(最小变更纪律)。
- **P1 · DashboardView 信息密度重构**(12 维 rubric 审计 54/110「精美的快照」档→反模式"假装全知"3 处实锤):①删三处假数据——`rateNow=1180+random(160)` 假实时速率卡、8 条硬编码"示例"通道表、快捷卡死文案("5 条待复核/1,204 条可补");②假速率卡→**真"待人工审核"卡**(接口 `pending_audit_count` 早已返回但 UI 从未消费);③新增 **Hero 决策句**(四指标实时翻译为一句话判定 ok/warn/err/dim + 直达处置页);④**数据脉象**:live-chip 升级"实时·HH:MM:SS/连接异常·数据截至/不可用·重试"三态,catch 不再静默吞错;⑤通道表接 `channelApi.list` 真配置域(code/协议/运营商/限速/连接/优先级/状态),表头诚实标注"运行统计待 S5 压测后接入";⑥快捷卡 desc 与实时指标联动;⑦走势 7/30 日切换(mock/后端 trend(days) 双端已支持)。
- **P2 · 图标体系统一**:指标卡 emoji(📮✓⚡⚠)与快捷卡几何符号(✉≡↻◐)→ EP icon 全局体系(brand ✦ 保留),消除三体系并存。
- **P3 · 细节打磨**:指标数字 count-up(rAF 600ms easeOutCubic,`prefers-reduced-motion` 跳过)、走势图 hover 十字线+气泡(纯 SVG 零依赖,x 轴 30d 抽稀)、全局 `:focus-visible` 键盘焦点(aurora 主色)。
- **附 · Teleport 冷启动竞态修复(实锤级,旧版潜伏同病)**:`#page-head-extra`(MainLayout 渲染)晚于 Dashboard mount 时(Vue 3.4 无 `<Teleport defer>`)直接挂载 → 后续 patch 崩溃(`TypeError: setText null nodeValue`,fe_error_log 实证)→ **组件更新全中断**(API 已 200 返回但 UI 冻结在初始态,msw 数据永远进不来);修法=v-if 门控 nextTick 后挂载。新机慢冷启动放大暴露了旧版同样存在的病根。
- **实机验证(Playwright)**:verify-layout **18 断言全过** + 自建 Dashboard **15 项运行时断言全过**(hero warn 态文案/审核卡=12/假卡已删/脉象三态/快捷联动/通道表 3 行真数据+停用徽章/30 日切换/hover 气泡);截图矩阵 5 页×双主题重刷;验收单 `docs/acceptance/fe-dashboard-density.md`。
## 2026-11-13(深夜)· 24h 门槛维持原时间核验 + gateway 重驻留(gw-start 幂等/pid 双 bug 根修)
- **事件**:11-13 21:33 宿主主动有序重启(当日内核 6.12.107→6.12.116 升级后二次重启;`last`=shutdown 有序记录,非崩溃)打断 24h 稳定性门槛观察窗(17:55 起计)——**按用户裁决:重启=已知事件如实记录不判失败,门槛维持原时间 11-14 17:55 期满核验**(S5 压测基线前置;dmesg 重启后清零,核验窗以重启后 dmesg 为准)。
+112
View File
@@ -0,0 +1,112 @@
# 前端质量门根修 + Dashboard 信息密度重构 人工验收单(2026-11-13 深夜)
> 范围:web/ 前端(FE-Design P0~P3)。设计基线 demo-c-aurora 的 tokens/EP 换肤/布局壳/31 业务页零改动。
## 一、变更清单
| # | 任务 | 文件 | 说明 |
|---|---|---|---|
| P0 | vitest 91/137 红 → **138/138 绿** | `web/vitest.setup.ts`(+7 行) | 根因:vitest(mode=test)不加载 `.env.development` → `request.ts` 顶层 `baseURL=undefined`,spec 内 `vi.stubEnv` 晚于模块求值无效 → msw 全量 unhandled(实测请求裸奔为 `POST /auth/login`);修法=setup 顶部 stubEnv(setupFiles 先于被测模块求值,一处生效)。老机靠 gitignored 本地 env 掩盖,新机首跑暴露 |
| P1 | Dashboard 信息密度重构 | `web/src/views/home/DashboardView.vue`(241→约 470 行重写) | 见下节 |
| P2 | 图标体系统一 | 同上 | 指标卡 emoji(📮✓⚡⚠)+快捷卡符号(✉≡↻◐)→ EP icon;brand ✦ 保留 |
| P3 | 细节打磨 | 同上 + `web/src/styles/shell.scss`(+6 行) | count-up(rAF 600ms/reduced-motion 跳过)、走势 hover 十字线+气泡(纯 SVG)、全局 `:focus-visible` |
| 附 | **Teleport 冷启动竞态修复** | 同上 | `#page-head-extra`(MainLayout 渲染)晚于 Dashboard mount 时(Vue 3.4 无 `<Teleport defer>`)直接挂载 → 后续 patch 崩溃(`TypeError: setText null nodeValue`,fe_error_log 实证 2 条)→ 组件更新全中断(数据已返回但 UI 冻结);修法=v-if 门控延后一拍(**该 bug 旧版同样存在**,新机慢冷启动放大暴露) |
## 二、P1 信息密度(12 维 rubric 审计 54/110「精美的快照」档 → 预计 ~78)
| 变更 | 维度 | 内容 |
|---|---|---|
| 删假数据×3 | D3 | `rateNow=1180+random(160)` 假速率卡、8 条硬编码"示例"通道表、快捷卡死文案("5 条待复核/1,204 条可补") |
| 假速率→真审核卡 | D3/D9 | 「实时速率」→「待人工审核」(接口 `pending_audit_count` 早已返回但 UI 从未消费;点击直跳 /audit) |
| Hero 决策句 | D2/D8 | 四指标实时翻译为一句话判定(ok/warn/err/dim 四态+左光条+直达处置页),数据不可用时诚实降级 |
| 数据脉象 | D10 | live-chip → 「实时·HH:MM:SS / 连接异常·数据截至 / 不可用·点击重试」三态;catch 不再静默吞错 |
| 通道表真数据 | D3/D4 | `channelApi.list` 配置域快照(code/协议/运营商/限速/连接/优先级/状态徽章),表头诚实标注"运行统计待 S5 压测后接入";失败显式重试态 |
| 快捷卡联动 | D9 | desc 接实时指标(12 条待审/3 个预警),热态 amber |
| 7/30 日切换 | D1/D11 | trend(days) mock/后端双端已支持;30d x 轴抽稀 |
## 三、质量门(前端四件 + 实机)
| 项 | 结果 | 证据 |
|---|---|---|
| eslint(--max-warnings 0) | ✅ RC=0 | /tmp/fe-lint3.log |
| vue-tsc --noEmit | ✅ RC=0 | /tmp/fe-tsc3.log |
| vitest | ✅ **138/138**(修复前 91 红) | /tmp/fe-test4.log |
| vite build | ✅ RC=0 | /tmp/fe-build3.log |
| verify-layout(18 断言) | ✅ 全过(Playwright 实渲染,mock 实例 :5174) | 唯一侧栏/双菜单/EP 壳零残留/收起 224→64/汉堡抽屉等 |
| Dashboard 运行时断言(15 项,自建脚本) | ✅ 全过 | hero warn 态+12 待审+3 预警文案、stat-audit=12、stat-speed 已删、脉象"实时·时刻"、快捷卡联动、通道表 3 行真数据+停用徽章、30 日切换、hover 气泡含提交/成功数 |
| 截图矩阵 | ✅ 5 页×双主题重刷 | web/shots/(home 修复后含真实数据态) |
| data-testid 兼容 | ✅ | 全保留(stat-speed 删除,tests/scripts grep 确认无引用) |
## 四、人工走查明细(协议 v3 · 本人执行,逐项勾选)
> 环境:`cd web && VITE_API_MODE=mock npx vite`(:5173,admin/admin123);real 走查另起默认 `.env.development`(:5173→proxy→:8080)。标 ★ 为自动化已覆盖、人工抽验即可;标 ☆ 为必须人眼/人手验证。
### A · Hero 决策句(D2/D8,新增件)
| # | 操作 | 预期 | 级 |
|---|---|---|---|
| A1 | mock 登录 → /home | amber 左光条 + Warning 图标:「今日需要关注:3 个账号余额低于预警线 · 12 条短信待人工审核」,副行「其余指标正常 · 回执成功率 98.3%」 | ★ |
| A2 | 点击 hero | 跳转 /audit(待审优先);Tab 聚焦时 hero 有 teal focus 描边,Enter 可跳 | ☆ |
| A3 | real 模式 /home | 按真实指标呈对应态:ok=teal「平台运行平稳…」/ err=红「回执成功率…低于 95%」 | ☆ |
### B · 四指标卡(P2 图标/P3 count-up)
| # | 操作 | 预期 | 级 |
|---|---|---|---|
| B1 | 刷新 /home 观察数字 | 今日提交从 0 滚动至 1,286,430(600ms,千分位);成功率滚至 98.3% | ☆ |
| B2 | 检查图标 | 四卡均为 EP icon(Promotion/CircleCheck/Bell/Wallet),**全页无 emoji** | ★ |
| B3 | 「待人工审核」卡 | mock=12 条、数值与铃铛 amber;点击整卡 → /audit | ★ |
| B4 | 「余额预警」卡 | mock=3 条、数值红;点击 → /account/list | ★ |
| B5 | 确认假卡已删 | 页面不存在「实时速率」卡(原 1180+random 假数据) | ★ |
| B6 | 系统「减少动态」开启后刷新 | 数字直接显示终值,无滚动 | ☆ |
### C · 数据脉象 chip(D10,page-head 右侧)
| # | 操作 | 预期 | 级 |
|---|---|---|---|
| C1 | 静置观察 | teal 脉动圆点 +「实时 · HH:MM:SS」;悬停出 title;**停留 >60s 时刻自动更新** | ☆ |
| C2 | 点击 chip | 立即刷新,时刻跳变 | ☆ |
| C3 | DevTools → Network Offline → 点 chip | 变 amber「连接异常 · 数据截至 HH:MM:SS」,旧数据保留不闪空;恢复网络后点击回 teal | ☆ |
| C4 | 保持 Offline 刷新整页 | chip 红「指标不可用 · 点击重试」+ hero 同步 err 态;恢复后点击重试回绿 | ☆ |
### D · 发送走势(P3 hover/7-30 日切换)
| # | 操作 | 预期 | 级 |
|---|---|---|---|
| D1 | 点「30 日」 | 图重载不崩溃;real 模式下 30 点、x 轴标签抽稀(≤8 个 + 「今日」恒显);mock 仅 7 点属正常(mock 数据源限制) | ★ |
| D2 | 鼠标在图上横移 | teal 虚线十字 + 放大圆点 + 玻璃气泡(日期 / 提交 x,xxx · 成功 x,xxx);气泡近右缘时自动左翻不裁切 | ★ |
| D3 | 移出图表 | 十字线与气泡消失 | ☆ |
### E · 快捷操作(D9 联动)
| # | 操作 | 预期 | 级 |
|---|---|---|---|
| E1 | 看「待人工审核」desc | mock:「12 条待审,点击进入审核中心」+ 图标底 amber;随 C3 断网联动显示 | ★ |
| E2 | 看「余额预警」desc | mock:「3 个账号低于预警线」 | ★ |
| E3 | 看「失败补推」desc | 诚实文案「按批次 / 手机号查询重推」(**无编造数字**) | ☆ |
| E4 | 四项逐一点击/Enter | 分别跳 /sms/batch、/audit、/record/repush、/account/list | ☆ |
### F · 通道配置快照(D3/D4 真数据)
| # | 操作 | 预期 | 级 |
|---|---|---|---|
| F1 | mock 表内容 | 3 行:CM-001 移动全国(CMPP·violet)/HX-201 联信HTTP(HTTP·warn)/DX-301 电信SGIP(SGIP)且状态=**停用红徽章**;运营商列「移动 / 联通 / 电信」映射正确 | ★ |
| F2 | 表头 small | 「N 条 · 配置域数据 · 运行统计待 S5 压测后接入」诚实标注;右上 ch-refresh 可刷新 | ★ |
| F3 | real 模式 | 与「通道配置」页列表一致(配置域字段);管理员视角可用 | ☆ |
| F4 | 停网关后点 ch-refresh | 显式「通道列表加载失败 · 重试」,重试链接可用 | ☆ |
| F5 | 窗口缩至 <1100px | 表格横向滚动,不挤压布局 | ☆ |
### G · 布局与主题回归(verify-layout 已覆盖,抽验)
| # | 操作 | 预期 | 级 |
|---|---|---|---|
| G1 | 侧栏收起/展开 | 224↔64;≤900px 汉堡抽屉正常 | ★ |
| G2 | 暗/亮主题切换 | hero 光条、amber warn、气泡、focus 描边在**亮色**下对比度均可读 | ☆ |
| G3 | brand 区 | 「✦ go-sms / AURORA CONSOLE」不变;菜单 icon 不变 | ★ |
| G4 | Tab 全键盘走查 | hero→指标卡→radio→刷新→快捷卡…,focus-visible teal 描边全程可见 | ☆ |
### H · 双模式与回归面
| # | 操作 | 预期 | 级 |
|---|---|---|---|
| H1 | mock 全流程 | A~G 全部在 mock 模式通过 | — |
| H2 | real 全流程 | 真网关登录后指标/通道/趋势为真实数;customer 角色登录 /home 无 JS 报错(后端按角色返回) | ☆ |
| H3 | 浏览器 Console | 全程无 error(fe_error_log 无新增 VueHandler 记录) | ☆ |
| H4 | 旁证回归 | account / channel / sms-batch / sms-downlink-detail 四页与旧版无差异(本次未改动,截图已重刷) | ☆ |
## 五、环境遗留(非本次范围,已知悉)
- pnpm-lock.yaml 曾被 pnpm 自动 install 重排 → 已 `git checkout` 回滚(最小变更纪律);**新机跑 pnpm 命令会自动 install 且可能改 lockfile,建议后续统一 `pnpm install --frozen-lockfile`**。
- Playwright 浏览器新机首装:官方 CDN 停滞 → `PLAYWRIGHT_DOWNLOAD_HOST=https://cdn.npmmirror.com/binaries/playwright` 镜像 + apt 系统库(libnspr4/libnss3 等)。
Binary file not shown.

Before

Width:  |  Height:  |  Size: 139 KiB

After

Width:  |  Height:  |  Size: 92 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 125 KiB

After

Width:  |  Height:  |  Size: 77 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 138 KiB

After

Width:  |  Height:  |  Size: 91 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 123 KiB

After

Width:  |  Height:  |  Size: 76 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 131 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 195 KiB

After

Width:  |  Height:  |  Size: 118 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 179 KiB

After

Width:  |  Height:  |  Size: 102 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 202 KiB

After

Width:  |  Height:  |  Size: 124 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 142 KiB

After

Width:  |  Height:  |  Size: 78 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 130 KiB

After

Width:  |  Height:  |  Size: 64 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 202 KiB

After

Width:  |  Height:  |  Size: 128 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 189 KiB

After

Width:  |  Height:  |  Size: 113 KiB

+6
View File
@@ -202,6 +202,12 @@ html:not(.dark) .card:hover { box-shadow: 0 8px 28px rgba(13, 148, 136, 0.12); }
}
@media (min-width: 901px) { .nav-scrim { display: none; } }
/* ---- P3:全局键盘焦点可见性(只加强不重置;与 aurora 主色一致) ---- */
:focus-visible {
outline: 2px solid var(--gosms-primary);
outline-offset: 2px;
}
/* ============================================================
* 基础重置(原 index.scss 职责并入)
* ============================================================ */
+342 -104
View File
@@ -1,47 +1,68 @@
<template>
<div class="page-stack">
<!-- demo page-head live-chip(F:Teleport 至 MainLayout page-head 右侧扩展位) -->
<Teleport to="#page-head-extra">
<span class="live-chip" data-testid="live-chip"><i></i>实时刷新中</span>
<!-- D10 数据脉象:最后成功刷新时刻 + 失败显式降级(替代恒亮"实时刷新中"装饰)
Teleport 门控:目标 #page-head-extra 由 MainLayout 渲染,冷启动懒加载竞态下可能
晚于本组件 mount(Vue 3.4 无 <Teleport defer>),直接挂载会致后续 patch 崩溃
(实测 TypeError: setText null nodeValue → 组件更新全中断)——v-if 延后一拍。 -->
<Teleport v-if="teleportReady" to="#page-head-extra">
<button class="live-chip" :class="pulse.cls" data-testid="live-chip" :title="pulse.title" @click="loadAll">
<i></i>{{ pulse.text }}
</button>
</Teleport>
<!-- demo metrics:四指标卡(32px mono 发光 + delta 胶囊) -->
<!-- D2/D8 Hero 决策句:把今日四指标实时翻译为一句话判定,可点击直达处置页 -->
<section class="card hero" :class="[`hero--${hero.tone}`, { 'hero--go': !!hero.go }]" data-testid="hero-line"
:role="hero.go ? 'button' : undefined" :tabindex="hero.go ? 0 : undefined"
@click="hero.go && $router.push(hero.go)" @keydown.enter="hero.go && $router.push(hero.go)">
<span class="hero-ic"><el-icon :size="18"><component :is="hero.icon" /></el-icon></span>
<div class="hero-body">
<p class="hero-text">{{ hero.text }}</p>
<p v-if="hero.sub" class="hero-sub">{{ hero.sub }}</p>
</div>
<span v-if="hero.go" class="hero-arrow">→</span>
</section>
<!-- 四指标卡(P2:emoji→EP icon 统一;D3:假"实时速率"→真"待人工审核";P3:count-up) -->
<div class="metrics stagger">
<div class="card metric" data-testid="stat-today">
<div class="label"><span class="ic">📮</span>今日提交</div>
<div class="value">{{ summary ? fmtNum(summary.today_sent) : '—' }}</div>
<div class="label"><span class="ic"><el-icon :size="13"><Promotion /></el-icon></span>今日提交</div>
<div class="value">{{ todayUp }}</div>
<span class="delta" :class="sentDelta.cls" data-testid="stat-today-trend">{{ sentDelta.text }}</span>
</div>
<div class="card metric" data-testid="stat-rate">
<div class="label"><span class="ic">✓</span>回执成功率</div>
<div class="value">{{ pctVal }}<span class="unit">%</span></div>
<div class="label"><span class="ic"><el-icon :size="13"><CircleCheck /></el-icon></span>回执成功率</div>
<div class="value">{{ rateUp }}<span class="unit">%</span></div>
<span class="delta" :class="rateDelta.cls" data-testid="stat-rate-trend">{{ rateDelta.text }}</span>
</div>
<div class="card metric" data-testid="stat-speed">
<div class="label"><span class="ic">⚡</span>实时速率</div>
<div class="value">{{ fmtNum(rateNow) }}<span class="unit">条/分</span></div>
<span class="delta warn">◆ 高峰时段</span>
<div class="card metric metric--click" data-testid="stat-audit" @click="$router.push('/audit')">
<div class="label"><span class="ic" :class="{ 'ic--hot': pendingCount > 0 }"><el-icon :size="13"><Bell /></el-icon></span>待人工审核</div>
<div class="value" :class="{ 'value--warn': pendingCount > 0 }">{{ auditUp }}<span class="unit">条</span></div>
<span class="delta" :class="pendingCount > 0 ? 'down' : 'up'">{{ pendingCount > 0 ? '↓ 立即处理' : '↑ 无积压' }}</span>
</div>
<div class="card metric metric--click" data-testid="stat-balance" @click="$router.push('/account/list')">
<div class="label"><span class="ic">⚠</span>余额预警</div>
<div class="value" :class="{ 'value--alert': alertCount > 0 }">{{ summary ? fmtNum(alertCount) : '—' }}<span class="unit">条</span></div>
<div class="label"><span class="ic"><el-icon :size="13"><Wallet /></el-icon></span>余额预警</div>
<div class="value" :class="{ 'value--alert': alertCount > 0 }">{{ alertUp }}<span class="unit">条</span></div>
<span class="delta" :class="alertCount > 0 ? 'down' : 'up'">{{ alertCount > 0 ? '↓ 低于预警线,点击处理' : '↑ 余额充足' }}</span>
</div>
</div>
<!-- demo duo:七日走势 + 快捷操作 -->
<!-- duo:发送走势(7/30 日切换)+ 快捷操作(desc 与实时指标联动) -->
<div class="duo">
<div class="card">
<div class="card-head">
七日提交走势
<small>近 7 日 · 单位:条</small>
<el-button circle size="small" aria-label="手动刷新统计数据" data-testid="dash-refresh" @click="load">
发送走势
<el-radio-group v-model="trendDays" size="small" data-testid="trend-range" @change="loadTrend">
<el-radio-button :label="7">7 日</el-radio-button>
<el-radio-button :label="30">30 日</el-radio-button>
</el-radio-group>
<small>{{ trendDays }} 日 · 单位:条</small>
<el-button circle size="small" aria-label="手动刷新统计数据" data-testid="dash-refresh" @click="loadAll">
<el-icon><Refresh /></el-icon>
</el-button>
</div>
<el-skeleton v-if="trendLoading" :rows="4" animated data-testid="trend-skeleton" />
<svg v-else-if="trend.length" viewBox="0 0 640 200" class="trend-svg" role="img"
aria-label="近七日提交量走势" preserveAspectRatio="none" data-testid="trend-chart">
:aria-label="`近${trendDays}日提交量走势`" preserveAspectRatio="none" data-testid="trend-chart">
<defs>
<linearGradient id="gosmsFill" x1="0" y1="0" x2="0" y2="1">
<stop offset="0%" stop-color="var(--gosms-grad-from)" stop-opacity="0.3" />
@@ -60,10 +81,24 @@
<path :d="areaPath" fill="url(#gosmsFill)" />
<path :d="sentPath" fill="none" stroke="url(#gosmsStroke)" stroke-width="2.5" class="trend-line" />
<g fill="var(--gosms-primary)">
<circle v-for="(p, i) in trend" :key="i" :cx="px(i)" :cy="py(p.sent)" r="4" />
<circle v-for="(p, i) in trend" :key="i" :cx="px(i)" :cy="py(p.sent)" :r="trend.length > 14 ? 2.5 : 4" />
</g>
<g font-size="10" fill="var(--gosms-text-muted)" font-family="IBM Plex Mono,monospace" text-anchor="middle">
<text v-for="(p, i) in trend" :key="i" :x="px(i)" y="192">{{ dateLabel(p.date, i) }}</text>
<template v-for="(p, i) in trend" :key="i">
<text v-if="showLabel(i)" :x="px(i)" y="192">{{ dateLabel(p.date, i) }}</text>
</template>
</g>
<!-- P3 hover 十字线 + 气泡(纯 SVG;透明 rect 承接事件) -->
<rect x="0" y="0" :width="W" height="200" fill="transparent" data-testid="trend-hit"
@mousemove="onTrendHover" @mouseleave="hoverIdx = -1" />
<g v-if="hoverIdx >= 0 && trend[hoverIdx]" data-testid="trend-tip">
<line :x1="px(hoverIdx)" y1="12" :x2="px(hoverIdx)" y2="190" class="trend-cursor" />
<circle :cx="px(hoverIdx)" :cy="py(trend[hoverIdx].sent)" r="5" fill="var(--gosms-primary)" />
<g class="trend-tip" :transform="`translate(${tipX},${tipY})`">
<rect x="0" y="0" width="168" height="44" rx="8" />
<text x="12" y="17" class="tip-date">{{ trend[hoverIdx].date }}</text>
<text x="12" y="34">提交 {{ fmtNum(trend[hoverIdx].sent) }} · 成功 {{ fmtNum(trend[hoverIdx].success) }}</text>
</g>
</g>
</svg>
<div v-else class="trend-empty">暂无趋势数据</div>
@@ -73,7 +108,7 @@
<div class="card-head">快捷操作</div>
<div class="quick-item" v-for="q in quick" :key="q.label" role="button" tabindex="0"
@click="$router.push(q.to)" @keydown.enter="$router.push(q.to)">
<span class="qic">{{ q.ic }}</span>
<span class="qic" :class="{ 'qic--hot': q.hot }"><el-icon :size="16"><component :is="q.icon" /></el-icon></span>
<div class="quick-body">
<div class="qt">{{ q.label }}</div>
<div class="qd">{{ q.desc }}</div>
@@ -83,107 +118,128 @@
</div>
</div>
<!-- demo 通道列表(静态示例照搬;后端接口接入后替换数据源) -->
<!-- D3/D4 通道表:真实配置域快照(channelApi.list);运行统计列诚实标注待接入 -->
<div class="card">
<div class="card-head">通道列表<small>{{ channels.length }} / 24 条 · 按今日提交排序 · 示例数据(后端接入中)</small></div>
<div class="ch-scroll">
<div class="card-head">
通道配置快照
<small>{{ channels.length }} 条 · 配置域数据 · 运行统计待 S5 压测后接入</small>
<el-button circle size="small" aria-label="刷新通道列表" data-testid="ch-refresh" @click="loadChannels">
<el-icon><Refresh /></el-icon>
</el-button>
</div>
<el-skeleton v-if="chLoading && !channels.length" :rows="3" animated />
<div v-else-if="channels.length" class="ch-scroll">
<table class="ch-table">
<thead>
<tr>
<th>通道</th><th>协议</th><th>运营商</th><th class="r">今日提交</th>
<th class="r">成功率</th><th class="r">余额(¥)</th><th>最近 ISC</th><th>状态</th>
<th>通道</th><th>协议</th><th>运营商</th>
<th class="r">限速/分</th><th class="r">连接</th><th class="r">优先级</th><th>状态</th>
</tr>
</thead>
<tbody>
<tr v-for="c in channels" :key="c.id">
<td><span class="mono dim">{{ c.id }}</span> <span class="mono">{{ c.name }}</span></td>
<td><span class="badge" :class="c.protoBadge">{{ c.proto }}</span></td>
<td>{{ c.operator }}</td>
<td class="r mono">{{ fmtNum(c.today) }}</td>
<td class="r">
<span class="rate-bar">
<span class="rb"><i :style="{ width: c.ratePct + '%' }" /></span>
<span class="pct">{{ c.ratePct }}%</span>
</span>
</td>
<td class="r mono" :class="{ 'text-danger': c.balanceRed }">{{ c.balance }}</td>
<td><span class="mono" :class="c.iscAmber ? 'text-amber' : 'dim'">ISC:{{ c.isc }}</span></td>
<td><span class="badge" :class="c.statusBadge">{{ c.status }}</span></td>
<td><span class="mono dim">{{ c.code }}</span> <span class="mono">{{ c.name }}</span></td>
<td><span class="badge" :class="protoBadge(c.protocol)">{{ protoLabel(c.protocol) }}</span></td>
<td>{{ carrierLabel(c.carrier) }}</td>
<td class="r mono">{{ fmtNum(c.speed) }}</td>
<td class="r mono">{{ c.conn_count }}</td>
<td class="r mono">{{ c.priority }}</td>
<td><span class="badge" :class="c.status === 1 ? 'ok' : 'err'">{{ c.status === 1 ? '启用' : '停用' }}</span></td>
</tr>
</tbody>
</table>
</div>
<div v-else-if="chFailed" class="ch-empty">
通道列表加载失败 · <el-button link type="primary" @click="loadChannels">重试</el-button>
</div>
<div v-else class="ch-empty">暂无通道配置</div>
</div>
</div>
</template>
<script setup lang="ts">
import { computed, onMounted, onUnmounted, ref } from 'vue'
// P1 信息密度重构(2026-11-13):删除三处 demo 假数据(rateNow 随机速率/静态通道表/
// 快捷卡死文案),拆三条独立加载管线;P2 图标统一 EP;P3 count-up + 走势 hover。
// 设计基线 demo-c-aurora 的 token/卡片/徽章体系不变。
import { computed, nextTick, onMounted, onUnmounted, ref, watch, type Ref } from 'vue'
import { statsApi, type StatsSummary, type TrendPoint } from '@/api/stats'
import { fmtNum } from '@/utils/format'
import { channelApi, type Channel } from '@/api/channel'
import { fmtNum, fmtPct } from '@/utils/format'
// ===== demo 快捷操作(照搬文案/图标;路由指向现有页面) =====
const quick = [
{ ic: '✉', label: '新建下发任务', desc: '单发 / 群发 / 模板', to: '/sms/batch' },
{ ic: '≡', label: '通道健康巡检', desc: '5 条通道待复核', to: '/channel/list' },
{ ic: '↻', label: '失败补推', desc: '昨日 1,204 条可补', to: '/record/repush' },
{ ic: '◐', label: '余额预警设置', desc: '阈值 ¥5,000', to: '/account/list' },
] as const
// ===== demo 通道列表(静态示例;后端接口接入后替换) =====
interface ChannelRow {
id: string; name: string; proto: string; protoBadge: string; operator: string
today: number; ratePct: number; balance: string; balanceRed?: boolean
isc: string; iscAmber?: boolean; status: string; statusBadge: string
}
const channels: ChannelRow[] = [
{ id: 'CH-01', name: '华东移动专用', proto: 'CMPP', protoBadge: 'violet', operator: '移动', today: 2431057, ratePct: 98.9, balance: '184,200', isc: '000', status: '在线', statusBadge: 'ok' },
{ id: 'CH-02', name: '华南联通三网', proto: 'SMPP', protoBadge: 'ok', operator: '联通', today: 1876442, ratePct: 98.2, balance: '96,500', isc: '000', status: '在线', statusBadge: 'ok' },
{ id: 'CH-09', name: '营销批量通道', proto: 'HTTP', protoBadge: 'warn', operator: '三网', today: 1102366, ratePct: 96.8, balance: '58,900', isc: '000', status: '在线', statusBadge: 'ok' },
{ id: 'CH-07', name: '验证码专线', proto: 'CMPP', protoBadge: 'violet', operator: '三网', today: 987110, ratePct: 99.3, balance: '2,140', balanceRed: true, isc: '000', status: '低余额', statusBadge: 'warn' },
{ id: 'CH-11', name: '政企通知专列', proto: 'SMPP', protoBadge: 'ok', operator: '三网', today: 763905, ratePct: 99.0, balance: '203,500', isc: '000', status: '在线', statusBadge: 'ok' },
{ id: 'CH-05', name: '国际出海通道', proto: 'HTTP', protoBadge: 'warn', operator: '国际', today: 642308, ratePct: 97.4, balance: '12,080', isc: '429', iscAmber: true, status: '限流中', statusBadge: 'warn' },
{ id: 'CH-13', name: '港澳台通道', proto: 'HTTP', protoBadge: 'warn', operator: '港澳台', today: 198442, ratePct: 95.2, balance: '44,300', isc: '000', status: '已停用', statusBadge: 'err' },
{ id: 'CH-99', name: '测试沙箱通道', proto: 'CMPP', protoBadge: 'violet', operator: '沙箱', today: 1024, ratePct: 100, balance: '∞', isc: '000', status: '沙箱', statusBadge: 'ok' },
]
// ===== 数据加载(60s 自动刷新) =====
// ===== 数据状态(三管线独立,单点失败不连坐) =====
const summary = ref<StatsSummary | null>(null)
const trend = ref<TrendPoint[]>([])
const trendLoading = ref(true)
let timer: ReturnType<typeof setInterval> | null = null
const trendDays = ref<number>(7)
const channels = ref<Channel[]>([])
const chLoading = ref(true)
const chFailed = ref(false)
async function load() {
// D10 数据脉象:最后成功时刻 + 最近一次结果(失败显式,不再静默吞错)
const lastOk = ref<Date | null>(null)
const loadFailed = ref(false)
async function loadSummary() {
try {
const [s, t] = await Promise.all([statsApi.summary(), statsApi.trend(7)])
summary.value = s
trend.value = t
summary.value = await statsApi.summary()
lastOk.value = new Date()
loadFailed.value = false
} catch {
summary.value = summary.value ?? null // 容错:保留旧值,首载失败显示 —
loadFailed.value = true // 保留旧值继续展示,脉象同步降级为"数据截至"
}
}
async function loadTrend() {
trendLoading.value = true
try {
trend.value = await statsApi.trend(trendDays.value)
} catch {
trend.value = [] // 趋势失败 = 显式空态,不伪造数据
} finally {
trendLoading.value = false
}
}
async function loadChannels() {
chLoading.value = true
chFailed.value = false
try {
const p = await channelApi.list({ page: 1, page_size: 8 })
channels.value = p.list
} catch {
chFailed.value = true
} finally {
chLoading.value = false
}
}
function loadAll() {
void loadSummary()
void loadTrend()
void loadChannels()
}
// Teleport 门控(见模板注释):等 #page-head-extra 就绪后再挂载脉象 chip
const teleportReady = ref(false)
// 指标 60s 自动刷新;趋势/通道随挂载与手动刷新(低频数据不陪跑)
let timer: ReturnType<typeof setInterval> | null = null
onMounted(() => {
load()
timer = setInterval(load, 60_000)
void nextTick().then(() => { teleportReady.value = true })
loadAll()
timer = setInterval(loadSummary, 60_000)
})
onUnmounted(() => { if (timer) clearInterval(timer) })
// ===== demo 实时速率(占位微动,后端接口接入后替换) =====
const rateNow = ref(1247)
let rateTimer: ReturnType<typeof setInterval> | null = null
onMounted(() => {
rateTimer = setInterval(() => { rateNow.value = 1180 + Math.floor(Math.random() * 160) }, 1500)
})
onUnmounted(() => { if (rateTimer) clearInterval(rateTimer) })
// ===== 派生指标 =====
const pendingCount = computed(() => summary.value?.pending_audit_count ?? 0)
const alertCount = computed(() => summary.value?.balance_alert_count ?? 0)
// ===== 环比(demo delta:↑/↓ + 文案) =====
function pctChange(s: StatsSummary): number | null {
if (!s.yesterday_sent) return null
return ((s.today_sent - s.yesterday_sent) / s.yesterday_sent) * 100
}
const sentDelta = computed(() => {
if (!summary.value) return { cls: 'up', text: '↑ — 较昨日' }
const y = summary.value.yesterday_sent
if (!y) return { cls: 'up', text: '↑ — 较昨日' }
const d = ((summary.value.today_sent - y) / y) * 100
const d = pctChange(summary.value)
if (d == null) return { cls: 'up', text: '↑ — 较昨日' }
return d >= 0
? { cls: 'up', text: `↑ ${d.toFixed(1)}% 较昨日` }
: { cls: 'down', text: `↓ ${Math.abs(d).toFixed(1)}% 较昨日` }
@@ -195,17 +251,139 @@ const rateDelta = computed(() => {
? { cls: 'up', text: `↑ ${pp.toFixed(1)}pt` }
: { cls: 'down', text: `↓ ${Math.abs(pp).toFixed(1)}pt` }
})
const alertCount = computed(() => summary.value?.balance_alert_count ?? 0)
const pctVal = computed(() =>
summary.value ? (summary.value.success_rate * 100).toFixed(1) : '—')
// ===== demo 趋势 SVG 几何(640×200 · 网格 42/94/146 · 底线 190) =====
const W = 640
function px(i: number) {
const n = trend.value.length
return 20 + (i * (W - 40)) / Math.max(n - 1, 1)
// ===== D2/D8 Hero 决策句(ok 平稳 / warn 需关注 / err 异常 / dim 加载中) =====
function fmtDeltaPt(d: number): string {
const pt = d * 100
return `${pt >= 0 ? '+' : '−'}${Math.abs(pt).toFixed(1)}pt`
}
function py(v: number) {
const hero = computed(() => {
if (!summary.value && loadFailed.value) {
return { tone: 'err', icon: 'WarningFilled', text: '运营指标暂不可用', sub: '统计接口连接失败,可点击右上角脉象重试', go: '' }
}
if (!summary.value) {
return { tone: 'dim', icon: 'Loading', text: '正在拉取今日运营指标…', sub: '', go: '' }
}
const s = summary.value
const parts: string[] = []
if (s.balance_alert_count > 0) parts.push(`${s.balance_alert_count} 个账号余额低于预警线`)
if (s.pending_audit_count > 0) parts.push(`${s.pending_audit_count} 条短信待人工审核`)
if (parts.length) {
return {
tone: 'warn', icon: 'Warning',
text: `今日需要关注:${parts.join(' · ')}`,
sub: `其余指标正常 · 回执成功率 ${fmtPct(s.success_rate, 1)}`,
go: s.pending_audit_count > 0 ? '/audit' : '/account/list',
}
}
if (s.success_rate < 0.95 || s.success_rate_delta < 0) {
return {
tone: 'err', icon: 'CircleClose',
text: `回执成功率 ${fmtPct(s.success_rate, 1)}(环比 ${fmtDeltaPt(s.success_rate_delta)})`,
sub: '低于平稳阈值 95%,建议核查通道回执与限流',
go: '/channel',
}
}
const d = pctChange(s)
return {
tone: 'ok', icon: 'CircleCheck',
text: '平台运行平稳,无待处置事项',
sub: `成功率 ${fmtPct(s.success_rate, 1)}(环比 ${fmtDeltaPt(s.success_rate_delta)}) · 今日提交 ${fmtNum(s.today_sent)} 条${d == null ? '' : `(较昨日 ${d >= 0 ? '+' : '−'}${Math.abs(d).toFixed(1)}%)`}`,
go: '',
}
})
// ===== D10 脉象 chip 文案 =====
function clock(d: Date | null): string {
return d ? d.toTimeString().slice(0, 8) : ''
}
const pulse = computed(() => {
if (loadFailed.value && !summary.value) {
return { cls: 'dead', text: '指标不可用 · 点击重试', title: '统计接口失败且无历史数据可展示' }
}
if (loadFailed.value) {
return { cls: 'stale', text: `连接异常 · 数据截至 ${clock(lastOk.value)}`, title: '最近一次刷新失败,正在展示上次成功数据' }
}
if (!lastOk.value) return { cls: '', text: '连接中…', title: '' }
return { cls: '', text: `实时 · ${clock(lastOk.value)}`, title: '每 60 秒自动刷新,点击立即刷新' }
})
// ===== P3 数字 count-up(rAF 补间 600ms;prefers-reduced-motion 直接跳变) =====
const REDUCE_MOTION = typeof window !== 'undefined'
&& !!window.matchMedia?.('(prefers-reduced-motion: reduce)').matches
function useCountUp(src: Ref<number | null>, format: (n: number) => string) {
const display = ref('—')
let raf = 0
let from = 0
const stop = () => { if (raf) cancelAnimationFrame(raf); raf = 0 }
watch(src, (to) => {
stop()
if (to == null || !Number.isFinite(to)) { display.value = '—'; return }
if (REDUCE_MOTION) { display.value = format(to); from = to; return }
const start = performance.now()
const a = from
const tick = (t: number) => {
const p = Math.min((t - start) / 600, 1)
const e = 1 - (1 - p) ** 3 // easeOutCubic
display.value = format(a + (to - a) * e)
if (p < 1) raf = requestAnimationFrame(tick)
else { from = to; raf = 0 }
}
raf = requestAnimationFrame(tick)
}, { immediate: true })
onUnmounted(stop)
return display
}
const todayUp = useCountUp(computed(() => summary.value?.today_sent ?? null), (n) => fmtNum(Math.round(n)))
const rateUp = useCountUp(
computed(() => (summary.value ? summary.value.success_rate * 100 : null)),
(n) => n.toFixed(1),
)
const auditUp = useCountUp(computed(() => summary.value?.pending_audit_count ?? null), (n) => String(Math.round(n)))
const alertUp = useCountUp(computed(() => summary.value?.balance_alert_count ?? null), (n) => String(Math.round(n)))
// ===== D9 快捷操作:desc 与实时指标联动(替换 demo 死文案) =====
const quick = computed(() => [
{ icon: 'EditPen', label: '新建下发任务', desc: '单发 / 群发 / 模板', to: '/sms/batch', hot: false },
{
icon: 'Stamp', label: '待人工审核', to: '/audit',
desc: summary.value
? (pendingCount.value > 0 ? `${pendingCount.value} 条待审,点击进入审核中心` : '当前无待审任务')
: '— 指标加载中',
hot: pendingCount.value > 0,
},
{ icon: 'RefreshRight', label: '失败补推', desc: '按批次 / 手机号查询重推', to: '/record/repush', hot: false },
{
icon: 'Wallet', label: '余额预警', to: '/account/list',
desc: summary.value
? (alertCount.value > 0 ? `${alertCount.value} 个账号低于预警线` : '全部账号余额充足')
: '— 指标加载中',
hot: alertCount.value > 0,
},
])
// ===== 通道表语义映射(配置域真数据;badge 色沿用 demo 语义) =====
const PROTO_META: Record<string, { label: string; badge: string }> = {
cmpp: { label: 'CMPP', badge: 'violet' },
smpp: { label: 'SMPP', badge: 'ok' },
http: { label: 'HTTP', badge: 'warn' },
sgip: { label: 'SGIP', badge: 'violet' },
}
function protoLabel(p: string): string { return PROTO_META[p]?.label ?? p.toUpperCase() }
function protoBadge(p: string): string { return PROTO_META[p]?.badge ?? 'warn' }
const CARRIER_META: Record<string, string> = { cmcc: '移动', cucc: '联通', ctcc: '电信' }
function carrierLabel(c?: string): string {
if (!c) return '—'
const parts = c.split(',').map((k) => CARRIER_META[k.trim()] ?? k.trim()).filter(Boolean)
return parts.join(' / ') || '—'
}
// ===== 走势 SVG 几何(640×200 · 网格 42/94/146 · 底线 190) =====
const W = 640
const stepX = computed(() => (W - 40) / Math.max(trend.value.length - 1, 1))
function px(i: number): number { return 20 + i * stepX.value }
function py(v: number): number {
const maxV = Math.max(...trend.value.map((p) => p.sent), 1)
return 180 - (v / maxV) * 130
}
@@ -216,26 +394,86 @@ const areaPath = computed(() => {
const last = trend.value.length - 1
return `${sentPath.value} L${px(last).toFixed(1)},190 L${px(0).toFixed(1)},190 Z`
})
function dateLabel(date: string, i: number) {
// x 轴 label 抽稀(≤8 个刻度;末位"今日"恒显)
const labelEvery = computed(() => Math.max(Math.ceil(trend.value.length / 7), 1))
function showLabel(i: number): boolean { return i % labelEvery.value === 0 || i === trend.value.length - 1 }
function dateLabel(date: string, i: number): string {
return i === trend.value.length - 1 ? '今日' : date.slice(5).replace('-', '/')
}
// ===== P3 走势 hover:十字线 + 气泡(纯 SVG,无第三方依赖) =====
const hoverIdx = ref(-1)
function onTrendHover(e: MouseEvent) {
const svg = (e.currentTarget as SVGElement).ownerSVGElement
if (!svg) return
const rect = svg.getBoundingClientRect()
const x = ((e.clientX - rect.left) / rect.width) * W
const i = Math.round((x - 20) / stepX.value)
hoverIdx.value = Math.min(Math.max(i, 0), trend.value.length - 1)
}
const tipX = computed(() => {
if (hoverIdx.value < 0) return 0
return px(hoverIdx.value) > W - 190 ? px(hoverIdx.value) - 180 : px(hoverIdx.value) + 12
})
const tipY = computed(() => {
const p = trend.value[hoverIdx.value]
return p ? Math.max(py(p.sent) - 58, 4) : 0
})
watch(trend, () => { hoverIdx.value = -1 })
</script>
<style scoped lang="scss">
/* demo 指标卡补充:预警红值 + 可点击态 */
/* ---- D2 hero 决策句:tone 左光条 + 图标容器色 + 可点击态 ---- */
.hero { display: flex; align-items: center; gap: 14px; padding: 14px 18px; }
.hero--ok { border-left: 3px solid var(--gosms-primary); }
.hero--warn { border-left: 3px solid var(--gosms-amber); }
.hero--err { border-left: 3px solid var(--gosms-red); }
.hero--dim { border-left: 3px solid var(--gosms-border-strong); }
.hero--go { cursor: pointer; }
.hero--go:hover { border-color: var(--gosms-border-glow); }
.hero-ic {
width: 36px; height: 36px; border-radius: 11px; flex-shrink: 0;
display: grid; place-items: center;
background: var(--gosms-primary-soft); color: var(--gosms-primary);
}
.hero--warn .hero-ic { background: rgba(251, 191, 36, 0.1); color: var(--gosms-amber); }
.hero--err .hero-ic { background: rgba(248, 113, 113, 0.1); color: var(--gosms-red); }
.hero--dim .hero-ic { background: var(--gosms-input-veil); color: var(--gosms-text-muted); }
.hero-body { min-width: 0; flex: 1; }
.hero-text { margin: 0; font-size: 14.5px; font-weight: 600; color: var(--gosms-text-bright); }
.hero-sub { margin: 3px 0 0; font-size: 11.5px; color: var(--gosms-text-muted); }
.hero-arrow { margin-left: auto; flex-shrink: 0; color: var(--gosms-primary); font-size: 16px; }
.hero--warn .hero-arrow { color: var(--gosms-amber); }
/* ---- P2 指标卡图标容器(emoji→EP icon 对齐)与热色 ---- */
.metric .ic { display: inline-flex; color: var(--gosms-text-muted); }
.metric .ic--hot { color: var(--gosms-amber); }
.metric--click { cursor: pointer; }
.value--warn { color: var(--gosms-amber) !important; }
.value--alert { color: var(--el-color-danger) !important; }
/* demo 趋势线:teal 光晕描边(trend-svg 尺寸走 demo-base) */
/* ---- P2 快捷卡图标热色(amber 呼应 hero warn) ---- */
.qic { color: var(--gosms-primary); }
.qic--hot { background: rgba(251, 191, 36, 0.1); color: var(--gosms-amber); }
/* ---- 走势:teal 光晕描边 + P3 hover 十字线/气泡 ---- */
.trend-line { filter: drop-shadow(0 0 6px rgba(45, 212, 191, 0.4)); }
.trend-cursor { stroke: var(--gosms-primary); stroke-width: 1; stroke-dasharray: 3 3; opacity: 0.7; }
.trend-tip rect { fill: var(--gosms-glass); stroke: var(--gosms-border); }
.trend-tip text { fill: var(--gosms-text); font-size: 11px; font-family: var(--gosms-font); }
.trend-tip .tip-date { fill: var(--gosms-text-bright); font-weight: 600; }
.trend-empty { padding: 40px 0; text-align: center; color: var(--gosms-text-muted); }
/* quick-item/qic/qt/qd/arrow 全套走 demo-base 原文,此处不再翻译 */
.quick-body { display: flex; flex-direction: column; min-width: 0; flex: 1; }
/* ---- D10 脉象 chip 降级态(基类 .live-chip 在 shell.scss;button 重置) ---- */
.live-chip { border: none; cursor: pointer; font-family: inherit; }
.live-chip.stale { color: var(--gosms-amber); background: rgba(251, 191, 36, 0.1); }
.live-chip.stale i { background: var(--gosms-amber); box-shadow: 0 0 8px rgba(251, 191, 36, 0.45); }
.live-chip.dead { color: var(--gosms-red); background: rgba(248, 113, 113, 0.1); }
.live-chip.dead i { background: var(--gosms-red); box-shadow: 0 0 8px rgba(248, 113, 113, 0.45); animation: none; }
/* 通道表横向滚动兜底(窄屏) */
/* ---- 通道表(配置域快照) ---- */
.ch-scroll { overflow-x: auto; }
.text-danger { color: var(--el-color-danger); }
.text-amber { color: var(--el-color-warning); }
.ch-empty { padding: 24px 0; text-align: center; color: var(--gosms-text-muted); }
.quick-body { display: flex; flex-direction: column; min-width: 0; flex: 1; }
:deep(.dim), .dim { color: var(--gosms-text-muted); }
</style>
+7
View File
@@ -1,2 +1,9 @@
// vitest 全局 setup:注册 msw node 服务(经 vite.config test.globals 生效)
// P0(2026-11-13):vitest mode=test 不加载 .env.development → request.ts 顶层
// baseURL=undefined → msw 全量 unhandled(91/137 红)。setupFiles 先于被测模块
// 求值,此处 stub 一处生效;各 spec 内重复 stubEnv 同值无害。
import { vi } from 'vitest'
vi.stubEnv('VITE_API_BASE_URL', 'http://localhost/api/v1')
import './tests/setup'