feat: 支持连接 Last.fm(记录播放、正在播放、喜欢同步)#25
Merged
Merged
Conversation
Contributor
There was a problem hiding this comment.
Pull request overview
本 PR 为 SPlayer-Next 增加 Last.fm 集成能力,打通「连接账号 → 上报正在播放 → 达标后 scrobble → 喜欢/取消喜欢同步」的完整链路,并在设置页提供开关与账号面板,整体覆盖渲染进程、preload 与主进程服务/IPC。
Changes:
- 新增设置项与设置页 Last.fm 连接面板(开关、scrobble/now playing/loveSync)。
- 新增 preload API 与主进程 IPC/服务实现:授权轮询、凭证持久化、now playing 与 scrobble 状态机、love/unlove 同步。
- 在播放事件与收藏入口处接入 Last.fm(播放状态/进度驱动 scrobbler、红心触发 loveSync)。
Reviewed changes
Copilot reviewed 19 out of 22 changed files in this pull request and generated 5 comments.
Show a summary per file
| File | Description |
|---|---|
| src/settings/categories/services.ts | 新增 Last.fm 设置分区与相关开关/面板挂载 |
| src/i18n/locales/zh-CN.json | 新增 Last.fm 设置文案(中文) |
| src/i18n/locales/en-US.json | 新增 Last.fm 设置文案(英文) |
| src/composables/useFavorite.ts | 收藏切换时触发 love/unlove 同步 |
| src/components/settings/custom/LastfmPanel.vue | 新增 Last.fm 账号连接/断开 UI 与交互 |
| shared/types/settings.ts | 增加 LastfmSettings,并接入 SystemConfig |
| shared/types/lastfm.ts | 定义 window.api.lastfm 类型、连接状态与结果类型 |
| shared/defaults/settings.ts | 增加 lastfm 默认配置 |
| electron/preload/index.ts | 暴露 window.api.lastfm(connect/cancel/disconnect/status/love) |
| electron/preload/index.d.ts | 声明 window.api.lastfm 类型 |
| electron/main/utils/logger.ts | 增加 lastfmLog scoped logger |
| electron/main/services/lastfm/scrobbler.ts | 新增 scrobble/now playing 触发状态机 |
| electron/main/services/lastfm/index.ts | Last.fm 主服务:授权、会话管理、回调接线、loveSync |
| electron/main/services/lastfm/credentials.ts | 会话凭证加解密与本地持久化 |
| electron/main/services/lastfm/client.ts | Last.fm API 签名与请求封装 |
| electron/main/ipc/player.ts | 播放事件接入 lastfm:onTrackLoaded/onState/onPosition/onEnded |
| electron/main/ipc/lastfm.ts | 新增 lastfm:* IPC handlers |
| electron/main/ipc/index.ts | 注册 Last.fm IPC |
| electron/main/ipc/config.ts | 配置变更时触发 Last.fm reloadConfig 副作用 |
| electron/main/core/index.ts | 应用启动时 init Last.fm 服务 |
| components.d.ts | 组件类型声明更新(包含 LastfmPanel) |
| .gitignore | 新增忽略项 docs/superpowers |
Comment on lines
+23
to
+28
| const encrypt = (plain: string): string => { | ||
| if (!plain) return ""; | ||
| if (!safeStorage.isEncryptionAvailable()) { | ||
| return Buffer.from(plain, "utf-8").toString("base64"); | ||
| } | ||
| return safeStorage.encryptString(plain).toString("base64"); |
Comment on lines
+36
to
+40
| if (!settings.system.lastfm.enabled || !settings.system.lastfm.loveSync) return; | ||
| const artist = track.artists?.[0]?.name ?? ""; | ||
| if (!artist || !track.title) return; | ||
| window.api.lastfm.love(artist, track.title, loved); | ||
| }; |
Comment on lines
+44
to
+47
| /** 取消授权轮询 */ | ||
| const handleCancel = (): void => { | ||
| window.api.lastfm.cancelConnect(); | ||
| }; |
Comment on lines
+122
to
+124
| } catch { | ||
| // 用户尚未授权,继续等待 | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
No description provided.