✨ feat: 新增本地缓存功能 by imsyy · Pull Request #640 · imsyy/SPlayer

Summary of Changes

Hello @imsyy, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed!

此拉取请求的核心目标是为应用程序引入全面的本地缓存功能,以优化音乐播放和本地文件管理的性能和用户体验。通过将缓存逻辑抽象为独立的Electron服务,并将其集成到播放器和歌词管理中,显著减少了对网络资源的依赖,并提高了本地音乐库扫描的效率。此外,还扩展了本地音乐的浏览方式,新增了按文件夹分类的视图。

Highlights

  • 本地缓存服务: 引入了全新的 CacheServiceMusicCacheService,用于集中管理音乐和歌词的本地缓存。这包括缓存文件的写入、读取、删除、清空以及总大小计算,并支持根据大小限制自动清理旧缓存。
  • 本地音乐库扫描优化: 重构了本地音乐扫描逻辑,现在使用 LocalMusicService 进行管理,支持并发限制 (p-limit)、封面提取 (sharp),并在扫描过程中通过 IPC 流式传输进度和批量歌曲数据,显著提升了用户体验和性能。
  • 播放器缓存集成: 播放器现在会优先检查本地音乐缓存,减少网络请求。在线歌曲和解锁歌曲的 URL 都会尝试缓存到本地,并在网络请求失败时作为兜底方案。
  • 歌词缓存: 歌词管理模块现在支持缓存原始的在线歌词数据(LRC 和 TTML 格式),避免重复下载,加快歌词加载速度。
  • 新增本地音乐文件夹视图: 在本地音乐页面新增了按文件夹分类的视图,方便用户按目录浏览和管理本地歌曲。
  • 设置项与用户体验改进: 新增了缓存大小限制设置,并优化了播放器进度条悬浮提示的显示逻辑。同时,本地音乐路径管理更加灵活,移除了默认音乐路径的特殊处理。
Using Gemini Code Assist

The full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips.

Invoking Gemini

You can request assistance from Gemini at any point by creating a comment using either /gemini <command> or @gemini-code-assist <command>. Below is a summary of the supported commands on the current page.

Feature Command Description
Code Review /gemini review Performs a code review for the current pull request in its current state.
Pull Request Summary /gemini summary Provides a summary of the current pull request in its current state.
Comment @gemini-code-assist Responds in comments when explicitly tagged, both in pull request comments and review comments.
Help /gemini help Displays a list of available commands.

Customization

To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a .gemini/ folder in the base of the repository. Detailed instructions can be found here.

Limitations & Feedback

Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for Github and other Google products, sign up here.

You can also get AI-powered code generation, chat, as well as code reviews directly in the IDE at no cost with the Gemini Code Assist IDE Extension.

  1. Review the Privacy Notices, Generative AI Prohibited Use Policy, Terms of Service, and learn how to configure Gemini Code Assist in GitHub here. Gemini can make mistakes, so double check it and use code with caution.