diff --git a/src/common/defaultSetting.ts b/src/common/defaultSetting.ts index 3e8c3111..92f6fed7 100644 --- a/src/common/defaultSetting.ts +++ b/src/common/defaultSetting.ts @@ -26,6 +26,7 @@ const defaultSetting: LX.AppSetting = { 'player.togglePlayMethod': 'listLoop', 'player.playQuality': '128k', 'player.isShowTaskProgess': true, + 'player.isShowStatusBarLyric': false, 'player.volume': 1, 'player.powerSaveBlocker': true, 'player.isMute': false, @@ -72,7 +73,6 @@ const defaultSetting: LX.AppSetting = { 'desktopLyric.isAlwaysOnTop': false, 'desktopLyric.isAlwaysOnTopLoop': false, 'desktopLyric.isShowTaskbar': false, - 'desktopLyric.isShowStatusBar': false, 'desktopLyric.audioVisualization': false, 'desktopLyric.fullscreenHide': true, 'desktopLyric.width': 450, diff --git a/src/common/types/app_setting.d.ts b/src/common/types/app_setting.d.ts index 09b4bfef..6b98f034 100644 --- a/src/common/types/app_setting.d.ts +++ b/src/common/types/app_setting.d.ts @@ -98,6 +98,12 @@ declare global { */ 'player.isShowTaskProgess': boolean + + /** + * 是否将将歌词显示在状态栏 + */ + 'player.isShowStatusBarLyric': boolean + /** * 音量大小 */ @@ -319,11 +325,6 @@ declare global { */ 'desktopLyric.isShowTaskbar': boolean - /** - * 是否将歌词进程显示在状态栏 - */ - 'desktopLyric.isShowStatusBar': boolean - /** * 是否启用音频可视化 */ diff --git a/src/common/types/desktop_lyric.d.ts b/src/common/types/desktop_lyric.d.ts index 5ecc2523..feb0f49a 100644 --- a/src/common/types/desktop_lyric.d.ts +++ b/src/common/types/desktop_lyric.d.ts @@ -6,7 +6,6 @@ declare namespace LX { 'desktopLyric.isAlwaysOnTop': LX.AppSetting['desktopLyric.isAlwaysOnTop'] 'desktopLyric.isAlwaysOnTopLoop': LX.AppSetting['desktopLyric.isAlwaysOnTopLoop'] 'desktopLyric.isShowTaskbar': LX.AppSetting['desktopLyric.isShowTaskbar'] - 'desktopLyric.isShowStatusBar': LX.AppSetting['desktopLyric.isShowStatusBar'] 'desktopLyric.audioVisualization': LX.AppSetting['desktopLyric.audioVisualization'] 'desktopLyric.width': LX.AppSetting['desktopLyric.width'] 'desktopLyric.height': LX.AppSetting['desktopLyric.height'] diff --git a/src/lang/en-us.json b/src/lang/en-us.json index c3d7fc8b..eedfa222 100644 --- a/src/lang/en-us.json +++ b/src/lang/en-us.json @@ -388,7 +388,6 @@ "setting__desktop_lyric_scroll_align_top": "Top", "setting__desktop_lyric_shadow_color": "Shadow color", "setting__desktop_lyric_show_taskbar": "Display lyrics progress on the taskbar (this setting is used as a workaround when the screen recording software cannot capture the lyrics window)", - "setting__desktop_lyric_show_status_bar": "Display lyrics progress on the Menu Bar", "setting__desktop_lyric_unplay_color": "Color not playing", "setting__dislike_list_input_tip": "song name@artist name\nSong name\n@ singer name", "setting__dislike_list_save_btn": "Save", @@ -527,6 +526,7 @@ "setting__play_power_save_blocker": "Prevent computer from sleeping while playing songs", "setting__play_save_play_time": "Remember playback progress", "setting__play_startup_auto_play": "Play music automatically after launching the software", + "setting__play_statusbar_lyric": "Show lyrics in status bar (needs tray enabled)", "setting__play_task_bar": "Show playing progress on the taskbar", "setting__play_timeout": "Timed pause", "setting__player_audio_visualization_tip": "The custom audio output device will conflict with the audio visualization function. After the audio visualization is enabled, the audio output device will be reset to the default output device. At present, this problem cannot be solved. Do you still want to enable it?", diff --git a/src/lang/zh-cn.json b/src/lang/zh-cn.json index 9277e083..639d4b0a 100644 --- a/src/lang/zh-cn.json +++ b/src/lang/zh-cn.json @@ -388,7 +388,6 @@ "setting__desktop_lyric_scroll_align_top": "顶部", "setting__desktop_lyric_shadow_color": "阴影颜色", "setting__desktop_lyric_show_taskbar": "在任务栏显示歌词进程(此设置用于在录屏软件无法捕获歌词窗口时的变通解决方法)", - "setting__desktop_lyric_show_status_bar": "在状态栏显示歌词进程", "setting__desktop_lyric_unplay_color": "未播放颜色", "setting__dislike_list_input_tip": "歌曲名@歌手名\n歌曲名\n@歌手名", "setting__dislike_list_save_btn": "保存", @@ -527,6 +526,7 @@ "setting__play_power_save_blocker": "播放歌曲时阻止电脑休眠", "setting__play_save_play_time": "记住播放进度", "setting__play_startup_auto_play": "启动软件后自动播放音乐", + "setting__play_statusbar_lyric": "在状态栏显示歌词(需要启用托盘)", "setting__play_task_bar": "在任务栏上显示当前歌曲播放进度", "setting__play_timeout": "定时暂停", "setting__player_audio_visualization_tip": "自定义音频输出设备与音频可视化功能会冲突,启用了音频可视化后音频输出设备将会被重置为默认的输出设备,目前此问题暂无法解决,是否仍要开启?", diff --git a/src/lang/zh-tw.json b/src/lang/zh-tw.json index d37be78f..95c572d6 100644 --- a/src/lang/zh-tw.json +++ b/src/lang/zh-tw.json @@ -388,7 +388,6 @@ "setting__desktop_lyric_scroll_align_top": "頂部", "setting__desktop_lyric_shadow_color": "陰影顏色", "setting__desktop_lyric_show_taskbar": "在工作列顯示歌詞進程(此設定用於在錄影軟體無法擷取歌詞視窗時的變通解決方法)", - "setting__desktop_lyric_show_status_bar": "在狀態列顯示歌詞進程", "setting__desktop_lyric_unplay_color": "未播放顏色", "setting__dislike_list_input_tip": "歌曲名@歌手名\n歌曲名\n@歌手名", "setting__dislike_list_save_btn": "儲存", @@ -527,6 +526,7 @@ "setting__play_power_save_blocker": "播放歌曲時阻止電腦休眠", "setting__play_save_play_time": "記住播放進度", "setting__play_startup_auto_play": "啟動軟體後自動播放音樂", + "setting__play_statusbar_lyric": "在狀態列顯示歌詞(需要啟用托盤)", "setting__play_task_bar": "在工作列上顯示目前歌曲播放進度", "setting__play_timeout": "定時暫停", "setting__player_audio_visualization_tip": "自訂音訊輸出設備與音訊視覺化功能會衝突,啟用了音訊視覺化後音訊輸出設備將會被重設為預設的輸出設備,目前此問題暫無法解決,是否仍要開啟?", diff --git a/src/main/modules/tray.ts b/src/main/modules/tray.ts index 8455c403..f52d2b8e 100644 --- a/src/main/modules/tray.ts +++ b/src/main/modules/tray.ts @@ -1,5 +1,5 @@ import { Tray, Menu, nativeImage } from 'electron' -import { isWin } from '@common/utils' +import { isMac, isWin } from '@common/utils' import path from 'node:path' import { hideWindow as hideMainWindow, @@ -13,7 +13,7 @@ import { quitApp } from '@main/app' let tray: Electron.Tray | null let isEnableTray: boolean = false let themeId: number -let isShowStatusBar: boolean = false +let isShowStatusBarLyric: boolean = false const playerState = { empty: false, @@ -27,9 +27,9 @@ const watchConfigKeys = [ 'desktopLyric.enable', 'desktopLyric.isLock', 'desktopLyric.isAlwaysOnTop', - 'desktopLyric.isShowStatusBar', 'tray.themeId', 'tray.enable', + 'player.isShowStatusBarLyric', 'common.langId', ] satisfies Array @@ -67,6 +67,8 @@ const messages = { unlock_win_lyric: 'Unlock desktop lyrics', top_win_lyric: 'Set top lyrics', untop_win_lyric: 'Cancel top lyrics', + show_statusbar_lyric: 'Show statusbar lyric', + hide_statusbar_lyric: 'Hide statusbar lyric', exit: 'Exit', }, 'zh-cn': { @@ -84,6 +86,8 @@ const messages = { unlock_win_lyric: '解锁桌面歌词', top_win_lyric: '置顶歌词', untop_win_lyric: '取消置顶', + show_statusbar_lyric: '显示状态栏歌词', + hide_statusbar_lyric: '隐藏状态栏歌词', exit: '退出', }, 'zh-tw': { @@ -101,6 +105,8 @@ const messages = { unlock_win_lyric: '解鎖桌面歌詞', top_win_lyric: '置頂歌詞', untop_win_lyric: '取消置頂', + show_statusbar_lyric: '顯示狀態列歌詞', + hide_statusbar_lyric: '隱藏狀態列歌詞', exit: '退出', }, } as const @@ -126,7 +132,7 @@ const getIconPath = (id: number) => { export const createTray = () => { // eslint-disable-next-line @typescript-eslint/prefer-nullish-coalescing - if ((tray && !tray.isDestroyed())) return + if ((tray && !tray.isDestroyed()) || !global.lx.appSetting['tray.enable']) return // 托盘 tray = new Tray(nativeImage.createFromPath(getIconPath(global.lx.appSetting['tray.themeId']))) @@ -143,12 +149,12 @@ export const destroyTray = () => { if (!tray) return tray.destroy() isEnableTray = false - isShowStatusBar = false + isShowStatusBarLyric = false tray = null } -const handleUpdateConfig = (config: any) => { - global.lx.event_app.update_config(config) +const handleUpdateConfig = (setting: Partial) => { + global.lx.event_app.update_config(setting) } const createPlayerMenu = () => { @@ -234,6 +240,22 @@ export const createMenu = () => { handleUpdateConfig({ 'desktopLyric.isAlwaysOnTop': true }) }, }) + if (isMac) { + menu.push({ type: 'separator' }) + menu.push(isShowStatusBarLyric + ? { + label: i18n.getMessage('hide_statusbar_lyric'), + click() { + handleUpdateConfig({ 'player.isShowStatusBarLyric': false }) + }, + } + : { + label: i18n.getMessage('show_statusbar_lyric'), + click() { + handleUpdateConfig({ 'player.isShowStatusBarLyric': true }) + }, + }) + } menu.push({ type: 'separator' }) if (isExistMainWindow()) { const isShow = isShowMainWindow() @@ -266,15 +288,28 @@ export const setTrayImage = (themeId: number) => { tray.setImage(nativeImage.createFromPath(getIconPath(themeId))) } +const setLyric = (lyricLineText?: string) => { + if (isShowStatusBarLyric && tray && lyricLineText != null) { + tray.setTitle(lyricLineText) + } +} + const init = () => { if (themeId != global.lx.appSetting['tray.themeId']) { themeId = global.lx.appSetting['tray.themeId'] setTrayImage(themeId) } - if (isEnableTray !== global.lx.appSetting['tray.enable'] || isShowStatusBar !== global.lx.appSetting['desktopLyric.isShowStatusBar']) { + if (isEnableTray !== global.lx.appSetting['tray.enable']) { isEnableTray = global.lx.appSetting['tray.enable'] - isShowStatusBar = global.lx.appSetting['desktopLyric.isShowStatusBar'] - global.lx.appSetting['tray.enable'] || global.lx.appSetting['desktopLyric.isShowStatusBar'] ? createTray() : destroyTray() + global.lx.appSetting['tray.enable'] ? createTray() : destroyTray() + } + if (isShowStatusBarLyric !== global.lx.appSetting['player.isShowStatusBarLyric']) { + isShowStatusBarLyric = global.lx.appSetting['player.isShowStatusBarLyric'] + if (isShowStatusBarLyric) { + setLyric(global.lx.player_status.lyricLineText) + } else { + tray?.setTitle('') + } } createMenu() } @@ -321,29 +356,32 @@ export default () => { case 'paused': playerState.play = false playerState.empty &&= false + setLyric('') break case 'error': playerState.play = false playerState.empty &&= false + setLyric('') break case 'playing': playerState.play = true playerState.empty &&= false + setLyric(global.lx.player_status.lyricLineText) break case 'stoped': playerState.play &&= false playerState.empty = true + setLyric('') break } updated = true + } else { + setLyric(status.lyricLineText) } if (status.collect != null) { playerState.collect = status.collect updated = true } if (updated) init() - if (tray && isShowStatusBar && status.lyricLineText) { - tray.setTitle(status.lyricLineText) - } }) } diff --git a/src/main/modules/winLyric/utils.ts b/src/main/modules/winLyric/utils.ts index f108c4a5..722e62eb 100644 --- a/src/main/modules/winLyric/utils.ts +++ b/src/main/modules/winLyric/utils.ts @@ -53,7 +53,6 @@ export const watchConfigKeys = [ 'desktopLyric.isAlwaysOnTop', 'desktopLyric.isAlwaysOnTopLoop', 'desktopLyric.isShowTaskbar', - 'desktopLyric.isShowStatusBar', 'desktopLyric.audioVisualization', 'desktopLyric.width', 'desktopLyric.height', diff --git a/src/renderer-lyric/store/state.ts b/src/renderer-lyric/store/state.ts index 87024d5b..3a7e87bf 100644 --- a/src/renderer-lyric/store/state.ts +++ b/src/renderer-lyric/store/state.ts @@ -6,7 +6,6 @@ export const setting = shallowReactive({ 'desktopLyric.isAlwaysOnTop': false, 'desktopLyric.isAlwaysOnTopLoop': false, 'desktopLyric.isShowTaskbar': true, - 'desktopLyric.isShowStatusBar': false, 'desktopLyric.audioVisualization': false, 'desktopLyric.width': 450, 'desktopLyric.height': 300, diff --git a/src/renderer/views/Setting/components/SettingDesktopLyric.vue b/src/renderer/views/Setting/components/SettingDesktopLyric.vue index bce48d12..50b8d2d6 100644 --- a/src/renderer/views/Setting/components/SettingDesktopLyric.vue +++ b/src/renderer/views/Setting/components/SettingDesktopLyric.vue @@ -15,8 +15,6 @@ dd base-checkbox(id="setting_desktop_lyric_alwaysOnTop" :model-value="appSetting['desktopLyric.isAlwaysOnTop']" :label="$t('setting__desktop_lyric_always_on_top')" @update:model-value="updateSetting({ 'desktopLyric.isAlwaysOnTop': $event })") .gap-top base-checkbox(id="setting_desktop_lyric_showTaskbar" :model-value="appSetting['desktopLyric.isShowTaskbar']" :label="$t('setting__desktop_lyric_show_taskbar')" @update:model-value="updateSetting({ 'desktopLyric.isShowTaskbar': $event })") - .gap-top(v-if="isMac") - base-checkbox(id="setting_desktop_lyric_showStatusBar" :model-value="appSetting['desktopLyric.isShowStatusBar']" :label="$t('setting__desktop_lyric_show_status_bar')" @update:model-value="updateSetting({ 'desktopLyric.isShowStatusBar': $event })") .gap-top base-checkbox(id="setting_desktop_lyric_alwaysOnTopLoop" :model-value="appSetting['desktopLyric.isAlwaysOnTopLoop']" :label="$t('setting__desktop_lyric_always_on_top_loop')" @update:model-value="updateSetting({ 'desktopLyric.isAlwaysOnTopLoop': $event })") .gap-top @@ -95,7 +93,7 @@ dd