diff --git a/electron/main/index.ts b/electron/main/index.ts index 6564918e..b5efeedd 100644 --- a/electron/main/index.ts +++ b/electron/main/index.ts @@ -38,7 +38,7 @@ class MainProcess { constructor() { log.info("🚀 Main process startup"); // 禁用 Windows 7 的 GPU 加速功能 - if (release().startsWith("6.1") && type() == 'Windows_NT') app.disableHardwareAcceleration(); + if (release().startsWith("6.1") && type() == "Windows_NT") app.disableHardwareAcceleration(); // 单例锁 if (!app.requestSingleInstanceLock()) { log.error("❌ There is already a program running and this process is terminated"); @@ -236,6 +236,10 @@ class MainProcess { } // 窗口事件 handleWindowEvents() { + this.mainWindow?.on("ready-to-show", () => { + if (!this.mainWindow) return; + this.thumbar = initThumbar(this.mainWindow); + }); this.mainWindow?.on("show", () => { // this.mainWindow?.webContents.send("lyricsScroll"); }); diff --git a/electron/main/ipcMain.ts b/electron/main/ipcMain.ts index d039c991..9f7255ae 100644 --- a/electron/main/ipcMain.ts +++ b/electron/main/ipcMain.ts @@ -666,6 +666,10 @@ const initTrayIpcMain = ( // thumbar const initThumbarIpcMain = (thumbar: Thumbar | null): void => { if (!thumbar) return; + // 更新工具栏 + ipcMain.on("play-status-change", (_, playStatus: boolean) => { + thumbar?.updateThumbar(playStatus); + }); }; // store diff --git a/electron/main/thumbar.ts b/electron/main/thumbar.ts index aae0b66b..80c199fe 100644 --- a/electron/main/thumbar.ts +++ b/electron/main/thumbar.ts @@ -14,6 +14,7 @@ type ThumbarMap = Map; export interface Thumbar { clearThumbar(): void; + updateThumbar(playing: boolean, clean?: boolean): void; } // 工具栏图标 @@ -32,12 +33,12 @@ const createThumbarButtons = (win: BrowserWindow): ThumbarMap => { .set(ThumbarKeys.Prev, { tooltip: "上一曲", icon: thumbarIcon("prev"), - click: () => win.webContents.send("play-prev"), + click: () => win.webContents.send("playPrev"), }) .set(ThumbarKeys.Next, { tooltip: "下一曲", icon: thumbarIcon("next"), - click: () => win.webContents.send("play-next"), + click: () => win.webContents.send("playNext"), }) .set(ThumbarKeys.Play, { tooltip: "播放", @@ -47,7 +48,7 @@ const createThumbarButtons = (win: BrowserWindow): ThumbarMap => { .set(ThumbarKeys.Pause, { tooltip: "暂停", icon: thumbarIcon("pause"), - click: () => win.webContents.send("play-pause"), + click: () => win.webContents.send("pause"), }); }; @@ -75,7 +76,7 @@ class createThumbar implements Thumbar { this.updateThumbar(); } // 更新工具栏 - private updateThumbar(playing: boolean = false, clean: boolean = false) { + updateThumbar(playing: boolean = false, clean: boolean = false) { if (clean) return this.clearThumbar(); this._win.setThumbarButtons([this._prev, playing ? this._pause : this._play, this._next]); } diff --git a/package.json b/package.json index 4c085eea..1aeddcf9 100644 --- a/package.json +++ b/package.json @@ -1,7 +1,7 @@ { "name": "splayer", "productName": "SPlayer", - "version": "3.0.0-alpha.4", + "version": "3.0.0-beta.1", "description": "A minimalist music player", "main": "./out/main/index.js", "author": "imsyy", diff --git a/src/components/Menu/SongListMenu.vue b/src/components/Menu/SongListMenu.vue index f02ba84a..7b940a15 100644 --- a/src/components/Menu/SongListMenu.vue +++ b/src/components/Menu/SongListMenu.vue @@ -27,7 +27,7 @@ import { openPlaylistAdd, openSongInfoEditor, } from "@/utils/modal"; -import { deleteSongs } from "@/utils/auth"; +import { deleteSongs, isLogin } from "@/utils/auth"; import { songUrl } from "@/api/song"; import player from "@/utils/player"; @@ -64,6 +64,7 @@ const openDropdown = ( const isHasMv = !!song?.mv && song.mv !== 0; const isCloud = router.currentRoute.value.name === "cloud"; const isLocal = !!song?.path; + const isLoginNormal = isLogin() === 1; // 是否当前播放 const isCurrent = statusStore.playIndex === index; // 是否为用户歌单 @@ -169,7 +170,7 @@ const openDropdown = ( { key: "cloud-import", label: "导入至云盘", - show: !isCloud && type === "song" && !isLocal, + show: !isCloud && isLoginNormal && type === "song" && !isLocal, props: { onClick: () => importSongToCloud(song), }, @@ -178,7 +179,7 @@ const openDropdown = ( { key: "delete", label: "从歌单中删除", - show: isUserPlaylist && !isCloud, + show: isUserPlaylist && isLoginNormal && !isCloud, props: { onClick: () => deleteSongs(playListId!, [song.id], () => emit("removeSong", [song.id])), }, diff --git a/src/components/Modal/CreatePlaylist.vue b/src/components/Modal/CreatePlaylist.vue index 5779dc03..b53eb011 100644 --- a/src/components/Modal/CreatePlaylist.vue +++ b/src/components/Modal/CreatePlaylist.vue @@ -1,7 +1,7 @@