Skip to content

代码审计修复:安全加固、超时统一、请求取消保护、歌词同步等多项优化#1

Merged
yingxiaomo merged 4 commits into
mainfrom
dev
Jul 4, 2026
Merged

代码审计修复:安全加固、超时统一、请求取消保护、歌词同步等多项优化#1
yingxiaomo merged 4 commits into
mainfrom
dev

Conversation

@yingxiaomo

Copy link
Copy Markdown
Owner

变更摘要

三轮代码审计后的修复与优化,涵盖安全性、健壮性、代码一致性等多个维度。

安全加固

  • 社交链接添加 rel="noopener noreferrer" 防止窗口劫持
  • 移除 unused Color Thief CDN 引用,消除供应链攻击风险
  • Footer 中 busuanzi 脚本移除 referrerPolicy='unsafe-url',防止 URL 泄漏

请求保护与超时统一

  • useHitokoto.js / MusicPlayer.vue parseLrc 添加 AbortController 请求取消保护
  • useWeather.js 统一 6 处 API 调用为 fetchWithTimeout 公共函数
  • 背景图加载超时兜底 timer 正确保存引用并在 handleLoad/handleError/onBeforeUnmount 中清理

歌词同步修复

  • 修复 store.playerLrc 歌词数据从未写入 Footer 的问题
  • APlayer timeupdate 事件兼容数字和 DOM Event 两种传参

代码质量

  • 提取问候逻辑为 composables/useGreeting.js,与组件解耦
  • useTime.js 改用 dayjs locale 替代手工维护的星期数组
  • api/music.js 添加响应类型检查与字段兜底
  • MusicPlayer 添加 Enter 键无障碍支持
  • 修复 Background.vue handleError 中 API 回退路径缺少超时兜底的回归
  • 补充:Vore.top handler 添加 data.ip 作为 IP 字段回退

工程化

  • 添加缺失的 apple-touch-icon.png
  • 新增 .gitattributes 统一行尾风格(text=auto eol=lf)
  • nginx.conf 添加 charset utf-8 配置

测试

  • 本地 npm run dev 正常启动
  • 构建 npm run build 通过

- 移除 package.json 和 vite.config.js 中的 UTF-8 BOM,解决 Vite 8 PostCSS JSON.parse 崩溃
- 更新 engines.node 为 ^20.19.0 || >=22.12.0 以满足 Vite 8/rolldown 要求
- 更新 .node-version 为 20.19
- 在 Linux 环境重新生成 package-lock.json,确保 rolldown Linux native binding 正确安装
- 修复:store.playerLrc 歌词数据从未写入 Footer,导致歌词显示完全失效
- 安全:社交链接添加 rel="noopener noreferrer" 防止窗口劫持
- 安全:移除未使用的 Color Thief CDN 引用,消除供应链攻击风险
- 优化:useWeather.js 统一 fetchWithTimeout 超时逻辑
- 优化:useHitokoto.js 添加 AbortController 请求取消保护
- 优化:api/music.js 添加响应类型检查与兜底
- 优化:移除 App.vue 中 font-preload-helper hack,改用标准 link preload
- 优化:useTime.js 改用 dayjs locale 替代手工维护的星期数组
- 优化:提取问候逻辑为 composables/useGreeting.js,与组件解耦
- 优化:nginx.conf 添加 charset utf-8 配置
- 优化:MusicPlayer 添加 Enter 键无障碍支持
- 清理:移除 Teleport 中重复的 footer-lyric-bar(与 Footer.vue 冲突)
- 清理:补全多处空 catch 块中的日志输出
- 修复:Background.vue handleError 中 API 回退路径缺少超时兜底
- 修复:MusicPlayer.vue parseLrc fetch 添加 AbortController 请求取消保护
- 修复:Footer.vue 移除 unsafe-url referrerPolicy,防止 URL 泄漏
- 优化:useWeather.js getLocationByFreeApi 统一使用 fetchWithTimeout
- 优化:用 loadTimeout 引用替换裸 setTimeout,在 handleLoad/handleError/onBeforeUnmount 中正确清理
- 优化:Vore.top handler 添加 data.ip 作为 IP 字段回退
- 修复:添加缺失的 apple-touch-icon.png
- 新增:.gitattributes 统一行尾风格(text=auto eol=lf)
@vercel

vercel Bot commented Jul 4, 2026

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated (UTC)
home Error Error Jul 4, 2026 1:56pm

@yingxiaomo yingxiaomo merged commit 958d698 into main Jul 4, 2026
1 of 4 checks passed
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