@mingfuyun/star-allinone 0.4.5 → 0.4.6

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -174,7 +174,7 @@ import { CustomDrawer, HocModal } from '@mingfuyun/star-allinone';
174
174
  **1. 安装能力包并同步 Skill**
175
175
 
176
176
  ```bash
177
- pnpm add @mingfuyun/star-allinone@^0.4.5
177
+ pnpm add @mingfuyun/star-allinone@^0.4.6
178
178
  pnpm exec star-allinone skills sync
179
179
  ```
180
180
 
@@ -198,7 +198,7 @@ pnpm exec star-allinone skills sync
198
198
  | 加载 SDK | 在 Umi `headScripts` 插入 OSS 内联脚本 |
199
199
  | 应用初始化 | 改 `src/app.tsx`:`markTrackingReady`、`syncTrackingRoute` |
200
200
  | 接口失败上报 | 改 `src/services/request.tsx`:失败时 `reportApiTracking` |
201
- | 全站按钮埋点 | 扫描页面,补齐五类按钮以及 **带 `onClick` 的 `a` / `div` / `span` 等** |
201
+ | 全站按钮埋点 | 扫描页面,补齐按钮、**带 `onClick` 的元素**、**Tabs 页签**、**下载 `href`** |
202
202
  | 验证 | 跑 `pnpm typecheck`;必要时说明浏览器验收项 |
203
203
 
204
204
  非默认 import 路径时,Agent 可读 `.star-allinone.json` 的 `trackingModule`(如 `@/utils/tracking`)。
@@ -235,8 +235,10 @@ pnpm exec star-allinone skills sync
235
235
  | 4 | 表单提交/重置 | `ProForm` submitter、`Form` 按钮 |
236
236
  | 5 | 复制 | 操作列、工具栏、「复制 IP」等 |
237
237
  | 6 | 带 `onClick` 的元素 | `a`、`div`、`span`、`Typography.Link`、可点击卡片 |
238
+ | 7 | Tabs / 分段切换 | `Tabs` / `Segmented` 每个页签 `label` |
239
+ | 8 | 文件下载 | `<a href>` 带 `download` 或文件 URL,**无 `onClick` 也要报** |
238
240
 
239
- **不上报:** 列设置、表格「更多」省略号 icon(菜单内各项仍要 track)、无权限未渲染的按钮、**没有** `onClick` 的纯展示节点。
241
+ **不上报:** 列设置、表格「更多」省略号 icon(菜单内各项仍要 track)、无权限未渲染的按钮、**没有** `onClick` 且**不是下载**的纯展示 / 纯外链。
240
242
 
241
243
  ### 按钮写法速查
242
244
 
@@ -262,6 +264,20 @@ track: getTrackData('edit', '编辑', { key: 'action', name: '操作' })
262
264
  >
263
265
  {record.name}
264
266
  </a>
267
+
268
+ // Tabs 页签
269
+ <span data-track={getTrackData('switch_tab', '列表', { key: 'tabs', name: '页签' })}>
270
+ 列表
271
+ </span>
272
+
273
+ // 文件下载(无 onClick 也要 data-track)
274
+ <a
275
+ href={fileUrl}
276
+ download
277
+ data-track={getTrackData('download', '下载', { key: 'file', name: '导出' })}
278
+ >
279
+ 下载
280
+ </a>
265
281
  ```
266
282
 
267
283
  点击由 SDK 监听 `data-track`,**不要在** `onClick` 里再调 `track()`。
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@mingfuyun/star-allinone",
3
- "version": "0.4.5",
3
+ "version": "0.4.6",
4
4
  "description": "星系运维前端能力包",
5
5
  "main": "dist/index.js",
6
6
  "bin": {
package/skills/README.md CHANGED
@@ -127,7 +127,7 @@ git commit -m "chore(skill): 更新公共 skill"
127
127
  | `shared-design-to-page` | 页面:标准列表内部 `gen page`,其余按设计稿实现 |
128
128
  | `shared-review-and-submit` | 审查并提交 |
129
129
  | `shared-publish-test` | 测发 |
130
- | `shared-tracking` | 埋点接入与全站可点击补齐(含 onClick 的 a/div/span) |
130
+ | `shared-tracking` | 埋点接入(含 onClick、Tabs、下载 href) |
131
131
 
132
132
  ## 公共规则写在哪里
133
133
 
@@ -137,7 +137,7 @@ git commit -m "chore(skill): 更新公共 skill"
137
137
  | `shared-design-to-page` | SKILL + `page-conventions.md`、`overlays.md`、`list-page-template.md`、`tracking.md` | 页面分层、标准列表 CLI、弹层合同、按钮埋点 |
138
138
  | `shared-review-and-submit` | SKILL + `impact-analysis.md`、`verify.md`、`ai-review.md`、`commit.md` | 影响分析 → 验证(含埋点完整性)→ 确认后提交 |
139
139
  | `shared-publish-test` | SKILL + `scripts/publish-current-branch.sh` | 云效测发;只读 `publishPipelineId` |
140
- | `shared-tracking` | [SKILL.md](./shared/tracking/SKILL.md) | 埋点接入:业务接入、五类按钮、带 onClick 的 a/div/span |
140
+ | `shared-tracking` | [SKILL.md](./shared/tracking/SKILL.md) | 埋点接入:按钮、onClick、Tabs 切换、下载 href |
141
141
  | (非入口)`shared-project-conventions` | `architecture.md`、`mfprotable.md`、`component-contract.md`、`review-checklist.md`(含埋点审查)、`quality-checklist.md` | 架构、导入合同、质量清单 |
142
142
  | (非入口)`shared-i-have-adhd` | `i-have-adhd.md` | 用户输出格式 |
143
143
 
@@ -52,7 +52,7 @@ Add `--permission-create`, `--permission-edit`, `--permission-delete` when codes
52
52
  3. The CLI fills columns and drawer fields from the OpenAPI schema (required, enum → `ProFormSelect`, dates/numbers). Review labels and permission codes; do not recreate the file tree. See [references/list-page-template.md](references/list-page-template.md).
53
53
  4. If `src/components/Page/Container/config.tsx` exists, `gen page` writes a Container `index.tsx`, puts the table in `components/List.tsx`, and registers a Tab with `loader: () => import(...)`. Do not invent a second page shell.
54
54
  5. Do not overwrite existing page files. Tell the user the CLI refused, then edit in place.
55
- 6. **Tracking:** When the project has tracking configured, `gen page` auto-wires default button tracking. Agent must scan and wire **all** in-scope clickables per [references/tracking.md](references/tracking.md) and `$shared-tracking` (permission, drawer/modal footers, action column, ProForm, copy, **`onClick` on `a` / `div` / `span`**)—do not leave manual steps for the user. If tracking is not set up yet, tell the user to run `$shared-tracking` first; do not invent a second tracking helper.
55
+ 6. **Tracking:** When the project has tracking configured, `gen page` auto-wires default button tracking. Agent must scan and wire **all** in-scope clickables per [references/tracking.md](references/tracking.md) and `$shared-tracking` (permission, drawer/modal footers, action column, ProForm, copy, **`onClick` on `a` / `div` / `span`**, **Tabs labels**, **download `href`**)—do not leave manual steps for the user. If tracking is not set up yet, tell the user to run `$shared-tracking` first; do not invent a second tracking helper.
56
56
 
57
57
  ## Design path
58
58
 
@@ -65,7 +65,7 @@ For non-standard layouts:
65
65
  5. API-backed pages include types, `MFRequest` methods, aggregate exports, and page consumption in the same change. Use `.agents/skills/shared-api-to-service/SKILL.md` for missing services. Use `.agents/skills/shared-api-to-service/references/mock.md` for extra mock scenarios. Do not embed production fake data.
66
66
  6. Compare desktop and narrow layouts against the design. Fix structure and spacing before decoration.
67
67
  7. Run focused verification. Do not claim visual fidelity without inspecting the rendered page.
68
- 8. When tracking is enabled, Agent applies [references/tracking.md](references/tracking.md) for every toolbar, action, copy, drawer, confirm, form submit, standalone permission button, and **`onClick` on `a` / `div` / `span` / links**.
68
+ 8. When tracking is enabled, Agent applies [references/tracking.md](references/tracking.md) for every toolbar, action, copy, drawer, confirm, form submit, standalone permission button, **`onClick` on `a` / `div` / `span` / links**, **Tabs / Segmented**, and **download `href`**.
69
69
 
70
70
  ## Hard rules
71
71
 
@@ -79,7 +79,7 @@ For non-standard layouts:
79
79
  - Do not use `Modal.confirm` or feature-level Ant Design `Modal` / `Drawer` shells.
80
80
  - Do not add a UI library, state library, or CSS-in-JS system without approval.
81
81
  - Do not refactor unrelated code.
82
- - When `src/utils/tracking/index.ts` exists, Agent wires `getTrackData` on every control covered by [references/tracking.md](references/tracking.md), including copy and **any `onClick` on `a` / `div` / `span` / links**. Do not call `track()` in handlers. Do not ask the user to add tracks manually.
82
+ - When `src/utils/tracking/index.ts` exists, Agent wires `getTrackData` on every control covered by [references/tracking.md](references/tracking.md), including copy, **any `onClick` on `a` / `div` / `span` / links**, **Tabs**, and **download `href`**. Do not call `track()` in handlers. Do not ask the user to add tracks manually.
83
83
 
84
84
  ## Verification
85
85
 
@@ -90,7 +90,7 @@ pnpm typecheck
90
90
 
91
91
  Run `pnpm lint` for broad or shared changes. Run the project's documented build command when routes, entry, or multiple pages change.
92
92
 
93
- When tracking is configured, scan changed page files: toolbar `track`, action `track`, copy `track`, drawer `cancelTrack` / `okTrack` or custom-footer `data-track`, confirm modal buttons, ProForm submitters, standalone permission buttons, and **`onClick` on `a` / `div` / `span` / `Typography.Link`**. Agent fixes missing wiring before calling the page done; do not defer to the user.
93
+ When tracking is configured, scan changed page files: toolbar `track`, action `track`, copy `track`, drawer `cancelTrack` / `okTrack` or custom-footer `data-track`, confirm modal buttons, ProForm submitters, standalone permission buttons, **`onClick` on `a` / `div` / `span` / `Typography.Link`**, **Tabs / Segmented labels**, and **download `href`**. Agent fixes missing wiring before calling the page done; do not defer to the user.
94
94
 
95
95
  ## User-facing output
96
96
 
@@ -2,7 +2,7 @@
2
2
 
3
3
  Apply when the business project already has `src/utils/tracking/index.ts` (or the path documented in project conventions). Full SDK setup and **Agent 全站批量补齐规则** live in `.agents/skills/shared-tracking/SKILL.md`. This file covers **page / 生成场景**。
4
4
 
5
- **Agent 规则:** 生成或修改页面时,由 Agent 写入全部可点击埋点,**不要**留给用户手工补。与「接入埋点」同一套扫描标准:五类按钮 + **任何带 `onClick` 的元素**(`a`、`div`、`span`、`Typography.Link` 等)。
5
+ **Agent 规则:** 生成或修改页面时,由 Agent 写入全部可点击埋点,**不要**留给用户手工补。与「接入埋点」同一套扫描标准:标准按钮 + **任何带 `onClick` 的元素** + **Tabs 切换** + **下载 `href`**。
6
6
 
7
7
  Import:
8
8
 
@@ -25,6 +25,8 @@ Click reporting uses `data-track` JSON from `getTrackData`. Do not call `track()
25
25
  | Confirm dialog | `BaseModal` | custom footer + `data-track` when button props unavailable |
26
26
  | Inline form submit | `ProForm` / `Form` | `submitButtonProps` / `resetButtonProps` |
27
27
  | Clickable `a` / `div` / `span` / `Typography.Link` | any node with `onClick` | `data-track={getTrackData(...)}` on **that** node |
28
+ | Tabs / Segmented | `Tabs` `items[].label`, `Segmented` options | wrap label with `data-track` (`switch_tab`) |
29
+ | File download `<a href>` | `download` attr, file URL, 下载 text | `data-track` on the `<a>` even without `onClick` |
28
30
 
29
31
  `MFProTable` query and reset are handled inside the table (`filter_query` / `查询`, `filter_reset` / `重置`). Do not duplicate in page code.
30
32
 
@@ -50,18 +52,22 @@ Every business `Button` in custom `footer` needs `data-track`. Do not replace th
50
52
  - Column settings only.
51
53
  - Table overflow 「更多」 ellipsis icon (menu items inside still need `track`).
52
54
  - Buttons hidden by permission (no render → no track).
53
- - Nodes with **no** `onClick` (plain text, static `href` links).
55
+ - Nodes with **no** `onClick` **except file-download `<a href>`** (plain text, non-download static `href`).
54
56
 
55
57
  **Copy buttons must be tracked** — see shared-tracking §5.
56
58
 
57
- **Any `onClick` node must be tracked** — see shared-tracking §6 (`a`, `div`, `span`, `Typography.Link`, clickable cards).
59
+ **Any `onClick` node must be tracked** — see shared-tracking §6.
60
+
61
+ **Tabs `onChange` / tab labels must be tracked** — see shared-tracking §7.
62
+
63
+ **Download `<a href>` must be tracked even without `onClick`** — see shared-tracking §8.
58
64
 
59
65
  ## After `gen page`
60
66
 
61
- When `src/utils/tracking/index.ts` exists, `gen page` wires toolbar, action edit/delete, drawer, and modal by default. Agent still reviews and adds tracking for extra buttons (copy, batch, custom footer, ProForm) and **every `onClick` on `a` / `div` / `span` / links**. Pass `--no-tracking` only when user explicitly asks.
67
+ When `src/utils/tracking/index.ts` exists, `gen page` wires toolbar, action edit/delete, drawer, and modal by default. Agent still reviews and adds tracking for extra buttons (copy, batch, custom footer, ProForm), **every `onClick` on `a` / `div` / `span` / links**, **Tabs labels**, and **download `href`**. Pass `--no-tracking` only when user explicitly asks.
62
68
 
63
69
  For pages **not** from `gen page`, Agent scans and wires the full set per shared-tracking — not a user manual task.
64
70
 
65
71
  ## Verification
66
72
 
67
- Static scan changed files: every toolbar / action / copy / drawer / modal / form button, plus every `onClick` on `a` / `div` / `span` / `Typography.Link`, has `track`, `cancelTrack`, `okTrack`, or `data-track`.
73
+ Static scan changed files: every toolbar / action / copy / drawer / modal / form button, every `onClick` on `a` / `div` / `span` / `Typography.Link`, **Tabs / Segmented labels**, and **download `href`**, has `track`, `cancelTrack`, `okTrack`, or `data-track`.
@@ -34,10 +34,12 @@ Apply when the project has `src/utils/tracking/index.ts` (or the path in project
34
34
  - Action column entries need `track` beside `permission` when present.
35
35
  - Standalone permission buttons need `data-track={getTrackData(...)}`.
36
36
  - Clickable `a` / `div` / `span` / `Typography.Link` with `onClick` need `data-track` on **that** node.
37
+ - `Tabs` / `Segmented` / `Radio.Group` page labels need `data-track` on each tab (see shared-tracking §7).
38
+ - File-download `<a href>` (`download` attribute, file URL, 下载) need `data-track` even without `onClick`.
37
39
  - `CustomDrawer` with the default footer needs `cancelTrack` and `okTrack`; custom footers need `data-track` on each business button.
38
40
  - `BaseModal` confirm dialogs need `cancelButtonProps` / `okButtonProps` with `'data-track'`.
39
41
  - `ProForm` with a visible default submitter needs submit/reset button props; when `submitter={false}`, tracking belongs on the overlay footer only.
40
- - Require tracking on copy actions and **any node with `onClick`** (`a`, `div`, `span`, `Typography.Link`, clickable cards). Do not require tracking on column settings, table overflow ellipsis icon, buttons hidden by permission, or nodes without `onClick`.
42
+ - Require tracking on copy actions, **any node with `onClick`**, **Tabs / Segmented switches**, and **download `<a href>`**. Do not require tracking on column settings, table overflow ellipsis icon, buttons hidden by permission, or non-download nodes without `onClick`.
41
43
  - Missing in-scope button tracking on a changed page is **P1**.
42
44
 
43
45
  ## Shared components and regression
@@ -32,7 +32,7 @@ Follow [references/verify.md](references/verify.md). Output:
32
32
  - P0/P1/P2 blockers
33
33
  - Completeness of route, permission, API, types, mock, page states, and click tracking when the project has tracking configured
34
34
  - Async, loading, overlay, and list-reload behavior
35
- - Missing `track` / `data-track` / `cancelTrack` / `okTrack` on in-scope clickables (buttons, copy, **`onClick` on `a` / `div` / `span`**) per `shared-tracking` (P1 when tracking is enabled)
35
+ - Missing `track` / `data-track` / `cancelTrack` / `okTrack` on in-scope clickables (buttons, copy, **`onClick` on `a` / `div` / `span`**, **Tabs**, **download `href`**) per `shared-tracking` (P1 when tracking is enabled)
36
36
  - Prettier, TypeScript, lint, and build results
37
37
  - Uncovered risks
38
38
 
@@ -15,7 +15,7 @@ If `.agents/project/review-rules.md` exists, apply extra domain checks only; do
15
15
  1. React Hooks: stale closures, incomplete dependencies, request races, updates after unmount, unnecessary rerenders.
16
16
  2. API contracts: method/path/params, response unwrapping, pagination, nullability, enum drift, error handling, DTO mismatch.
17
17
  3. Permissions: route access, button visibility, mutation authorization, client-only enforcement.
18
- 4. **Tracking** (when `src/utils/tracking/index.ts` or project equivalent exists): scan changed pages for missing `track` / `cancelTrack` / `okTrack` / `data-track` on in-scope buttons—toolbar, action column, permission buttons, drawer and confirm footers (default and custom), inline form submitters, **copy** actions, and **any `onClick` on `a` / `div` / `span` / `Typography.Link`**. Flag missing wiring as **P1**. Do not require tracking on column settings, table overflow ellipsis icon, permission-hidden buttons, or nodes without `onClick`. Do not flag handlers that call `track()` when `data-track` is the project standard.
18
+ 4. **Tracking** (when `src/utils/tracking/index.ts` or project equivalent exists): scan changed pages for missing `track` / `cancelTrack` / `okTrack` / `data-track` on in-scope clickables—toolbar, action column, permission buttons, drawer and confirm footers, inline form submitters, **copy**, **any `onClick` on `a` / `div` / `span` / `Typography.Link`**, **Tabs / Segmented labels**, and **download `<a href>`**. Flag missing wiring as **P1**. Do not require tracking on column settings, table overflow ellipsis icon, permission-hidden buttons, or non-download nodes without `onClick`. Do not flag handlers that call `track()` when `data-track` is the project standard.
19
19
  5. Forms/tables: validation, reset, duplicate submit, refresh after mutation, column-state, long text, empty/error.
20
20
  6. Performance (hard checks):
21
21
  - New or changed files must not statically `import 'xlsx'`, `@uiw/react-codemirror`, `@codemirror/*`, `echarts`, `@ant-design/charts`, or `react-json-view` at module top level. Those must be `import()`.
@@ -19,7 +19,7 @@ Do not auto-fix. If `.agents/project/review-rules.md` exists, apply extra domain
19
19
  5. Empty table values, duplicate-submit guards, permission wrappers, and narrow-screen overflow.
20
20
  6. Heavy deps (`xlsx`, editors, charts) are `import()`; nothing new lands in `src/app.ts`.
21
21
  7. No `MFTablePro` / table-from-package imports; overlays come from `@mingfuyun/star-allinone`.
22
- 8. **Tracking** (when tracking is configured): every in-scope clickable has `track`, `cancelTrack`, `okTrack`, or `data-track` per `.agents/skills/shared-tracking/SKILL.md` and `.agents/skills/shared-design-to-page/references/tracking.md`. Check toolbar items, action column entries, standalone permission buttons, drawer default or custom footers, confirm modals, inline `ProForm` submitters, **copy** buttons, and **`onClick` on `a` / `div` / `span` / `Typography.Link`**. Missing wiring is **P1** when the control is user-visible and in scope. Excluded controls (column settings, table overflow ellipsis icon, nodes without `onClick`) must not be flagged. Permission-hidden buttons may omit tracking.
22
+ 8. **Tracking** (when tracking is configured): every in-scope clickable has `track`, `cancelTrack`, `okTrack`, or `data-track` per `.agents/skills/shared-tracking/SKILL.md` and `.agents/skills/shared-design-to-page/references/tracking.md`. Check toolbar items, action column entries, standalone permission buttons, drawer default or custom footers, confirm modals, inline `ProForm` submitters, **copy** buttons, **`onClick` on `a` / `div` / `span` / `Typography.Link`**, **Tabs / Segmented labels**, and **download `<a href>`**. Missing wiring is **P1** when the control is user-visible and in scope. Excluded controls (column settings, table overflow ellipsis icon, non-download nodes without `onClick`) must not be flagged. Permission-hidden buttons may omit tracking.
23
23
 
24
24
  ## Commands
25
25
 
@@ -16,7 +16,7 @@ description: User-facing. Connect a galaxy admin app to the shared tracking SDK.
16
16
  完成标准:
17
17
 
18
18
  1. 基础设施(SDK、`tracking/index.ts`、`app.tsx`、请求封装)已就绪。
19
- 2. **全站**带用户点击意图的控件均已带 `track` / `cancelTrack` / `okTrack` / `data-track`(无权限未渲染的除外)。覆盖五类标准按钮,以及 **任何写了 `onClick` / `onClickCapture` 的元素**(`a`、`div`、`span`、`Typography.Link` 等)。
19
+ 2. **全站**带用户点击意图的控件均已带 `track` / `cancelTrack` / `okTrack` / `data-track`(无权限未渲染的除外)。覆盖标准按钮、**带 `onClick` 的元素**、**Tabs / 分段器切换**、以及 **文件下载 `<a href>`**。
20
20
  3. `pnpm typecheck` 通过。
21
21
  4. 向用户汇报已覆盖的文件范围,而不是留 TODO 让用户自己改。
22
22
 
@@ -30,8 +30,10 @@ description: User-facing. Connect a galaxy admin app to the shared tracking SDK.
30
30
  | 4 | **ProForm / Form** | `submitter` 默认栏、`submitter.render`、antd `Form` 提交/重置 | `submitButtonProps` / `resetButtonProps` 的 `data-track` |
31
31
  | 5 | **复制相关按钮** | 文案含「复制」「一键复制」、`key` 含 `copy`;含复制 IP | `getTrackData('copy', '…', …)` |
32
32
  | 6 | **任意带 `onClick` 的可点击元素** | `onClick` / `onClickCapture` 写在 `a`、`div`、`span`、`p`、`li`、`Typography.Link`、`Typography.Text`、antd `Link` 等上 | 该节点加 `data-track={getTrackData(...)}`。不要只给外层容器埋点而漏掉真正被点的子节点 |
33
+ | 7 | **Tabs / 分段切换** | antd `Tabs`、`Segmented`、`Radio.Group`、业务 Tab 容器的 `onChange` | 每个页签 `label` 包一层带 `data-track` 的节点;不要只写 `onChange` 不埋点 |
34
+ | 8 | **文件下载链接** | `<a href>` 带 `download`、文件 URL、blob、文案含「下载」 | 该 `<a>` 加 `data-track`,**即使没有 `onClick`** |
33
35
 
34
- 硬规则:**只要业务代码给节点绑了点击回调,该节点就要上报。** 不限 `Button`。链接、可点击文字、卡片区域、状态标签、图标容器都算。
36
+ 硬规则:**只要业务代码给节点绑了点击回调,该节点就要上报。** 不限 `Button`。链接、可点击文字、卡片区域、状态标签、图标容器都算。**Tab 切换和文件下载链接同样必须上报。**
35
37
 
36
38
  另需覆盖(同属 Agent 批量任务):
37
39
 
@@ -48,10 +50,12 @@ rg "withAuth|AccessButton" src/pages -g "*.tsx"
48
50
  rg "ProForm|submitter" src/pages -g "*.tsx"
49
51
  rg "复制|copy|Copy" src/pages src/components -g "*.tsx"
50
52
  rg "onClick(Capture)?=" src/pages src/components -g "*.tsx"
53
+ rg "<Tabs|<Segmented|Radio.Group" src/pages src/components -g "*.tsx"
54
+ rg "download=|href=.+\.(xlsx|xls|csv|zip|pdf|png|jpg)|下载" src/pages src/components -g "*.tsx"
51
55
  rg "<a |<div |<span " src/pages -g "*.tsx"
52
56
  ```
53
57
 
54
- 对每个命中文件:**打开、判断是否在范围内、补全、保存**。带 `onClick` 的 `a`/`div`/`span` 与 Button 同一标准。历史页与 `gen page` 新页同一标准。
58
+ 对每个命中文件:**打开、判断是否在范围内、补全、保存**。带 `onClick` 的 `a`/`div`/`span`、Tabs 页签、下载 `href` 与 Button 同一标准。历史页与 `gen page` 新页同一标准。
55
59
 
56
60
  ### 不要做的「半套接入」
57
61
 
@@ -60,8 +64,10 @@ rg "<a |<div |<span " src/pages -g "*.tsx"
60
64
  - ❌ 在组件层做 track 自动推断(不改 `withAuth` / `TableActions` 自动生成 track)
61
65
  - ❌ 把复制按钮排除在补齐范围外
62
66
  - ❌ 只给 `Button` 加埋点,漏掉带 `onClick` 的 `a` / `div` / `span` / `Typography.Link`
67
+ - ❌ 漏掉 `Tabs` / `Segmented` 切换
68
+ - ❌ 漏掉带 `href` 的文件下载 `<a>`(没有 `onClick` 也要报)
63
69
 
64
- 仍不上报:**列设置**、表格 **「更多」省略号**(仅展开菜单的 icon;菜单内各项仍要 track)、纯展示且**没有** `onClick` 的节点。
70
+ 仍不上报:**列设置**、表格 **「更多」省略号**(仅展开菜单的 icon;菜单内各项仍要 track)、纯展示且**没有** `onClick` 的节点(**文件下载 `href` 除外**)、无下载意图的纯外链 `href`。
65
71
 
66
72
  ---
67
73
 
@@ -303,7 +309,91 @@ track: getTrackData('copy', '复制IP', { key: 'toolbar', name: '群看板' })
303
309
 
304
310
  `onClick` 写在包裹组件上时,把 `data-track` 也写在同一组件。子节点没有独立点击时不要重复上报。
305
311
 
306
- 路由跳转用 `history.push` / `navigate` 且绑了 `onClick` 的,同样要 `data-track`。纯 `href`、没有 `onClick` 的外链可以不上报。
312
+ 路由跳转用 `history.push` / `navigate` 且绑了 `onClick` 的,同样要 `data-track`。无下载意图、纯 `href`、没有 `onClick` 的外链可以不上报。**文件下载见第 8 节,必须上报。**
313
+
314
+ #### 7. Tabs / 分段器 `onChange`
315
+
316
+ antd `Tabs`、`Segmented`、`Radio.Group` 以及业务页签容器,切换时必须上报。优先在**每个页签的可点击文案**上写 `data-track`(SDK 监听点击,不要在 `onChange` 里再调 `track()`)。`items` 里 `label` 若是纯字符串,改成带 `data-track` 的节点。
317
+
318
+ ```tsx
319
+ <Tabs
320
+ items={[
321
+ {
322
+ key: 'list',
323
+ label: (
324
+ <span
325
+ data-track={getTrackData('switch_tab', '列表', { key: 'tabs', name: '页签' })}
326
+ >
327
+ 列表
328
+ </span>
329
+ ),
330
+ },
331
+ {
332
+ key: 'detail',
333
+ label: (
334
+ <span
335
+ data-track={getTrackData('switch_tab', '详情', { key: 'tabs', name: '页签' })}
336
+ >
337
+ 详情
338
+ </span>
339
+ ),
340
+ },
341
+ ]}
342
+ onChange={handleTabChange}
343
+ />
344
+ ```
345
+
346
+ ```tsx
347
+ <Segmented
348
+ options={[
349
+ {
350
+ label: (
351
+ <span data-track={getTrackData('switch_tab', '日', { key: 'tabs', name: '时间' })}>
352
+ 日
353
+ </span>
354
+ ),
355
+ value: 'day',
356
+ },
357
+ {
358
+ label: (
359
+ <span data-track={getTrackData('switch_tab', '周', { key: 'tabs', name: '时间' })}>
360
+ 周
361
+ </span>
362
+ ),
363
+ value: 'week',
364
+ },
365
+ ]}
366
+ onChange={handleRangeChange}
367
+ />
368
+ ```
369
+
370
+ `action` 用 `switch_tab`(或项目已有惯例)。`name` 用页签文案。不要只给 `Tabs` 根节点加一个 `data-track`。
371
+
372
+ #### 8. 文件下载 `<a href>`
373
+
374
+ 下载文件的 `<a>` **即使没有 `onClick` 也要上报**。识别:`download` 属性、href 指向文件(xlsx/xls/csv/zip/pdf/png 等)、blob URL、文案含「下载」。
375
+
376
+ ```tsx
377
+ <a
378
+ href={fileUrl}
379
+ download
380
+ data-track={getTrackData('download', '下载', { key: 'file', name: '导出' })}
381
+ >
382
+ 下载
383
+ </a>
384
+ ```
385
+
386
+ ```tsx
387
+ <Typography.Link
388
+ href={record.file_url}
389
+ target="_blank"
390
+ data-track={getTrackData('download', '下载附件', { key: 'cell', name: '附件' })}
391
+ >
392
+ {record.file_name}
393
+ </Typography.Link>
394
+ ```
395
+
396
+ 点击由 SDK 监听 `data-track`。不要为了埋点去掉 `href` 改成纯 `onClick` 除非业务本来就走接口下载。接口下载按钮按第 1 / 6 节写 `data-track` 或 `track`。
307
397
 
308
398
  ## 不要做的事
309
399
 
@@ -322,6 +412,6 @@ track: getTrackData('copy', '复制IP', { key: 'toolbar', name: '群看板' })
322
412
  1. 页面请求了 OSS 上的脚本,并且出现 `window.TrackingSDK`。
323
413
  2. 进入业务页、初始状态完成后存在 `window.__tracker`。`/` 上可以还没有。
324
414
  3. 一次失败请求发出事件名 `api_request`。
325
- 4. 五类标准按钮(含复制),以及带 `onClick` 的 `a` / `div` / `span` / `Typography.Link` 等,带 `data-track` / `cancelTrack` / `okTrack`。
415
+ 4. 标准按钮(含复制)、带 `onClick` 的 `a` / `div` / `span`、**Tabs 页签**、**下载 `href`** 带 `data-track` / `cancelTrack` / `okTrack`。
326
416
 
327
417
  `appId` 与平台不一致时,只改 `src/utils/tracking/index.ts`。