From 8c225038116396bae0a0c7f4738059499df6b7c6 Mon Sep 17 00:00:00 2001 From: hanyixuanten <105723997+hanyixuanten@users.noreply.github.com> Date: Fri, 3 Jul 2026 21:58:05 +0800 Subject: [PATCH] =?UTF-8?q?Revert=20"feat:=20=E6=B7=BB=E5=8A=A0=E6=94=B6?= =?UTF-8?q?=E8=97=8F=E5=A4=B9=E9=80=89=E6=8B=A9=E5=92=8C=E5=8F=96=E6=B6=88?= =?UTF-8?q?=E6=94=B6=E8=97=8F=E5=8A=9F=E8=83=BD"?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .gitignore | 2 +- .husky/commit-msg | 1 - .husky/pre-commit | 1 - .mimocode/plans/1783084400288-jolly-rocket.md | 252 ------------------ .prettierrc.js | 2 +- .stylelintrc.js | 2 + AGENTS.md | 67 ----- eslint.config.mjs | 44 --- husky.sh | 4 +- package.json | 2 +- quickapp.config.js | 17 +- scripts/build_rw5.py | 4 +- scripts/build_s3s4.py | 4 +- scripts/buildtools.py | 8 +- src/animation/engine.ts | 20 +- src/app.ux | 33 +-- src/articletools.ts | 3 +- src/asyncapi/file.ts | 2 +- src/bilibiliclient/api/request.ts | 8 +- src/bilibiliclient/folder/favfolder.ts | 8 - src/bilibiliclient/message/message.ts | 2 + src/bilibiliclient/video/action.ts | 54 +--- src/eula.ts | 20 +- src/funnytips.ts | 3 +- src/jumpcheck.ts | 7 +- src/logger/logger.ts | 2 +- src/manifest.json | 2 +- .../app/features/dynamic/detail/detail.ux | 2 +- src/pages/reply/replys/replys.ux | 17 +- src/pages/search/search/search.ux | 2 +- src/pages/user/user.ux | 2 +- src/pages/video/player/player.ux | 19 +- src/pages/video/videodetail/videodetail.less | 69 ----- src/pages/video/videodetail/videodetail.ux | 102 +------ src/savedcontent.ts | 3 +- src/settings.ts | 14 +- src/tools.ts | 2 - src/ui/ui.ts | 13 +- src/usertracker.ts | 4 +- 39 files changed, 85 insertions(+), 738 deletions(-) delete mode 100644 .husky/commit-msg delete mode 100644 .husky/pre-commit delete mode 100644 .mimocode/plans/1783084400288-jolly-rocket.md delete mode 100644 AGENTS.md delete mode 100644 eslint.config.mjs diff --git a/.gitignore b/.gitignore index 20d0c33..0178a0d 100644 --- a/.gitignore +++ b/.gitignore @@ -4,7 +4,7 @@ /sign /dist /build -# .husky/ — hooks are tracked in version control +.husky/ */__pycache__ src/buildinfo.ts **/.DS_Store \ No newline at end of file diff --git a/.husky/commit-msg b/.husky/commit-msg deleted file mode 100644 index 0a4b97d..0000000 --- a/.husky/commit-msg +++ /dev/null @@ -1 +0,0 @@ -npx --no -- commitlint --edit $1 diff --git a/.husky/pre-commit b/.husky/pre-commit deleted file mode 100644 index 2312dc5..0000000 --- a/.husky/pre-commit +++ /dev/null @@ -1 +0,0 @@ -npx lint-staged diff --git a/.mimocode/plans/1783084400288-jolly-rocket.md b/.mimocode/plans/1783084400288-jolly-rocket.md deleted file mode 100644 index 4cf8cc8..0000000 --- a/.mimocode/plans/1783084400288-jolly-rocket.md +++ /dev/null @@ -1,252 +0,0 @@ -# 代码修复计划 — Bug、风险与性能问题 - -## 修复优先级总览 - -| 阶段 | 问题数 | 描述 | -|------|--------|------| -| P0 紧急 | 8 | 功能完全不可用、崩溃、安全漏洞 | -| P1 高 | 8 | 数据损坏、启动失败、CI 失效 | -| P2 中 | 14 | 功能异常、性能退化、潜在隐患 | -| P3 低 | 11 | 代码质量、工具链现代化 | - ---- - -## P0 紧急修复(功能不可用/崩溃) - -### 1. 回复功能 — API 调用交换 + 未声明变量 -**文件**: `src/pages/reply/replys/replys.ux` -- **L64-77**: `GiveTreeReply` 和 `GiveSecReply` 调用语义反了,交换调用 -- **L97**: `this.input_text` 未声明,在 `private` data 中添加 `input_text: { content: "" }` - -### 2. 音乐播放 — `api` 未定义 -**文件**: `src/pages/video/player/player.ux` -- **L782,822,1261,1461,1495**: `api.getSongUrl()` / `api.getLyric()` 调用但 `api` 未导入 -- 需要创建 `src/bilibiliclient/music/music.ts` 模块(或找到正确的 API 来源),在文件顶部导入并赋值给 `api` - -### 3. 动态详情 — `typeof` 比较恒为 true -**文件**: `src/pages/app/features/dynamic/detail/detail.ux` -- **L87**: `typeof this.dyn != Object` → `typeof this.dyn !== "object"` - -### 4. 空回复检查 — 字符串与数字比较 -**文件**: `src/pages/video/videodetail/videodetail.ux` -- **L202**: `evt.detail.content === 0` → `!evt.detail.content || evt.detail.content.length === 0` - -### 5. Settings JSON.parse 崩溃 -**文件**: `src/settings.ts` -- **L37**: 用 try-catch 包裹 `JSON.parse(data)`,catch 中保持默认 SETTINGS 并 log 警告 - -### 6. App 启动 Promise 无错误处理 -**文件**: `src/app.ux` -- **L44-50**: 用 try-catch 包裹每个 await,或用 `Promise.allSettled` 并行执行非关键初始化 -- 关键初始化(`savedcontent.initialize`)失败应显示错误页面 -- 非关键初始化(`getNetworkType`)失败可降级为默认值 - -### 7. HTTP 追踪 URL(调试遗留) -**文件**: `src/usertracker.ts` -- **L5**: 取消注释 L4 的 HTTPS URL,删除或注释 L5 的 HTTP 内网地址 - -### 8. asyncapi `access()` 语义错误 -**文件**: `src/asyncapi/file.ts` -- **L161**: `fail` 回调中 `reject(...)` → `resolve(false)`,使调用方能用布尔值判断文件是否存在 - ---- - -## P1 高优先级修复 - -### 9. API 响应空检查链 -**文件**: `src/bilibiliclient/api/request.ts` -- **L60, L91**: `return response.data` 前增加对 `response` 和 `response.data` 的 null 检查 -- 创建 `safeData(response)` 辅助函数,统一处理 `response.data.code !== 0` 的错误情况 -- 在所有 bilibiliclient 子模块中使用此辅助函数 - -### 10. 文章图片空引用 -**文件**: `src/articletools.ts` -- **L39**: 在访问 `dom.attributes.src` 前增加 `dom.attributes && dom.attributes.src` 检查 -- **L49**: 第二个 `parseInt(dom.attributes.height)` → `parseInt(dom.attributes.width)` - -### 11. 页面返回键崩溃 -**文件**: `src/ui/ui.ts` -- **L55**: 增加 `pageStack.length >= 2` 判断,不足时跳过返回动画 -- **L57-58**: 增加 `global.vmPool[lastPageName]` 存在性检查 - -### 12. VmPool GC 逻辑错误 -**文件**: `src/ui/ui.ts` -- **L21**: `return` → `continue` - -### 13. 构建脚本不传播失败 -**文件**: `scripts/build_s3s4.py`, `scripts/build_rw5.py` -- **L8**: `os.system("yarn run build")` → `subprocess.run(["yarn", "run", "build"], check=True)` -- 同时更新 import 语句添加 `subprocess` - -### 14. buildtools.py 异常吞掉 -**文件**: `scripts/buildtools.py` -- **L18**: `Exception(...)` → `raise Exception(...)` -- **L27-31**: 用 `with open(...) as f:` 替换裸 `open()` - -### 15. ESLint 配置缺失 -**文件**: 新建 `eslint.config.mjs` -- 创建 ESLint flat config 文件,兼容 ESLint 9 -- 或将 `package.json` 中 ESLint 降级到 `^8.x` 并保留旧 `.eslintrc` - -### 16. Husky hooks 未版本控制 + API 过时 -**文件**: `.gitignore`, `husky.sh` -- 从 `.gitignore` 中删除 `.husky/` 行 -- 用 Husky v9 API 重写 `husky.sh`(`husky init` + 直接写 `.husky/pre-commit` 和 `.husky/commit-msg` 脚本) - ---- - -## P2 中优先级修复 - -### 17. bvid 默认值类型错误 -**文件**: `src/pages/video/videodetail/videodetail.ux` -- **L84**: `bvid: 1` → `bvid: ""` - -### 18. 数组初始化为对象 -**文件**: `src/pages/user/user.ux` L53, `src/pages/search/search/search.ux` L32 -- `masterpiece: {}` → `masterpiece: []` -- `hotwords: {}` → `hotwords: []` - -### 19. 音频事件处理被覆盖 -**文件**: `src/pages/video/player/player.ux` -- **L404-407**: 删除 `onInit` 中重复的 `audio.ontimeupdate` 赋值,或合并逻辑到 `bindAudioEvents` - -### 20. fetchDefaultPlaylist 空函数 -**文件**: `src/pages/video/player/player.ux` -- **L665-668**: 实现函数体或标记为 TODO 并添加用户提示 - -### 21. Settings 加载竞态 -**文件**: `src/settings.ts` -- 重构 `loadSettings` 返回 `Promise`,在 `app.ux` 中 `await` 完成后再继续初始化 - -### 22. HTML 解析器嵌套标签问题 -**文件**: `src/htmlparser.ts` -- **L38**: 对于嵌套标签,改用递归下降解析而非单正则匹配 -- 或引入轻量 HTML 解析库 - -### 23. 收藏夹名称硬编码 -**文件**: `src/bilibiliclient/video/action.ts` L23, L47 -- 改用 `folder.id === 0`(B站默认收藏夹 ID 固定为 0)或通过 API 响应中的 `default` 字段判断 - -### 24. 存储索引无验证 -**文件**: `src/savedcontent.ts` -- **L38**: JSON.parse 后增加 `Array.isArray()` 检查和元素结构验证 - -### 25. 日志无缓冲 -**文件**: `src/logger/logger.ts` -- 实现内存缓冲区,批量写入(如每 10 条或每 5 秒 flush 一次) -- 添加日志文件轮转机制(保留最近 N 个文件) - -### 26. VmPool GC 定时器优化 -**文件**: `src/ui/ui.ts` -- 在页面销毁事件中触发 GC,替代 10 秒定时器 - -### 27. 动画引用泄漏 -**文件**: `src/animation/engine.ts` -- 在 `SequenceAnim.stop()` 和 `DomAnim.stop()` 中从 `global.animations` 移除自身引用 - -### 28. request.ts 无超时 -**文件**: `src/bilibiliclient/api/request.ts` -- `getRequest` 和 `postRequest` 增加 `timeout` 参数(默认 15s),传入 `fetch.fetch()` - -### 29. Content-Length 冗余设置 -**文件**: `src/bilibiliclient/message/message.ts` -- **L51**: 删除手动 `Content-Length` 设置,让 HTTP 客户端自动处理 - -### 30. Stylelint 废弃规则 -**文件**: `.stylelintrc.js` -- **L10-11**: 删除 `color-hex-case` 和 `color-hex-length`,或安装 `stylelint-stylistic` 插件 - ---- - -## P3 低优先级改进 - -### 31. formatNumber 边界处理 -**文件**: `src/tools.ts` L3-13 — 增加 `NaN`/负数/undefined 守卫 - -### 32. funnytips 日期捕获时机 -**文件**: `src/funnytips.ts` L1 — `new Date()` 移入 `getTips()` 函数内部 - -### 33. jumpcheck storage 无 fail 回调 -**文件**: `src/jumpcheck.ts` — 增加 `fail` 回调,导航到错误页面 - -### 34. Object.assign 原型组装 -**文件**: `src/bilibiliclient/client.ts` L55-68 — 长期重构为 class extends 或 mixin 模式(影响范围大,建议单独 PR) - -### 35. quickapp.config.js 健壮性 -**文件**: `quickapp.config.js` -- L7: `execSync` 包裹 try-catch -- L10: 相对路径 → `path.resolve(__dirname, ...)` -- L12-17: 模板字符串值转义引号和反斜杠 - -### 36. manifest.json 生产日志级别 -**文件**: `src/manifest.json` L53 — `"log"` → `"warn"`(或在构建脚本中覆盖) - -### 37. .prettierrc.js 废弃选项 -**文件**: `.prettierrc.js` L10 — `jsxBracketSameLine` → `bracketSameLine` - -### 38. buildInfoContent 注入风险 -**文件**: `quickapp.config.js` L12-17 — 对插值值做 JSON.stringify 转义 - -### 39. PII 泄漏 -**文件**: `quickapp.config.js` L8 — 移除 `os.userInfo().username`,改用 CI 环境变量或固定标识 - -### 40. logger %c 样式无效 -**文件**: `src/logger/logger.ts` L61 — 移除 `%c` 和 style 参数 - -### 41. eula.ts 嵌套 `

` 标签 -**文件**: `src/eula.ts` — 修正 HTML 结构,外层 `

` 改为 `

` - ---- - -## 实施建议 - -### 分批策略 -1. **第 1 批 (P0)**: 8 个修复,每个独立可测,建议逐个 PR -2. **第 2 批 (P1)**: 8 个修复,工具链相关可合并为一个 PR -3. **第 3 批 (P2)**: 14 个修复,按模块分组(player 模块、bilibiliclient 模块、基础设施) -4. **第 4 批 (P3)**: 11 个改进,可在后续迭代中逐步完成 - -### 验证方式 -- 每个修复在 NuttX 设备或模拟器上手动验证对应功能 -- 构建脚本修复:运行 `python scripts/build_s3s4.py` 和 `python scripts/build_rw5.py` 确认退出码 -- 工具链修复:运行 `yarn lint` 确认 ESLint 正常工作 -- CI 修复:推送到 `next-gen` 分支确认 GitHub Actions 流水线绿色 - -### 关键文件清单 -| 文件 | 修改类型 | -|------|---------| -| `src/pages/reply/replys/replys.ux` | Bug 修复 | -| `src/pages/video/player/player.ux` | Bug 修复 + 功能实现 | -| `src/pages/app/features/dynamic/detail/detail.ux` | Bug 修复 | -| `src/pages/video/videodetail/videodetail.ux` | Bug 修复 | -| `src/settings.ts` | 健壮性修复 | -| `src/app.ux` | 错误处理 | -| `src/usertracker.ts` | 安全修复 | -| `src/asyncapi/file.ts` | 语义修复 | -| `src/bilibiliclient/api/request.ts` | 健壮性修复 | -| `src/articletools.ts` | Bug 修复 | -| `src/ui/ui.ts` | Bug 修复 + 性能 | -| `src/tools.ts` | 边界处理 | -| `src/htmlparser.ts` | Bug 修复 | -| `src/logger/logger.ts` | 性能优化 | -| `src/savedcontent.ts` | 健壮性修复 | -| `src/animation/engine.ts` | 内存泄漏修复 | -| `src/funnytips.ts` | Bug 修复 | -| `src/jumpcheck.ts` | 健壮性修复 | -| `src/bilibiliclient/video/action.ts` | 兼容性修复 | -| `src/bilibiliclient/message/message.ts` | 代码清理 | -| `scripts/build_s3s4.py` | CI 修复 | -| `scripts/build_rw5.py` | CI 修复 | -| `scripts/buildtools.py` | Bug 修复 | -| `quickapp.config.js` | 健壮性 + 安全 | -| `package.json` | 依赖更新 | -| `.prettierrc.js` | 配置更新 | -| `.stylelintrc.js` | 配置更新 | -| `husky.sh` | 重写 | -| `.gitignore` | 配置修复 | -| `.github/workflows/main.yml` | CI 修复 | -| `eslint.config.mjs` | 新建 | -| `src/pages/user/user.ux` | Bug 修复 | -| `src/pages/search/search/search.ux` | Bug 修复 | -| `src/eula.ts` | HTML 修正 | -| `src/manifest.json` | 配置调整 | diff --git a/.prettierrc.js b/.prettierrc.js index 1e78db8..f26c316 100644 --- a/.prettierrc.js +++ b/.prettierrc.js @@ -7,7 +7,7 @@ module.exports = { quoteProps: "consistent", // 要求对象字面量属性是否使用引号包裹,(‘as-needed’: 没有特殊要求,禁止使用,'consistent': 保持一致 , preserve: 不限制,想用就用) trailingComma: "none", // 不添加对象和数组最后一个元素的逗号 bracketSpacing: false, // 对象中对空格和空行进行处理 - bracketSameLine: false, // 在多行JSX元素的最后一行追加 > + jsxBracketSameLine: false, // 在多行JSX元素的最后一行追加 > requirePragma: false, // 是否严格按照文件顶部的特殊注释格式化代码 insertPragma: false, // 是否在格式化的文件顶部插入Pragma标记,以表明该文件被prettier格式化过了 proseWrap: "preserve", // 按照文件原样折行 diff --git a/.stylelintrc.js b/.stylelintrc.js index 4eda223..5d9de7a 100644 --- a/.stylelintrc.js +++ b/.stylelintrc.js @@ -7,6 +7,8 @@ module.exports = { ignoreFiles: ["node_modules", "test", "dist", "**/*.js"], rules: { "no-descending-specificity": null, + "color-hex-case": "lower", + "color-hex-length": "short", "at-rule-no-unknown": null, "block-no-empty": null, "selector-pseudo-class-no-unknown": [ diff --git a/AGENTS.md b/AGENTS.md deleted file mode 100644 index 081c68a..0000000 --- a/AGENTS.md +++ /dev/null @@ -1,67 +0,0 @@ -# AGENTS.md - -## Project Overview - -Third-party Bilibili client for Xiaomi Vela embedded watches, built with the **QuickApp** framework (快应用). Targets round watches (S3/S4 at 466px, RW5 at 432px design width). - -## Key Commands - -```bash -yarn # install deps (NEVER use npm — postinstall enforces this) -yarn start # dev server with watch + NuttX device -yarn build # production build (outputs dist/*.rpk) -yarn lint # eslint --fix on src/**/*.{ux,js} -python scripts/build_s3s4.py # build for S3/S4 watches (466px design width) -python scripts/build_rw5.py # build for RW5 watches (432px design width) -``` - -Build scripts mutate `src/manifest.json` `config.designWidth` before calling `yarn build`. The CI runs both sequentially. - -## Architecture - -**Framework**: QuickApp (小米快应用) — NOT Vue, React, or standard web. Uses `.ux` single-file components with `