Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(service): 🐛 增加浏览器指纹作为唯一值解决netty关联channel的问题 #171

Merged
merged 1 commit into from
Jan 9, 2025

Conversation

nongyehong
Copy link
Member

@nongyehong nongyehong commented Jan 9, 2025

💻 变更类型 | Change Type

  • ✨ feat | 新增功能
  • 🐛 fix | 修复缺陷
  • ♻️ refactor | 代码重构(不包括 bug 修复、功能新增)
  • 💄 style | 代码格式(不影响功能,例如空格、分号等格式修正)
  • 📦️ build | 构建流程、外部依赖变更(如升级 npm 包、修改 vite 配置等)
  • 🚀 perf | 性能优化
  • 📝 docs | 文档变更
  • 🧪 test | 添加疏漏测试或已有测试改动
  • ⚙️ ci | 修改 CI 配置、脚本
  • ↩️ revert | 回滚 commit
  • 🛠️ chore | 对构建过程或辅助工具和库的更改(不影响源文件、测试用例)

🔀 变更说明 | Description of Change

修复控制台退出和mac程序坞退出导致登录出错问题

📝 补充信息 | Additional Information

修复控制台退出和mac程序坞退出导致登录出错问题
@github-actions github-actions bot added 前端 关于前端的代码修改 依赖更新 labels Jan 9, 2025
Copy link

New and removed dependencies detected. Learn more about Socket for GitHub ↗︎

Package New capabilities Transitives Size Publisher

🚮 Removed packages: npm/[email protected], npm/[email protected], npm/[email protected], npm/[email protected], npm/[email protected], npm/[email protected]

View full report↗︎

Copy link

github-actions bot commented Jan 9, 2025

PR 代码分析

### 代码变更分析

1. useWindowState.ts 文件

  • 改动

    • 移除了处理 macOS 应用退出时清除 TOKEN 和请求头的操作。
    • 修改了窗口关闭事件的监听逻辑,仅在非正常关闭时触发。
  • 潜在问题或优化空间

    • 移除的代码原本用于解决 macOS 程序坞右键退出应用后重新启动时请求头保留 token 的问题。虽然注释中提到“还是会失败”,但移除该逻辑可能会导致类似问题再次出现。建议保留并优化这部分逻辑。
    • 可以考虑增加日志记录,便于调试和排查问题。

2. 新增 fingerprint.ts 文件

  • 改动

    • 新增了一个设备指纹生成服务,使用 FingerprintJS 和 Tauri 插件来获取跨平台设备信息,并结合浏览器特征生成唯一指纹。
    • 指纹缓存机制,避免频繁计算,提高性能。
  • 潜在问题或优化空间

    • 指纹生成逻辑较为复杂,建议对每个步骤进行详细的错误处理和日志记录,确保稳定性。
    • 缓存策略可以进一步优化,例如根据用户行为或特定条件更新缓存。
    • TypeScript 类型定义较为准确,但仍需确保所有异步操作都正确处理了 Promise 链。

3. http.ts 文件

  • 改动

    • 在 HTTP 请求中加入了设备指纹作为请求头的一部分。
    • 打印了请求头内容(console.log(...httpHeaders)),这可能会影响生产环境下的性能和安全性。
  • 潜在问题或优化空间

    • 打印请求头内容应仅用于开发和调试阶段,建议在生产环境中移除或有条件地启用。
    • 设备指纹的获取是异步操作,可能会增加请求延迟,建议评估其对性能的影响。
    • 确保 getEnhancedFingerprint 的返回值类型与 X-Device-Fingerprint 头部的要求一致。

4. Login.vue 文件

  • 改动

    • 增加了 onBeforeMount 生命周期钩子,在非自动登录且当前路径为 /login 时清除 TOKEN 并重置 WebSocket 连接。
    • 移除了部分注释掉的代码,简化了登录后的用户状态更新逻辑。
  • 潜在问题或优化空间

    • 清除 TOKEN 和重置 WebSocket 连接的逻辑放在 onBeforeMount 中,可能会导致页面加载时的短暂延迟,建议评估其影响。
    • 注释掉的代码可以考虑重构或删除,保持代码整洁。
    • Vue 组件的性能影响较小,主要是关注生命周期钩子的调用时机和频率。

总结

本次代码变更加入了设备指纹生成功能,并对其进行了缓存优化,同时调整了 HTTP 请求和登录逻辑。需要注意的是,移除的部分逻辑可能会导致某些场景下的问题重现,建议在后续版本中继续优化和测试。此外,打印请求头内容应谨慎处理,确保不会影响生产环境的安全性和性能。

*这是由通义千问 AI 自动生成的 PR 分析,仅供参考。*

Copy link

codecov bot commented Jan 9, 2025

Codecov Report

Attention: Patch coverage is 4.50450% with 106 lines in your changes missing coverage. Please review.

Files with missing lines Patch % Lines
src/services/fingerprint.ts 4.34% 88 Missing ⚠️
src/views/loginWindow/Login.vue 0.00% 13 Missing ⚠️
src/services/http.ts 16.66% 5 Missing ⚠️
Files with missing lines Coverage Δ
src/hooks/useWindowState.ts 0.00% <ø> (ø)
src/services/http.ts 5.45% <16.66%> (+1.37%) ⬆️
src/views/loginWindow/Login.vue 0.00% <0.00%> (ø)
src/services/fingerprint.ts 4.34% <4.34%> (ø)

... and 1 file with indirect coverage changes

@nongyehong nongyehong linked an issue Jan 9, 2025 that may be closed by this pull request
@nongyehong nongyehong merged commit a5b5f89 into master Jan 9, 2025
13 of 14 checks passed
@nongyehong nongyehong deleted the fix/fingerprint branch January 9, 2025 10:40
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
依赖更新 前端 关于前端的代码修改
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[bug] 控制台退出和mac程序坞退出导致第二次登录出错
1 participant