web-checkin 1.1.0__tar.gz

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.
Files changed (30) hide show
  1. web_checkin-1.1.0/LICENSE +21 -0
  2. web_checkin-1.1.0/PKG-INFO +325 -0
  3. web_checkin-1.1.0/README.md +299 -0
  4. web_checkin-1.1.0/pyproject.toml +43 -0
  5. web_checkin-1.1.0/setup.cfg +4 -0
  6. web_checkin-1.1.0/web_checkin/__init__.py +7 -0
  7. web_checkin-1.1.0/web_checkin/__main__.py +8 -0
  8. web_checkin-1.1.0/web_checkin/account_store.py +282 -0
  9. web_checkin-1.1.0/web_checkin/app.py +474 -0
  10. web_checkin-1.1.0/web_checkin/cli.py +43 -0
  11. web_checkin-1.1.0/web_checkin/paths.py +72 -0
  12. web_checkin-1.1.0/web_checkin/qoder_checkin.py +147 -0
  13. web_checkin-1.1.0/web_checkin/qoder_login.py +273 -0
  14. web_checkin-1.1.0/web_checkin/qoder_tool.py +273 -0
  15. web_checkin-1.1.0/web_checkin/static/assets/index-CekGxNfP.js +10 -0
  16. web_checkin-1.1.0/web_checkin/static/assets/index-DBqTs3Tn.css +2 -0
  17. web_checkin-1.1.0/web_checkin/static/index.html +14 -0
  18. web_checkin-1.1.0/web_checkin/trae_tool.py +705 -0
  19. web_checkin-1.1.0/web_checkin/trae_usage.py +182 -0
  20. web_checkin-1.1.0/web_checkin/workbuddy_checkin.py +155 -0
  21. web_checkin-1.1.0/web_checkin/workbuddy_common.py +529 -0
  22. web_checkin-1.1.0/web_checkin/workbuddy_login.py +138 -0
  23. web_checkin-1.1.0/web_checkin/workbuddy_tool.py +537 -0
  24. web_checkin-1.1.0/web_checkin/workbuddy_usage.py +177 -0
  25. web_checkin-1.1.0/web_checkin.egg-info/PKG-INFO +325 -0
  26. web_checkin-1.1.0/web_checkin.egg-info/SOURCES.txt +28 -0
  27. web_checkin-1.1.0/web_checkin.egg-info/dependency_links.txt +1 -0
  28. web_checkin-1.1.0/web_checkin.egg-info/entry_points.txt +2 -0
  29. web_checkin-1.1.0/web_checkin.egg-info/requires.txt +4 -0
  30. web_checkin-1.1.0/web_checkin.egg-info/top_level.txt +1 -0
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 S-GGbond
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
@@ -0,0 +1,325 @@
1
+ Metadata-Version: 2.4
2
+ Name: web-checkin
3
+ Version: 1.1.0
4
+ Summary: WorkBuddy / Trae / Qoder 多账号签到与用量查询的本地 Web 中枢
5
+ Author: S-GGbond
6
+ License-Expression: MIT
7
+ Project-URL: Homepage, https://github.com/S-GGbond/web-checkin
8
+ Project-URL: Repository, https://github.com/S-GGbond/web-checkin
9
+ Project-URL: Issues, https://github.com/S-GGbond/web-checkin/issues
10
+ Keywords: checkin,workbuddy,trae,qoder,fastapi
11
+ Classifier: Environment :: Console
12
+ Classifier: Environment :: Web Environment
13
+ Classifier: Programming Language :: Python :: 3
14
+ Classifier: Programming Language :: Python :: 3.11
15
+ Classifier: Programming Language :: Python :: 3.12
16
+ Classifier: Programming Language :: Python :: 3.13
17
+ Classifier: Topic :: Utilities
18
+ Requires-Python: >=3.11
19
+ Description-Content-Type: text/markdown
20
+ License-File: LICENSE
21
+ Requires-Dist: fastapi>=0.110
22
+ Requires-Dist: uvicorn[standard]>=0.29
23
+ Requires-Dist: cryptography>=42
24
+ Requires-Dist: apscheduler<4,>=3.10
25
+ Dynamic: license-file
26
+
27
+ # Web Check-in Hub
28
+
29
+ WorkBuddy / Trae / Qoder 多账号签到与用量查询中枢。项目提供一个 FastAPI 本地 Web 服务,把各平台的账号状态、余额、签到结果和用量明细放在同一个界面中管理。
30
+
31
+ > 仅供个人管理自己拥有授权的账号。请不要用于批量注册、共享账号、绕过平台限制或任何违反平台服务条款的场景。
32
+
33
+ ## 功能概览
34
+
35
+ ### 账号与状态
36
+
37
+ - WorkBuddy、Trae、Qoder 账号分别走平台官方授权流程。
38
+ - 登录态写入本地 SQLite 数据库,数据库默认 `0600` 权限。
39
+ - 支持账号启用 / 停用 / 删除。
40
+ - 页面打开后自动刷新所有账号的实时余额。
41
+ - WorkBuddy 使用平台返回的 `today_checked_in`,Trae 使用 `checked_in`;Qoder 没有明确“今日已签”字段,因此只有 `CLAIMED` 活动或当天本地成功领取记录才会显示“今日已签到”。
42
+ - 每个账号可配置独立的每日签到时间。
43
+ - 服务重启后,如果当天设定时间已过且尚未完成签到,会补跑一次。
44
+
45
+ ### 签到与日志
46
+
47
+ - 支持单账号签到、全部账号签到。
48
+ - 每个账号的定时触发会生成 `schedule` 日志。
49
+ - 实际签到结果会生成 `claim` / `already` 日志。
50
+ - 登录、状态刷新、签到失败信息都会记录在执行日志中。
51
+
52
+ ### WorkBuddy 用量
53
+
54
+ - 使用浏览器 Cookie 查询 WorkBuddy 积分消耗明细。
55
+ - 展示每日积分趋势、模型分布和分页请求明细。
56
+ - 支持导出 CSV。
57
+ - Cookie 只保存在当前查询请求内存中,不会写入账号库或日志。
58
+
59
+ ### Trae 用量
60
+
61
+ - 复用统一账号库中的 Trae 登录态查询积分明细。
62
+ - 展示总消耗、每日曲线、模型分布和请求明细。
63
+ - 临期登录态会自动续期并加密回写。
64
+ - 用量接口分页使用 `page_size=20`,该值是当前验证可用的稳定分页大小。
65
+
66
+ ## 界面结构
67
+
68
+ 页面自上而下分为:
69
+
70
+ 1. 顶部栏(品牌、时钟、自动刷新、刷新余额、全部签到)。
71
+ 2. 账号统计卡片区。
72
+ 3. 添加账号(三平台官方授权登录)与独立定时说明。
73
+ 4. 托管账号列表(按平台分组,卡片内含余额/活动状态、签到状态、每日定时、操作按钮)。
74
+ 5. WorkBuddy 积分消耗明细。
75
+ 6. Trae 积分用量。
76
+ 7. 执行日志。
77
+
78
+ > 每日定时时间在「托管账号列表」中每张账号卡片的「定时」入口里单独设置。
79
+
80
+ ## 环境要求
81
+
82
+ - Python 3.11 或更高版本。
83
+ - 现代浏览器。
84
+ - 各平台的官方授权页面可正常访问。
85
+ - 仅当需要修改界面时,才需要 Node.js 20+(构建前端)。
86
+
87
+ ## 安装
88
+
89
+ 推荐从 PyPI 安装为独立命令(pipx 会为它创建隔离环境):
90
+
91
+ ```bash
92
+ pipx install web-checkin
93
+ ```
94
+
95
+ 也可以直接用 pip:
96
+
97
+ ```bash
98
+ pip install web-checkin
99
+ ```
100
+
101
+ 从源码安装:
102
+
103
+ ```bash
104
+ python -m venv .venv
105
+ source .venv/bin/activate
106
+ python -m pip install -r requirements.txt
107
+ # 或直接安装本仓库:pip install .
108
+ ```
109
+
110
+ 依赖包括 FastAPI、Uvicorn、cryptography 和 APScheduler。
111
+
112
+ 前端已把构建产物提交到 `web_checkin/static/`,**无需 Node 即可直接运行**。只有在改动 `frontend/` 源码后才需要重新构建:
113
+
114
+ ```bash
115
+ cd frontend
116
+ npm install
117
+ npm run build # 产物输出到 ../web_checkin/static
118
+ ```
119
+
120
+ ## 启动
121
+
122
+ ```bash
123
+ web-checkin
124
+ ```
125
+
126
+ 打开:
127
+
128
+ ```text
129
+ http://127.0.0.1:8320
130
+ ```
131
+
132
+ 也可以直接从源码运行(开发时):
133
+
134
+ ```bash
135
+ python -m web_checkin
136
+ # 或:python -m uvicorn web_checkin.app:app --host 127.0.0.1 --port 8320
137
+ ```
138
+
139
+ 命令行参数:
140
+
141
+ | 参数 | 说明 | 默认值 |
142
+ |---|---|---|
143
+ | `--host` | 监听地址 | `127.0.0.1` |
144
+ | `--port` | 监听端口 | `8320` |
145
+ | `--db` | 账号数据库路径 | 用户数据目录下的 `checkin-hub.sqlite3` |
146
+ | `--no-browser` | 启动后不自动打开浏览器 | 关闭 |
147
+ | `--log-level` | uvicorn 日志级别 | `info` |
148
+
149
+ 服务默认只监听本机地址。不要直接把无认证的管理端暴露到公网。如需局域网访问,请自行添加反向代理、访问控制和 HTTPS。
150
+
151
+ ## 环境变量
152
+
153
+ | 变量 | 说明 | 默认值 |
154
+ |---|---|---|
155
+ | `WEB_CHECKIN_HOME` | 应用数据目录(数据库、设备指纹等) | 平台数据目录,见下 |
156
+ | `CHECKIN_HUB_DB` | 统一账号数据库路径 | `WEB_CHECKIN_HOME/checkin-hub.sqlite3` |
157
+ | `TRAE_IDENTITY_PATH` | Trae 设备指纹文件路径 | `WEB_CHECKIN_HOME/trae-identity.json` |
158
+ | `TRAE_LEGACY_DB` | 可选的旧 Trae 数据库路径 | `~/.trae-checkin/trae_checkin.db` |
159
+ | `QODER_DATA_DIR` | Qoder 登录态和机器 ID 目录 | `~/.qoder-checkin` |
160
+
161
+ 应用数据目录按平台自动选择:
162
+
163
+ - Linux:`$XDG_DATA_HOME/web-checkin` 或 `~/.local/share/web-checkin`
164
+ - macOS:`~/Library/Application Support/web-checkin`
165
+ - Windows:`%LOCALAPPDATA%\web-checkin`
166
+
167
+ 兼容旧用法:如果应用数据目录里还没有 `checkin-hub.sqlite3` / `trae-identity.json`,而当前工作目录存在同名旧文件,会继续复用旧文件,方便从仓库目录直接运行平滑迁移。
168
+
169
+ Qoder 登录脚本已内置在项目内。服务启动时会尝试从 `QODER_DATA_DIR/qoder_auth.json` 导入既有登录态;目录不存在或还没有登录态时,不影响 WorkBuddy / Trae 启动。
170
+
171
+ ## 主要 API
172
+
173
+ | 方法 | 路径 | 说明 |
174
+ |---|---|---|
175
+ | `GET` | `/api/health` | 健康检查 |
176
+ | `GET` | `/api/accounts` | 获取账号列表 |
177
+ | `GET` | `/api/logs` | 获取执行日志 |
178
+ | `POST` | `/api/status` | 刷新全部账号状态 |
179
+ | `POST` | `/api/accounts/{id}/status` | 刷新单个账号状态 |
180
+ | `POST` | `/api/accounts/{id}/checkin` | 手动签到单个账号 |
181
+ | `POST` | `/api/checkin` | 手动签到全部启用账号 |
182
+ | `POST` | `/api/accounts/{id}/schedule` | 设置独立定时任务 |
183
+ | `POST` | `/api/accounts/{id}/enable?enabled=true|false` | 启用或停用账号 |
184
+ | `DELETE` | `/api/accounts/{id}` | 删除账号 |
185
+ | `POST` | `/api/login/workbuddy` | 启动 WorkBuddy 登录 |
186
+ | `POST` | `/api/login/trae` | 启动 Trae 登录 |
187
+ | `POST` | `/api/login/qoder` | 启动 Qoder 登录 |
188
+ | `POST` | `/api/workbuddy/usage` | 查询 WorkBuddy 积分明细 |
189
+ | `POST` | `/api/trae/usage` | 查询 Trae 积分明细 |
190
+
191
+ ## 定时任务
192
+
193
+ 每个账号保存独立的:
194
+
195
+ - `schedule_enabled`
196
+ - `schedule_time`
197
+ - `schedule_last_date`
198
+
199
+ 定时任务由 APScheduler 的 `AsyncIOScheduler` 驱动(非轮询)。服务启动时按账号注册每日 `CronTrigger`,到点直接触发,不再空转检查数据库:
200
+
201
+ - 账号启用且定时开启时,注册/更新一条每日定时任务;关闭账号或关闭定时即移除任务。
202
+ - 计划时间、启用状态变更,以及登录新增账号后,都会即时重排对应的定时任务。
203
+ - `schedule_last_date` 只在当日任务「完成」后写入。签到成功或平台返回「今日已签到」均视为完成。
204
+ - 签到失败会按固定间隔自动重试,默认最多 3 次、间隔 300 秒(用一次性任务重排);重试次数用尽后放弃当日重试并记录失败日志。
205
+ - 服务重启后,如果当天设定时间已过且尚未完成,会由启动补跑任务补签一次。
206
+ - 每次调度触发都会生成 `schedule` 日志,并标注是第几次尝试。
207
+
208
+ 日志顺序:
209
+
210
+ 1. `schedule`:记录定时任务已触发(含第几次尝试)。
211
+ 2. `claim` / `already`:记录实际签到结果。
212
+ 3. 失败时记录错误信息;重试耗尽时额外记录一条失败 `schedule` 日志。
213
+
214
+ ## 数据库
215
+
216
+ 统一账号数据库默认为应用数据目录下的 `checkin-hub.sqlite3`(见「环境变量」),也可用 `--db` 或 `CHECKIN_HUB_DB` 指定。
217
+
218
+ 核心表:
219
+
220
+ - `accounts`:账号、登录态、状态和定时配置。
221
+ - `checkin_logs`:登录、状态刷新、签到和调度日志。
222
+ - `settings`:运行级配置。
223
+
224
+ 账号库会保存 access token、refresh token 或加密后的平台登录态。请确保:
225
+
226
+ - 不把数据库提交到 Git。
227
+ - 不把数据库复制到公共目录。
228
+ - 不把日志、数据库或 API 响应截图发给别人。
229
+ - 定期备份时也仅保存在受控设备中。
230
+
231
+ ## 安全约定
232
+
233
+ - 服务只监听 `127.0.0.1`。
234
+ - `.gitignore` 已排除本地数据库、截图、浏览器调试数据和本机分析文档。
235
+ - WorkBuddy 用量 Cookie 只用于当次查询,前端提交后立即清空输入框。
236
+ - Trae 登录态使用加密容器保存,续期后自动回写。
237
+ - 请不要在 issue、日志、聊天或截图中粘贴 token、refresh token、Cookie 或完整账号数据库。
238
+
239
+ ## 测试
240
+
241
+ ```bash
242
+ python -m unittest -v test_qoder_status.py test_trae_usage.py test_workbuddy_usage.py test_trae_login_callback.py
243
+ python -m compileall -q web_checkin
244
+ cd frontend && npm run lint # 前端类型检查
245
+ ```
246
+
247
+ ## 项目结构
248
+
249
+ ```text
250
+ .
251
+ ├── pyproject.toml # 打包配置(命令入口:web-checkin)
252
+ ├── web_checkin/ # Python 包
253
+ │ ├── __init__.py
254
+ │ ├── __main__.py # python -m web_checkin
255
+ │ ├── cli.py # 命令行入口,参数解析 + 启动 uvicorn
256
+ │ ├── paths.py # 静态资源 / 数据目录 / 数据库路径解析
257
+ │ ├── app.py # FastAPI 服务、路由、调度器
258
+ │ ├── account_store.py # 统一账号和日志存储
259
+ │ ├── trae_tool.py # Trae 登录、状态、签到
260
+ │ ├── trae_usage.py # Trae 用量查询与聚合
261
+ │ ├── workbuddy_tool.py # WorkBuddy 登录、状态、签到
262
+ │ ├── workbuddy_usage.py # WorkBuddy 用量查询脚本
263
+ │ ├── workbuddy_common.py # WorkBuddy 公共请求与存储
264
+ │ ├── workbuddy_login.py # WorkBuddy 独立登录脚本
265
+ │ ├── workbuddy_checkin.py # WorkBuddy 独立签到脚本
266
+ │ ├── qoder_tool.py # Qoder Web Hub 接入
267
+ │ ├── qoder_login.py # Qoder 设备码登录
268
+ │ ├── qoder_checkin.py # Qoder 独立签到脚本
269
+ │ └── static/ # 前端构建产物(由 npm run build 生成)
270
+ │ ├── index.html
271
+ │ └── assets/
272
+ ├── frontend/ # 界面源码(React + Vite + Tailwind)
273
+ │ ├── src/
274
+ │ │ ├── App.tsx # 页面组装
275
+ │ │ ├── components/ # 顶部栏、统计、账号卡片、用量、日志、弹窗
276
+ │ │ ├── services/api.ts # 对接 FastAPI 的数据访问层
277
+ │ │ └── types/index.ts # 与后端对齐的类型定义
278
+ │ └── vite.config.ts # 构建输出到 ../web_checkin/static
279
+ ├── workbuddy-tools/ # 独立 Node.js 工具集
280
+ ├── test_trae_usage.py # Trae 用量测试
281
+ ├── test_trae_login_callback.py # Trae 登录本地回调回归测试
282
+ ├── test_workbuddy_usage.py # WorkBuddy 用量测试
283
+ └── test_qoder_status.py # Qoder 状态解析测试
284
+ ```
285
+
286
+ > `web_checkin/static/` 是前端构建产物,请勿手工编辑;修改界面请改 `frontend/src/` 后重新 `npm run build`。
287
+
288
+ 包内的独立脚本(如 Qoder / WorkBuddy 登录、签到、用量)改用模块方式运行,例如:
289
+
290
+ ```bash
291
+ python -m web_checkin.qoder_checkin --list
292
+ python -m web_checkin.trae_usage --start 2026-10-01 --end 2026-10-15
293
+ ```
294
+
295
+ ## WorkBuddy 独立工具
296
+
297
+ `workbuddy-tools/` 提供独立 Node.js 脚本,适合在没有启动 Web Hub 的场景使用。详细参数见:
298
+
299
+ ```text
300
+ workbuddy-tools/README.md
301
+ ```
302
+
303
+ 这些工具也只应访问你自己授权的账号,并同样需要注意数据库和登录态安全。
304
+
305
+ ## 常见问题
306
+
307
+ ### 页面打开后余额为空
308
+
309
+ 可能是平台接口临时失败或登录态过期。点击账号卡片中的“刷新状态”,或先重新登录对应平台。
310
+
311
+ ### Trae 用量查询失败
312
+
313
+ 确认账号仍能正常签到,并确认 Trae 登录态没有过期。当前接口分页必须使用 `page_size=20`;如果平台后续调整接口,需要重新核对请求结构。
314
+
315
+ ### WorkBuddy 用量查询失败
316
+
317
+ WorkBuddy 用量接口依赖浏览器 Cookie。Cookie 过期、账号会话失效、请求头不完整或站点前端变更都可能导致失败。请重新复制新的 Cookie,并不要把它提交到仓库。
318
+
319
+ ### Qoder 登录不可用
320
+
321
+ Qoder 登录脚本已随项目内置。若导入旧登录态失败,请确认 `QODER_DATA_DIR/qoder_auth.json` 存在且 refreshToken 未过期;也可以直接重新执行 Web 登录。
322
+
323
+ ## 免责声明
324
+
325
+ 本项目与 WorkBuddy、Trae、Qoder 官方没有隶属关系。接口和页面可能随平台更新变化。使用本项目时请遵守目标平台的服务条款和所在地区法律。
@@ -0,0 +1,299 @@
1
+ # Web Check-in Hub
2
+
3
+ WorkBuddy / Trae / Qoder 多账号签到与用量查询中枢。项目提供一个 FastAPI 本地 Web 服务,把各平台的账号状态、余额、签到结果和用量明细放在同一个界面中管理。
4
+
5
+ > 仅供个人管理自己拥有授权的账号。请不要用于批量注册、共享账号、绕过平台限制或任何违反平台服务条款的场景。
6
+
7
+ ## 功能概览
8
+
9
+ ### 账号与状态
10
+
11
+ - WorkBuddy、Trae、Qoder 账号分别走平台官方授权流程。
12
+ - 登录态写入本地 SQLite 数据库,数据库默认 `0600` 权限。
13
+ - 支持账号启用 / 停用 / 删除。
14
+ - 页面打开后自动刷新所有账号的实时余额。
15
+ - WorkBuddy 使用平台返回的 `today_checked_in`,Trae 使用 `checked_in`;Qoder 没有明确“今日已签”字段,因此只有 `CLAIMED` 活动或当天本地成功领取记录才会显示“今日已签到”。
16
+ - 每个账号可配置独立的每日签到时间。
17
+ - 服务重启后,如果当天设定时间已过且尚未完成签到,会补跑一次。
18
+
19
+ ### 签到与日志
20
+
21
+ - 支持单账号签到、全部账号签到。
22
+ - 每个账号的定时触发会生成 `schedule` 日志。
23
+ - 实际签到结果会生成 `claim` / `already` 日志。
24
+ - 登录、状态刷新、签到失败信息都会记录在执行日志中。
25
+
26
+ ### WorkBuddy 用量
27
+
28
+ - 使用浏览器 Cookie 查询 WorkBuddy 积分消耗明细。
29
+ - 展示每日积分趋势、模型分布和分页请求明细。
30
+ - 支持导出 CSV。
31
+ - Cookie 只保存在当前查询请求内存中,不会写入账号库或日志。
32
+
33
+ ### Trae 用量
34
+
35
+ - 复用统一账号库中的 Trae 登录态查询积分明细。
36
+ - 展示总消耗、每日曲线、模型分布和请求明细。
37
+ - 临期登录态会自动续期并加密回写。
38
+ - 用量接口分页使用 `page_size=20`,该值是当前验证可用的稳定分页大小。
39
+
40
+ ## 界面结构
41
+
42
+ 页面自上而下分为:
43
+
44
+ 1. 顶部栏(品牌、时钟、自动刷新、刷新余额、全部签到)。
45
+ 2. 账号统计卡片区。
46
+ 3. 添加账号(三平台官方授权登录)与独立定时说明。
47
+ 4. 托管账号列表(按平台分组,卡片内含余额/活动状态、签到状态、每日定时、操作按钮)。
48
+ 5. WorkBuddy 积分消耗明细。
49
+ 6. Trae 积分用量。
50
+ 7. 执行日志。
51
+
52
+ > 每日定时时间在「托管账号列表」中每张账号卡片的「定时」入口里单独设置。
53
+
54
+ ## 环境要求
55
+
56
+ - Python 3.11 或更高版本。
57
+ - 现代浏览器。
58
+ - 各平台的官方授权页面可正常访问。
59
+ - 仅当需要修改界面时,才需要 Node.js 20+(构建前端)。
60
+
61
+ ## 安装
62
+
63
+ 推荐从 PyPI 安装为独立命令(pipx 会为它创建隔离环境):
64
+
65
+ ```bash
66
+ pipx install web-checkin
67
+ ```
68
+
69
+ 也可以直接用 pip:
70
+
71
+ ```bash
72
+ pip install web-checkin
73
+ ```
74
+
75
+ 从源码安装:
76
+
77
+ ```bash
78
+ python -m venv .venv
79
+ source .venv/bin/activate
80
+ python -m pip install -r requirements.txt
81
+ # 或直接安装本仓库:pip install .
82
+ ```
83
+
84
+ 依赖包括 FastAPI、Uvicorn、cryptography 和 APScheduler。
85
+
86
+ 前端已把构建产物提交到 `web_checkin/static/`,**无需 Node 即可直接运行**。只有在改动 `frontend/` 源码后才需要重新构建:
87
+
88
+ ```bash
89
+ cd frontend
90
+ npm install
91
+ npm run build # 产物输出到 ../web_checkin/static
92
+ ```
93
+
94
+ ## 启动
95
+
96
+ ```bash
97
+ web-checkin
98
+ ```
99
+
100
+ 打开:
101
+
102
+ ```text
103
+ http://127.0.0.1:8320
104
+ ```
105
+
106
+ 也可以直接从源码运行(开发时):
107
+
108
+ ```bash
109
+ python -m web_checkin
110
+ # 或:python -m uvicorn web_checkin.app:app --host 127.0.0.1 --port 8320
111
+ ```
112
+
113
+ 命令行参数:
114
+
115
+ | 参数 | 说明 | 默认值 |
116
+ |---|---|---|
117
+ | `--host` | 监听地址 | `127.0.0.1` |
118
+ | `--port` | 监听端口 | `8320` |
119
+ | `--db` | 账号数据库路径 | 用户数据目录下的 `checkin-hub.sqlite3` |
120
+ | `--no-browser` | 启动后不自动打开浏览器 | 关闭 |
121
+ | `--log-level` | uvicorn 日志级别 | `info` |
122
+
123
+ 服务默认只监听本机地址。不要直接把无认证的管理端暴露到公网。如需局域网访问,请自行添加反向代理、访问控制和 HTTPS。
124
+
125
+ ## 环境变量
126
+
127
+ | 变量 | 说明 | 默认值 |
128
+ |---|---|---|
129
+ | `WEB_CHECKIN_HOME` | 应用数据目录(数据库、设备指纹等) | 平台数据目录,见下 |
130
+ | `CHECKIN_HUB_DB` | 统一账号数据库路径 | `WEB_CHECKIN_HOME/checkin-hub.sqlite3` |
131
+ | `TRAE_IDENTITY_PATH` | Trae 设备指纹文件路径 | `WEB_CHECKIN_HOME/trae-identity.json` |
132
+ | `TRAE_LEGACY_DB` | 可选的旧 Trae 数据库路径 | `~/.trae-checkin/trae_checkin.db` |
133
+ | `QODER_DATA_DIR` | Qoder 登录态和机器 ID 目录 | `~/.qoder-checkin` |
134
+
135
+ 应用数据目录按平台自动选择:
136
+
137
+ - Linux:`$XDG_DATA_HOME/web-checkin` 或 `~/.local/share/web-checkin`
138
+ - macOS:`~/Library/Application Support/web-checkin`
139
+ - Windows:`%LOCALAPPDATA%\web-checkin`
140
+
141
+ 兼容旧用法:如果应用数据目录里还没有 `checkin-hub.sqlite3` / `trae-identity.json`,而当前工作目录存在同名旧文件,会继续复用旧文件,方便从仓库目录直接运行平滑迁移。
142
+
143
+ Qoder 登录脚本已内置在项目内。服务启动时会尝试从 `QODER_DATA_DIR/qoder_auth.json` 导入既有登录态;目录不存在或还没有登录态时,不影响 WorkBuddy / Trae 启动。
144
+
145
+ ## 主要 API
146
+
147
+ | 方法 | 路径 | 说明 |
148
+ |---|---|---|
149
+ | `GET` | `/api/health` | 健康检查 |
150
+ | `GET` | `/api/accounts` | 获取账号列表 |
151
+ | `GET` | `/api/logs` | 获取执行日志 |
152
+ | `POST` | `/api/status` | 刷新全部账号状态 |
153
+ | `POST` | `/api/accounts/{id}/status` | 刷新单个账号状态 |
154
+ | `POST` | `/api/accounts/{id}/checkin` | 手动签到单个账号 |
155
+ | `POST` | `/api/checkin` | 手动签到全部启用账号 |
156
+ | `POST` | `/api/accounts/{id}/schedule` | 设置独立定时任务 |
157
+ | `POST` | `/api/accounts/{id}/enable?enabled=true|false` | 启用或停用账号 |
158
+ | `DELETE` | `/api/accounts/{id}` | 删除账号 |
159
+ | `POST` | `/api/login/workbuddy` | 启动 WorkBuddy 登录 |
160
+ | `POST` | `/api/login/trae` | 启动 Trae 登录 |
161
+ | `POST` | `/api/login/qoder` | 启动 Qoder 登录 |
162
+ | `POST` | `/api/workbuddy/usage` | 查询 WorkBuddy 积分明细 |
163
+ | `POST` | `/api/trae/usage` | 查询 Trae 积分明细 |
164
+
165
+ ## 定时任务
166
+
167
+ 每个账号保存独立的:
168
+
169
+ - `schedule_enabled`
170
+ - `schedule_time`
171
+ - `schedule_last_date`
172
+
173
+ 定时任务由 APScheduler 的 `AsyncIOScheduler` 驱动(非轮询)。服务启动时按账号注册每日 `CronTrigger`,到点直接触发,不再空转检查数据库:
174
+
175
+ - 账号启用且定时开启时,注册/更新一条每日定时任务;关闭账号或关闭定时即移除任务。
176
+ - 计划时间、启用状态变更,以及登录新增账号后,都会即时重排对应的定时任务。
177
+ - `schedule_last_date` 只在当日任务「完成」后写入。签到成功或平台返回「今日已签到」均视为完成。
178
+ - 签到失败会按固定间隔自动重试,默认最多 3 次、间隔 300 秒(用一次性任务重排);重试次数用尽后放弃当日重试并记录失败日志。
179
+ - 服务重启后,如果当天设定时间已过且尚未完成,会由启动补跑任务补签一次。
180
+ - 每次调度触发都会生成 `schedule` 日志,并标注是第几次尝试。
181
+
182
+ 日志顺序:
183
+
184
+ 1. `schedule`:记录定时任务已触发(含第几次尝试)。
185
+ 2. `claim` / `already`:记录实际签到结果。
186
+ 3. 失败时记录错误信息;重试耗尽时额外记录一条失败 `schedule` 日志。
187
+
188
+ ## 数据库
189
+
190
+ 统一账号数据库默认为应用数据目录下的 `checkin-hub.sqlite3`(见「环境变量」),也可用 `--db` 或 `CHECKIN_HUB_DB` 指定。
191
+
192
+ 核心表:
193
+
194
+ - `accounts`:账号、登录态、状态和定时配置。
195
+ - `checkin_logs`:登录、状态刷新、签到和调度日志。
196
+ - `settings`:运行级配置。
197
+
198
+ 账号库会保存 access token、refresh token 或加密后的平台登录态。请确保:
199
+
200
+ - 不把数据库提交到 Git。
201
+ - 不把数据库复制到公共目录。
202
+ - 不把日志、数据库或 API 响应截图发给别人。
203
+ - 定期备份时也仅保存在受控设备中。
204
+
205
+ ## 安全约定
206
+
207
+ - 服务只监听 `127.0.0.1`。
208
+ - `.gitignore` 已排除本地数据库、截图、浏览器调试数据和本机分析文档。
209
+ - WorkBuddy 用量 Cookie 只用于当次查询,前端提交后立即清空输入框。
210
+ - Trae 登录态使用加密容器保存,续期后自动回写。
211
+ - 请不要在 issue、日志、聊天或截图中粘贴 token、refresh token、Cookie 或完整账号数据库。
212
+
213
+ ## 测试
214
+
215
+ ```bash
216
+ python -m unittest -v test_qoder_status.py test_trae_usage.py test_workbuddy_usage.py test_trae_login_callback.py
217
+ python -m compileall -q web_checkin
218
+ cd frontend && npm run lint # 前端类型检查
219
+ ```
220
+
221
+ ## 项目结构
222
+
223
+ ```text
224
+ .
225
+ ├── pyproject.toml # 打包配置(命令入口:web-checkin)
226
+ ├── web_checkin/ # Python 包
227
+ │ ├── __init__.py
228
+ │ ├── __main__.py # python -m web_checkin
229
+ │ ├── cli.py # 命令行入口,参数解析 + 启动 uvicorn
230
+ │ ├── paths.py # 静态资源 / 数据目录 / 数据库路径解析
231
+ │ ├── app.py # FastAPI 服务、路由、调度器
232
+ │ ├── account_store.py # 统一账号和日志存储
233
+ │ ├── trae_tool.py # Trae 登录、状态、签到
234
+ │ ├── trae_usage.py # Trae 用量查询与聚合
235
+ │ ├── workbuddy_tool.py # WorkBuddy 登录、状态、签到
236
+ │ ├── workbuddy_usage.py # WorkBuddy 用量查询脚本
237
+ │ ├── workbuddy_common.py # WorkBuddy 公共请求与存储
238
+ │ ├── workbuddy_login.py # WorkBuddy 独立登录脚本
239
+ │ ├── workbuddy_checkin.py # WorkBuddy 独立签到脚本
240
+ │ ├── qoder_tool.py # Qoder Web Hub 接入
241
+ │ ├── qoder_login.py # Qoder 设备码登录
242
+ │ ├── qoder_checkin.py # Qoder 独立签到脚本
243
+ │ └── static/ # 前端构建产物(由 npm run build 生成)
244
+ │ ├── index.html
245
+ │ └── assets/
246
+ ├── frontend/ # 界面源码(React + Vite + Tailwind)
247
+ │ ├── src/
248
+ │ │ ├── App.tsx # 页面组装
249
+ │ │ ├── components/ # 顶部栏、统计、账号卡片、用量、日志、弹窗
250
+ │ │ ├── services/api.ts # 对接 FastAPI 的数据访问层
251
+ │ │ └── types/index.ts # 与后端对齐的类型定义
252
+ │ └── vite.config.ts # 构建输出到 ../web_checkin/static
253
+ ├── workbuddy-tools/ # 独立 Node.js 工具集
254
+ ├── test_trae_usage.py # Trae 用量测试
255
+ ├── test_trae_login_callback.py # Trae 登录本地回调回归测试
256
+ ├── test_workbuddy_usage.py # WorkBuddy 用量测试
257
+ └── test_qoder_status.py # Qoder 状态解析测试
258
+ ```
259
+
260
+ > `web_checkin/static/` 是前端构建产物,请勿手工编辑;修改界面请改 `frontend/src/` 后重新 `npm run build`。
261
+
262
+ 包内的独立脚本(如 Qoder / WorkBuddy 登录、签到、用量)改用模块方式运行,例如:
263
+
264
+ ```bash
265
+ python -m web_checkin.qoder_checkin --list
266
+ python -m web_checkin.trae_usage --start 2026-10-01 --end 2026-10-15
267
+ ```
268
+
269
+ ## WorkBuddy 独立工具
270
+
271
+ `workbuddy-tools/` 提供独立 Node.js 脚本,适合在没有启动 Web Hub 的场景使用。详细参数见:
272
+
273
+ ```text
274
+ workbuddy-tools/README.md
275
+ ```
276
+
277
+ 这些工具也只应访问你自己授权的账号,并同样需要注意数据库和登录态安全。
278
+
279
+ ## 常见问题
280
+
281
+ ### 页面打开后余额为空
282
+
283
+ 可能是平台接口临时失败或登录态过期。点击账号卡片中的“刷新状态”,或先重新登录对应平台。
284
+
285
+ ### Trae 用量查询失败
286
+
287
+ 确认账号仍能正常签到,并确认 Trae 登录态没有过期。当前接口分页必须使用 `page_size=20`;如果平台后续调整接口,需要重新核对请求结构。
288
+
289
+ ### WorkBuddy 用量查询失败
290
+
291
+ WorkBuddy 用量接口依赖浏览器 Cookie。Cookie 过期、账号会话失效、请求头不完整或站点前端变更都可能导致失败。请重新复制新的 Cookie,并不要把它提交到仓库。
292
+
293
+ ### Qoder 登录不可用
294
+
295
+ Qoder 登录脚本已随项目内置。若导入旧登录态失败,请确认 `QODER_DATA_DIR/qoder_auth.json` 存在且 refreshToken 未过期;也可以直接重新执行 Web 登录。
296
+
297
+ ## 免责声明
298
+
299
+ 本项目与 WorkBuddy、Trae、Qoder 官方没有隶属关系。接口和页面可能随平台更新变化。使用本项目时请遵守目标平台的服务条款和所在地区法律。
@@ -0,0 +1,43 @@
1
+ [build-system]
2
+ requires = ["setuptools>=77", "wheel"]
3
+ build-backend = "setuptools.build_meta"
4
+
5
+ [project]
6
+ name = "web-checkin"
7
+ version = "1.1.0"
8
+ description = "WorkBuddy / Trae / Qoder 多账号签到与用量查询的本地 Web 中枢"
9
+ readme = "README.md"
10
+ requires-python = ">=3.11"
11
+ license = "MIT"
12
+ license-files = ["LICENSE"]
13
+ authors = [{ name = "S-GGbond" }]
14
+ keywords = ["checkin", "workbuddy", "trae", "qoder", "fastapi"]
15
+ classifiers = [
16
+ "Environment :: Console",
17
+ "Environment :: Web Environment",
18
+ "Programming Language :: Python :: 3",
19
+ "Programming Language :: Python :: 3.11",
20
+ "Programming Language :: Python :: 3.12",
21
+ "Programming Language :: Python :: 3.13",
22
+ "Topic :: Utilities",
23
+ ]
24
+ dependencies = [
25
+ "fastapi>=0.110",
26
+ "uvicorn[standard]>=0.29",
27
+ "cryptography>=42",
28
+ "apscheduler>=3.10,<4",
29
+ ]
30
+
31
+ [project.urls]
32
+ Homepage = "https://github.com/S-GGbond/web-checkin"
33
+ Repository = "https://github.com/S-GGbond/web-checkin"
34
+ Issues = "https://github.com/S-GGbond/web-checkin/issues"
35
+
36
+ [project.scripts]
37
+ web-checkin = "web_checkin.cli:main"
38
+
39
+ [tool.setuptools]
40
+ packages = ["web_checkin"]
41
+
42
+ [tool.setuptools.package-data]
43
+ web_checkin = ["static/*", "static/assets/*"]