Skip to content

feat: 支持连接 Last.fm(记录播放、正在播放、喜欢同步)#25

Merged
imsyy merged 2 commits into
devfrom
feat/lastfm
Jun 4, 2026
Merged

feat: 支持连接 Last.fm(记录播放、正在播放、喜欢同步)#25
imsyy merged 2 commits into
devfrom
feat/lastfm

Conversation

@imsyy
Copy link
Copy Markdown
Member

@imsyy imsyy commented Jun 4, 2026

No description provided.

Copilot AI review requested due to automatic review settings June 4, 2026 09:51
Comment thread electron/main/services/lastfm/client.ts Dismissed
Copy link
Copy Markdown
Contributor

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 为 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 thread electron/main/services/lastfm/client.ts
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 thread electron/main/services/lastfm/index.ts Outdated
Comment on lines +122 to +124
} catch {
// 用户尚未授权,继续等待
}
@imsyy imsyy merged commit 035c76a into dev Jun 4, 2026
6 checks passed
@imsyy imsyy deleted the feat/lastfm branch June 4, 2026 14:10
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.

3 participants