Skip to content

chore: Bundle A+B (去重 + 工具链升级 + CI 硬门禁 + 配置卫生)#60

Merged
wnzzer merged 2 commits into
mainfrom
chore/toolchain-upgrade-and-ci-hardening
May 16, 2026
Merged

chore: Bundle A+B (去重 + 工具链升级 + CI 硬门禁 + 配置卫生)#60
wnzzer merged 2 commits into
mainfrom
chore/toolchain-upgrade-and-ci-hardening

Conversation

@wnzzer
Copy link
Copy Markdown
Owner

@wnzzer wnzzer commented May 13, 2026

Summary

整体 review 的 Bundle A + B 合并 PR。已 rebase 到当前 main(包含已合并的 #58 / #61,原 PR #59 内容并入此 PR,#59 将被关闭。

Bundle A — 去重 + 修小漏洞(commit 0bdb2b5

  • isDark ×4 → useTheme():App.vue / PlayerCard.vue / MatchDetailModal.vue / RecordCard.vue 各自复制了一份 computed(() => theme.name === 'Dark'|'dark'),统一调用 composables/useTheme.ts(已被 useTheme.spec.ts 覆盖)。
  • augmentRarityClass 去重:RecordCard.vue 私有版本删除,统一调 utils/augment.ts 的通用版(与 MatchDetailModal 对齐)。
  • pinia/setting.ts:经 rebase 到 main,已与 refactor: 统一 config IPC 格式为 { value: T } 包装 #61 的 helper 改造对齐,原 refactor: 去重 + 修小漏洞集合 (Bundle A) #59 中的"bug fix"在 refactor: 统一 config IPC 格式为 { value: T } 包装 #61 已实现,此处仅保留 import 和调用形式。
  • Automation.vue:删除调试遗漏的 console.log('addPickData', value)
  • MatchHistory.vue:两个 onMounted 合并;模块级 let name = ''computed(() => route.query.name),避免路由变更未重渲染时拿到过期值;championOption 导入路径从 deprecated '../type' 改成 canonical @renderer/types/domain/champion
  • useSessionSync:retry 路径的 setTimeout 引入 trackedSetTimeout + pendingTimers Set,onUnmountedclearTimeout 所有未触发的 timer,避免组件卸载后写已销毁响应式状态。
  • token.rs:auth_resolver:内联 Regex::new(...) 抽到 static AUTH_REGEX: LazyLock<Regex>,LCU 认证重试时不再重复编译。

Bundle B — 工具链 + CI + 配置卫生(commit feaf554

依赖升级(移除 GHSA)

  • env_logger 0.9 → 0.11:间接依赖 atty 0.2.14GHSA-g98v-hv3f-hcfr (Windows unsound),0.11 完全移除。Cargo.lock 同步:atty / hermit-abi 0.1 / humantime / termcolor 全部摘除,新加 jiff 系作为时间格式化后端。main.rs 里的 buf.timestamp_millis() API 不变。
  • @tauri-apps/plugin-opener "^2.0.0-alpha.3" → "^2":之前一直锁在 alpha,永远不会升 stable 2.x。

CI 硬门禁

  • 之前 vitest.config.ts 写了 80% threshold 但 CI 跑 npm run test(不带 --coverage),threshold 形同虚设。
  • 本 PR:CI 切 npm run test:coverage,threshold 真正生效。
  • threshold 调到当前 floor(lines/statements 15、functions 45、branches 73)。当前实际覆盖率 16.47% / 46.7% / 74.83% / 16.47%,threshold 略低于 floor 留 1-2% 抖动空间。这是无回归基线,不是达成目标 —— CLAUDE.md 中 80% 仍为长期目标,靠后续 PR 增加测试逐步抬升。

配置卫生

  • tsconfig.json:删 @components/@utils path alias(grep 整个 src 0 hits,dead config)。
  • .eslintrc.cjs:启用 @typescript-eslint/no-explicit-any: warn。CODE_QUALITY.md 早就禁 any 但没规则化。当前 91 处 warning,warn 级别不阻塞 CI,留作后续逐文件治理。
  • tauri.conf.json:删 dangerousInsecureTransportProtocol: true。两条 updater endpoint 都已 https://,flag 当前没有实际明文流量,但留着等于给未来挖坑。
  • 新建 lol-record-analysis-tauri/.gitignore:仓库之前没这个文件(只有 src-tauri/.gitignore),dist/coverage/ 都不在任何 ignore 范围。启用 coverage 生成后必须 ignore。

Rebase 备注

#59 / #60 都基于 #58 之前的 main,与已合并的 #58 (token.rs AtomicU32 + markdown-it html:false) 和 #61 (config IPC 包装) 有冲突。本次 rebase 后:

Test plan

  • npm run check ✓ 0 errors / 91 no-explicit-any warnings(预期)
  • npm run test ✓ 12/12 suites pass,219 tests pass
  • CI Windows-latest 跑通 cargo clippy(验证 env_logger 0.11 + timestamp_millis() 在 0.11 仍存在)
  • CI ubuntu-latest 跑通 test:coverage gate
  • CI security-audit job 跑 cargo audit 后 atty GHSA 告警消失
  • npm run tauri dev 启动正常(plugin-opener 升级不影响 IPC;主题切换 / 战绩场数 / Automation 开关 / Pick-Ban 规则 / UserRecord 模式持久化均正常)

Copilot AI review requested due to automatic review settings May 13, 2026 13:06
Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

该 PR 主要聚焦于工具链/依赖升级、CI 质量门禁落地(Vitest 覆盖率阈值在 CI 强制执行)、以及一些配置与前端代码的卫生/复用改造(如主题判断与 augment 稀有度样式抽离),整体不涉及业务逻辑变更。

Changes:

  • 前端:Vitest 覆盖率阈值下调到当前基线并在 CI 中改跑 test:coverage;清理无用 TS path alias;新增子项目 .gitignore;ESLint 开启 no-explicit-any(warn)。
  • 前端:主题暗色判断统一改用 useTheme();augment 稀有度样式 class 逻辑抽到 utils/augment;修复/规避卸载后定时器回调写响应式状态(tracked timers)。
  • Rust/Tauri:升级 env_logger 到 0.11;移除 tauri.conf.json 的不安全传输配置;Windows token 解析正则改为静态编译以减少重复开销。

Reviewed changes

Copilot reviewed 17 out of 19 changed files in this pull request and generated 1 comment.

Show a summary per file
File Description
lol-record-analysis-tauri/vitest.config.ts 调整覆盖率阈值为基线并补充说明注释
lol-record-analysis-tauri/tsconfig.json 移除未使用的 path alias 配置
lol-record-analysis-tauri/src/views/settings/Automation.vue 移除调试 console.log
lol-record-analysis-tauri/src/pinia/setting.ts 主题读写从直调 invoke 改为走 IPC service 封装
lol-record-analysis-tauri/src/composables/useSessionSync.ts 引入 tracked setTimeout,卸载时清理 pending timers
lol-record-analysis-tauri/src/components/record/RecordCard.vue 主题判断改用 useTheme;augment 稀有度 class 复用工具函数
lol-record-analysis-tauri/src/components/record/MatchHistory.vue route.query.name 改为 computed;分页/筛选调用统一使用 name.value
lol-record-analysis-tauri/src/components/record/MatchDetailModal.vue 主题判断改用 useTheme(并复用 augment 稀有度 class 工具)
lol-record-analysis-tauri/src/components/gaming/PlayerCard.vue 主题判断改用 useTheme
lol-record-analysis-tauri/src/App.vue 主题判断改用 useTheme
lol-record-analysis-tauri/src-tauri/tauri.conf.json 移除 dangerousInsecureTransportProtocol 配置
lol-record-analysis-tauri/src-tauri/src/lcu/util/token.rs Regex::new 改为 LazyLock 静态缓存,避免重复编译
lol-record-analysis-tauri/src-tauri/Cargo.toml env_logger 升级到 0.11
lol-record-analysis-tauri/src-tauri/Cargo.lock 锁文件随依赖升级更新(移除 atty 等,引入 jiff/anstream 等)
lol-record-analysis-tauri/package.json @tauri-apps/plugin-opener 从 alpha 升级到 ^2
lol-record-analysis-tauri/package-lock.json 同步 opener 版本变更
lol-record-analysis-tauri/.gitignore 新增 dist/coverage 等忽略项(子项目级)
lol-record-analysis-tauri/.eslintrc.cjs 启用 @typescript-eslint/no-explicit-any: warn
.github/workflows/quality-checks.yml 前端 CI 改跑 npm run test:coverage 以强制覆盖率阈值
Files not reviewed (1)
  • lol-record-analysis-tauri/package-lock.json: Language not supported
Comments suppressed due to low confidence (1)

lol-record-analysis-tauri/src/components/record/MatchHistory.vue:93

  • 这里仍从 ../type 导入 championOption,但该文件已标注为 @deprecated(建议改为从 @renderer/types/domain/champion 导入)。既然本次已改动该文件的 imports/逻辑,建议顺手替换掉以避免继续传播弃用入口。
import { computed, onMounted, provide, ref, watch } from 'vue'
import { useLoadingBar } from 'naive-ui'
import { useRoute } from 'vue-router'
import { renderSingleSelectTag, renderLabel, filterChampionFunc } from '../composition'
import { modeOptions, initModeOptions } from './composition'
import { invoke } from '@tauri-apps/api/core'
import { championOption } from '../type'
import type { Game, MatchHistory } from './match'

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

async function initTheme() {
try {
const savedTheme = await invoke<string>('get_config', { key: 'theme' })
const savedTheme = await getConfigByIpc<string>('theme')
baifu.chen added 2 commits May 17, 2026 00:48
- isDark x4: App / PlayerCard / MatchDetailModal / RecordCard 改用 useTheme()
  composable,删除各自本地的 isDark computed 与不再用的 settingsStore 引用。
- RecordCard: augmentRarityClass 改调 utils/augment.ts 的通用版(与
  MatchDetailModal 对齐),删除本地副本。
- pinia/setting.ts: initTheme/toggleTheme 走 services/ipc.ts 的
  get/putConfigByIpc 封装。顺手修复 initTheme 之前用裸 invoke<string>
  接收 ConfigValue<string> 包装的隐藏 bug——之前 savedTheme 永远是
  { value: '...' } 对象,与字符串比较恒为 false,导致 light 模式启动后
  仍被回退为 dark。
- Automation.vue: 删调试遗漏的 console.log('addPickData', value)。
- MatchHistory.vue: 合并两个 onMounted;模块级 `let name = ''` 改为
  computed(() => route.query.name),消除路由变更不重渲染时的过期值风险。
- useSessionSync: setTimeout 改走 trackedSetTimeout,onUnmounted 中
  clearTimeout 所有未触发的 timer,避免组件卸载后写已销毁的响应式状态。
- token.rs: auth_resolver 的 Regex 抽到 static LazyLock,避免每次
  LCU 认证失败重试时重复编译正则。
依赖:
- env_logger 0.9 → 0.11:移除间接依赖 atty 0.2 (GHSA-g98v-hv3f-hcfr)。
  0.11 默认 features 仍含 humantime(由 jiff 实现),timestamp_millis()
  API 保持兼容。Cargo.lock 同步刷新。
- @tauri-apps/plugin-opener "^2.0.0-alpha.3" → "^2":从 alpha 锁出,
  跟随上游 stable 2.x。package-lock.json 同步刷新。

CI 硬门禁:
- quality-checks.yml: `npm run test` → `npm run test:coverage`。
  之前 vitest.config.ts 设了 80% threshold 但 CI 没跑 --coverage,
  导致 threshold 形同虚设。
- vitest.config.ts: threshold 调整为当前 floor (lines/statements 15、
  functions 45、branches 73) ——做"无回归基线",禁止 PR 把覆盖率推下来。
  CLAUDE.md 中 80% 仍为长期目标,靠后续添加测试逐步抬升。

配置卫生:
- tsconfig.json: 删除从未引用的 @components/@utils path alias
  (全代码库 grep 0 hits)。
- .eslintrc.cjs: 启用 @typescript-eslint/no-explicit-any 为 warn。
  CODE_QUALITY.md 早有"禁用 any"约定但未规则化。当前 91 处 warning,
  待后续按文件逐步治理后再升 error。
- tauri.conf.json: 删除 dangerousInsecureTransportProtocol。两条
  updater endpoint 都已是 https://,这个标志当前实际无明文流量,
  但留着等于给未来挖坑。
- lol-record-analysis-tauri/.gitignore: 新建(仓库缺失)。忽略 dist/、
  coverage/、IDE/OS 杂项。本 PR 启用 coverage 生成后必须 ignore,否则
  污染开发树。
@wnzzer wnzzer force-pushed the chore/toolchain-upgrade-and-ci-hardening branch from be198af to feaf554 Compare May 16, 2026 16:49
@wnzzer wnzzer changed the title chore: 工具链升级 + CI 硬门禁 + 配置卫生 (Bundle B) chore: Bundle A+B (去重 + 工具链升级 + CI 硬门禁 + 配置卫生) May 16, 2026
@wnzzer wnzzer merged commit a2b5a0e into main May 16, 2026
3 checks passed
@wnzzer wnzzer deleted the chore/toolchain-upgrade-and-ci-hardening branch May 25, 2026 07:41
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.

2 participants