### 关联与状态 路线图 #2,一期。状态:**已完成**,PR #93。 ### 目标 抓取节点用令牌调网站的接口([接口 §6](https://github.com/mousebaoyan/mouseclock/blob/main/docs/api.md#6-抓取节点))。线上的令牌由站长在系统设置里生成、作废,本地开发现在用 `pnpm crawler-token` 生成([§6.2](https://github.com/mousebaoyan/mouseclock/blob/main/docs/design.md#62-权限):站长管抓取节点令牌)。 ### 已经有的 - **本地开发**:`docker compose up -d` 起数据库,`pnpm dev` 起网站,`pnpm seed` 往空库里填编好的学校、通知和项目。点「登录」会到假的鼠洞,挑一个假用户登录,各种等级和权限都有。命令见 [AGENTS.md](https://github.com/mousebaoyan/mouseclock/blob/main/AGENTS.md#命令)。 - **表结构**:[数据表](https://github.com/mousebaoyan/mouseclock/blob/main/docs/data-model.md)。 - **接口和页面的写法**:照 [`accounts/routes.ts`](https://github.com/mousebaoyan/mouseclock/blob/main/web/server/modules/accounts/routes.ts),用 Zod 定义请求和返回。页面的 loader 通过 [`app/api.server.ts`](https://github.com/mousebaoyan/mouseclock/blob/main/web/app/api.server.ts) 在进程内调接口,例子是 [`app/root.tsx`](https://github.com/mousebaoyan/mouseclock/blob/main/web/app/root.tsx) 的 loader。 - **权限**:路由里调 `authorize(c, "read")` 这类函数([`platform/http.ts`](https://github.com/mousebaoyan/mouseclock/blob/main/web/server/platform/http.ts)),规则在 [`platform/access.ts`](https://github.com/mousebaoyan/mouseclock/blob/main/web/server/platform/access.ts)。 - **样式**:照鼠洞,颜色和按钮在 [`app/app.css`](https://github.com/mousebaoyan/mouseclock/blob/main/web/app/app.css),组件在 `app/components/`。新页面做好后,把链接加进页头 [`site-header.tsx`](https://github.com/mousebaoyan/mouseclock/blob/main/web/app/components/site-header.tsx)。 - **令牌**: - 存在 `crawler_tokens`,库里只存 SHA-256; - 生成令牌的函数是 [`ingest/service.ts`](https://github.com/mousebaoyan/mouseclock/blob/main/web/server/modules/ingest/service.ts) 的 `createCrawlerToken`,[`scripts/crawler-token.ts`](https://github.com/mousebaoyan/mouseclock/blob/main/web/scripts/crawler-token.ts) 就是调它; - `last_seen_at` 是这个令牌上次来领活的时间。 - **站长的权限**:`authorize(c, "owner")`。 ### 范围 1. **接口**:列出令牌(名字、生成时间、上次来领活、是否作废)、生成(返回的令牌只出现这一次)、作废。只有站长能调,生成和作废记进 `audit_log`。 2. **页面 `/admin/settings`**: - 「抓取节点令牌」一节; - 生成后把令牌显示一次,提示复制保存; - 作废前要确认。 ### 建议的第一步 1. 在本 Issue 留言认领。 2. 先写接口和测试(非站长调不了、作废的令牌领不到活),开一个 Draft PR。 ### 验收标准 - [x] 站长能生成和作废抓取节点令牌,作废后马上不能用 - [x] 测试覆盖权限和作废,`pnpm check` 通过;接口文档已更新
Activity
实现抓取节点令牌的管理 (#93)