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

增加 macOS 平台 statusbar 歌词显示 #622

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion app/listen1_chrome_extension
22 changes: 22 additions & 0 deletions app/main.js
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,9 @@ let mainWindow;
let floatingWindow;
/** @type {electron.Tray} */
let appTray;
/** enable_status_bar_lyric */
let showStatusBarLyric;
let currentLyric;
//platform-specific
switch (process.platform) {
case "darwin":
Expand Down Expand Up @@ -575,6 +578,15 @@ ipcMain.on("currentLyric", (event, arg) => {
floatingWindow.webContents.send("currentLyricTrans", arg.tlyric);
}
}
// 增加macOS 状态栏歌词展示
if (typeof arg === "string") {
currentLyric = arg
} else {
currentLyric = arg.lyric
}
if (process.platform === "darwin" && showStatusBarLyric) {
appTray.setTitle(currentLyric)
}
});

ipcMain.on("trackPlayingNow", (event, track) => {
Expand Down Expand Up @@ -605,6 +617,16 @@ ipcMain.on("control", async (event, arg, params) => {
floatingWindow?.hide();
break;

case "enable_status_bar_lyric":
appTray.setTitle(currentLyric)
showStatusBarLyric = true
break;

case "disable_status_bar_lyric":
appTray.setTitle("")
showStatusBarLyric = false
break;

case "window_min":
mainWindow.minimize();
break;
Expand Down