From d895cf725b3be0b86384872136081f0c0f9353c2 Mon Sep 17 00:00:00 2001 From: xiaosi <2652281683@qq.com> Date: Wed, 2 Sep 2026 11:36:44 +0800 Subject: [PATCH] docs: add admin traffic test-grant implementation plan Break the TrafficOps test-grant dialog into URL, UI, and submit tasks for subagent or inline execution. --- .../2026-09-02-admin-traffic-test-grant.md | 381 ++++++++++++++++++ 1 file changed, 381 insertions(+) create mode 100644 docs/superpowers/plans/2026-09-02-admin-traffic-test-grant.md diff --git a/docs/superpowers/plans/2026-09-02-admin-traffic-test-grant.md b/docs/superpowers/plans/2026-09-02-admin-traffic-test-grant.md new file mode 100644 index 0000000..10d9071 --- /dev/null +++ b/docs/superpowers/plans/2026-09-02-admin-traffic-test-grant.md @@ -0,0 +1,381 @@ +# Admin Traffic Test Grant Tool Implementation Plan + +> **For agentic workers:** REQUIRED SUB-SKILL: Use superpowers:subagent-driven-development (recommended) or superpowers:executing-plans to implement this plan task-by-task. Steps use checkbox (`- [ ]`) syntax for tracking. + +**Goal:** 在管理员「流量运营」页增加「测试发放」对话框,调用 `POST /v1/admin/traffic/test-grants` 给普通用户直接加测试流量,绕过下单支付链路。 + +**Architecture:** 只改前端。`urls.js` 增加常量;`TrafficOpsView` 页头加按钮与对话框。用户可通过 `/v1/users` 搜索选择,或手填 `userId`。成功后 toast,并在对话框展示最新余额。 + +**Tech Stack:** Vue 3、tdesign-vue-next、Pinia `uiStore`、axios `src/utils/http.js`、既有 `TrafficOpsView` / `FirmwaresView` 页头按钮模式 + +**Spec:** `docs/superpowers/specs/2026-09-02-admin-traffic-test-grant-design.md` + +--- + +## File map + +| 文件 | 职责 | +|---|---| +| `src/config/urls.js` | 新增 `ADMIN_TRAFFIC_TEST_GRANTS` | +| `src/views/TrafficOpsView/TrafficOpsView.vue` | 页头按钮、发放对话框、搜索用户、提交与余额展示 | + +辅助约定: + +- 请求:`import request from '@/utils/http'`(成功时已解包 `res.data`) +- Toast:`useUiStore().toast(...)` +- GB:沿用页内 `GB_BYTES = 1024 ** 3`、`bytesToGbText` +- 本仓库无前端单测惯例:用 `npm run build` + 静态核对验收;不新增测试文件 + +--- + +### Task 1: URL 常量 + +**Files:** +- Modify: `src/config/urls.js` + +- [ ] **Step 1: 在 Admin traffic ops 段落后追加常量** + +在现有: + +```js +export const ADMIN_TRAFFIC_LEDGER = '/v1/admin/traffic/ledger' +``` + +后追加: + +```js +export const ADMIN_TRAFFIC_TEST_GRANTS = '/v1/admin/traffic/test-grants' +``` + +- [ ] **Step 2: Commit** + +```bash +git add src/config/urls.js +git commit -m "feat: add admin traffic test-grants URL" +``` + +--- + +### Task 2: TrafficOps 页头按钮 + 发放对话框 UI + +**Files:** +- Modify: `src/views/TrafficOpsView/TrafficOpsView.vue` + +- [ ] **Step 1: 页头增加「测试发放」按钮** + +把 header 从: + +```vue +
+
+

流量运营

+ 管理云媒体流量套餐、平台采购入池与账务流水 +
+
+``` + +改为(对齐 `FirmwaresView` 的 `page-actions`): + +```vue +
+
+

流量运营

+ 管理云媒体流量套餐、平台采购入池与账务流水 +
+
+ + 测试发放 + +
+
+``` + +- [ ] **Step 2: 在现有 purchase dialog 后追加发放对话框** + +放在第二个 ``(采购录入)之后、`` 之前: + +```vue + +
+ + + + +

{{ grantFormError }}

+
+ 最新余额 + {{ grantResultBalanceText }} +
+
+ +
+``` + +若页面尚无 `.form-error` / `.grant-result` 样式,在本文件 `