Skip to content

fix: 优化签到工作流与稳健性(免装 gh / cookie 合并 / 二维码依赖解析 / README 说明) - #28

Open
xfxx2022 wants to merge 8 commits into
develop202:mainfrom
xfxx2022:main
Open

fix: 优化签到工作流与稳健性(免装 gh / cookie 合并 / 二维码依赖解析 / README 说明)#28
xfxx2022 wants to merge 8 commits into
develop202:mainfrom
xfxx2022:main

Conversation

@xfxx2022

@xfxx2022 xfxx2022 commented Aug 9, 2026

Copy link
Copy Markdown
Contributor

改动清单(4 文件,+20/−13)

② 签到.yml 免装 gh、省 Actions 分钟

  • 删除「检查 GitHub CLI」里的 apt install gh 整段(GitHub 托管的 ubuntu-latest 已预装 gh,该段在标准 runner 上本就几乎不执行,删掉彻底避免任何安装/网络开销)。
  • permissions 增加 actions: writegithubSecrets.jsgh secret set 写回刷新后的 token,属于 actions 权限域,必需。
  • 未改 githubSecrets.js:仍用 gh 写 Secret。说明:GitHub Secrets API 要求用仓库公钥做 sealed-box 加密,curl 无法自加密;若改用 REST 需引入 tweetnacl 重写加密逻辑,会让"周日刷新 token 写回 Secret"这一关键路径增加失败风险——故选择"删安装段 + 保留 gh"的最稳方案,零新依赖、零加密风险。

③ README 意图说明

  • 第 57 行补充"安排在凌晨可抢在手动领取之前,避免与 APP 内领取当天青春版 VIP 名额冲突"的意图(cron 仍是北京 01:10,已对齐,无需改时间)。

④ server.js cookie 合并稳健性

  • Object.assign(req.cookies, cookie)query.cookie 为字符串/数组时,会把字符串当类数组注入 0,1,2… 字符索引键,污染传给酷狗的 cookie。
  • 改为:字符串 → cookieToJson对象 → 原样数组/其它 → 空对象;并用 Object.assign({}, req.cookies, cookieSource) 不再 mutate 原 req.cookies
  • 隔离单测 5/5 通过(字符串解码 / 对象 / undefined / 数组防污染 / 空串,且原 req.cookies 不受影响)。主签到走 HTTP Cookie 头,本就不传 ?cookie=,属额外防御层,行为等价。

⑤ qrcodeLogin.js 二维码依赖解析

  • 原硬编码 require('./api/node_modules/qrcode') → 改为优先 require('qrcode'),失败再回退 ./api/node_modules/qrcode
  • 两种环境(本地/全局安装、Actions 的 api/node_modules)均可用,本地开发更友好;Actions 走回退路径,行为不变。已用临时假包验证回退路径真实可取(用后清理)。

验证

  • node --checkapi/server.jsqrcodeLogin.js 全过。
  • 隔离单测:④ cookie 合并 5/5;⑤ qrcode 解析 1/1
  • git diff --stat:仅 4 个文件、+20/−13,无任何额外变更

兼容性 / 风险标注

  • 🟡 ② 扩大 actions: write 权限:写 Secret 的最小必要权限,非越权。
  • 🟢 ④ 纯防御、行为等价,不破坏现有合并语义。
  • 🟢 ⑤ 仅调整解析顺序,Actions 仍走原 api/node_modules 回退。

xfxx2022 and others added 5 commits August 9, 2026 13:21
- 删除 scheduled 触发的随机延迟步骤(原 DELAY=$((RANDOM%121)) 平均空耗 60 分钟/次)
- 签到改为北京时间 08:00 准时执行,单次由 ~60+ 分钟降至约 5 分钟
- timeout-minutes 由 150 下调至 30,防止异常卡死持续占用额度
- 签到.yml cron '0 0 * * *'(北京08:00)→ '10 17 * * *'(北京01:10)
- 背景:PR#23 将触发时间改为 08:00 意图做随机执行,但其随机延迟/超时部分已被 c2c3e69 回退为固定 08:00 整点;且当初未同步 README 造成文档矛盾
- 脚本与用户在 APP 手动领取共用当日青春版VIP名额(先到先得,main.js 已处理 130012/30002),凌晨跑可抢在手动操作前领取,避免空跑失败
- README 第57行现仍为 01:10,本次修正后 cron 与文档一致,无需改动 README 文字
- 签到.yml:删除 apt 安装 gh 段(ubuntu-latest 已预装),新增 actions:write 权限供 gh 写回刷新 token
- README:补充凌晨签到的意图说明(抢在手动领取前,避免青春版 VIP 名额冲突)
- api/server.js:cookie 合并前先规整为对象(字符串→cookieToJson / 对象原样 / 其余空),且不 mutate req.cookies
- qrcodeLogin.js:优先 require('qrcode'),失败再回退 api/node_modules 路径
dependabot Bot and others added 3 commits August 9, 2026 11:33
Bumps the npm_and_yarn group with 6 updates in the /api directory:

| Package | From | To |
| --- | --- | --- |
| [axios](https://github.com/axios/axios) | `1.15.2` | `1.18.0` |
| [body-parser](https://github.com/expressjs/body-parser) | `1.20.4` | `1.20.6` |
| [brace-expansion](https://github.com/juliangruber/brace-expansion) | `1.1.12` | `1.1.18` |
| [form-data](https://github.com/form-data/form-data) | `4.0.5` | `4.0.6` |
| [minimatch](https://github.com/isaacs/minimatch) | `3.1.2` | `3.1.5` |
| [qs](https://github.com/ljharb/qs) | `6.14.2` | `6.15.3` |



Updates `axios` from 1.15.2 to 1.18.0
- [Release notes](https://github.com/axios/axios/releases)
- [Changelog](https://github.com/axios/axios/blob/v1.x/CHANGELOG.md)
- [Commits](axios/axios@v1.15.2...v1.18.0)

Updates `body-parser` from 1.20.4 to 1.20.6
- [Release notes](https://github.com/expressjs/body-parser/releases)
- [Changelog](https://github.com/expressjs/body-parser/blob/master/HISTORY.md)
- [Commits](expressjs/body-parser@1.20.4...1.20.6)

Updates `brace-expansion` from 1.1.12 to 1.1.18
- [Release notes](https://github.com/juliangruber/brace-expansion/releases)
- [Commits](juliangruber/brace-expansion@v1.1.12...v1.1.18)

Updates `form-data` from 4.0.5 to 4.0.6
- [Changelog](https://github.com/form-data/form-data/blob/master/CHANGELOG.md)
- [Commits](form-data/form-data@v4.0.5...v4.0.6)

Updates `minimatch` from 3.1.2 to 3.1.5
- [Changelog](https://github.com/isaacs/minimatch/blob/main/changelog.md)
- [Commits](isaacs/minimatch@v3.1.2...v3.1.5)

Updates `qs` from 6.14.2 to 6.15.3
- [Changelog](https://github.com/ljharb/qs/blob/main/CHANGELOG.md)
- [Commits](ljharb/qs@v6.14.2...v6.15.3)

---
updated-dependencies:
- dependency-name: axios
  dependency-version: 1.18.0
  dependency-type: direct:production
  dependency-group: npm_and_yarn
- dependency-name: body-parser
  dependency-version: 1.20.6
  dependency-type: indirect
  dependency-group: npm_and_yarn
- dependency-name: brace-expansion
  dependency-version: 1.1.18
  dependency-type: indirect
  dependency-group: npm_and_yarn
- dependency-name: form-data
  dependency-version: 4.0.6
  dependency-type: indirect
  dependency-group: npm_and_yarn
- dependency-name: minimatch
  dependency-version: 3.1.5
  dependency-type: indirect
  dependency-group: npm_and_yarn
- dependency-name: qs
  dependency-version: 6.15.3
  dependency-type: indirect
  dependency-group: npm_and_yarn
...

Signed-off-by: dependabot[bot] <support@github.com>
…race-expansion,minimatch)

Bump the npm_and_yarn group across 1 directory with 6 updates
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant