新增 是否将歌词显示在状态栏 设置,默认关闭,该功能只在 MacOS 下可用(#1940)
parent
de5ea4f0aa
commit
308248d8ec
|
@ -1,3 +1,7 @@
|
|||
### 新增
|
||||
|
||||
- 新增 是否将歌词显示在状态栏 设置,默认关闭,该功能只在 MacOS 下可用(#1940)
|
||||
|
||||
### 修复
|
||||
|
||||
- 修复 MacOS 下点击 dock 右键菜单的退出按钮时,程序没有退出的问题(#1923)
|
||||
|
|
|
@ -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,
|
||||
|
|
|
@ -98,6 +98,12 @@ declare global {
|
|||
*/
|
||||
'player.isShowTaskProgess': boolean
|
||||
|
||||
|
||||
/**
|
||||
* 是否将歌词显示在状态栏
|
||||
*/
|
||||
'player.isShowStatusBarLyric': boolean
|
||||
|
||||
/**
|
||||
* 音量大小
|
||||
*/
|
||||
|
|
|
@ -526,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?",
|
||||
|
|
|
@ -526,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": "自定义音频输出设备与音频可视化功能会冲突,启用了音频可视化后音频输出设备将会被重置为默认的输出设备,目前此问题暂无法解决,是否仍要开启?",
|
||||
|
|
|
@ -526,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": "自訂音訊輸出設備與音訊視覺化功能會衝突,啟用了音訊視覺化後音訊輸出設備將會被重設為預設的輸出設備,目前此問題暫無法解決,是否仍要開啟?",
|
||||
|
|
|
@ -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,6 +13,7 @@ import { quitApp } from '@main/app'
|
|||
let tray: Electron.Tray | null
|
||||
let isEnableTray: boolean = false
|
||||
let themeId: number
|
||||
let isShowStatusBarLyric: boolean = false
|
||||
|
||||
const playerState = {
|
||||
empty: false,
|
||||
|
@ -28,6 +29,7 @@ const watchConfigKeys = [
|
|||
'desktopLyric.isAlwaysOnTop',
|
||||
'tray.themeId',
|
||||
'tray.enable',
|
||||
'player.isShowStatusBarLyric',
|
||||
'common.langId',
|
||||
] satisfies Array<keyof LX.AppSetting>
|
||||
|
||||
|
@ -65,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': {
|
||||
|
@ -82,6 +86,8 @@ const messages = {
|
|||
unlock_win_lyric: '解锁桌面歌词',
|
||||
top_win_lyric: '置顶歌词',
|
||||
untop_win_lyric: '取消置顶',
|
||||
show_statusbar_lyric: '显示状态栏歌词',
|
||||
hide_statusbar_lyric: '隐藏状态栏歌词',
|
||||
exit: '退出',
|
||||
},
|
||||
'zh-tw': {
|
||||
|
@ -99,6 +105,8 @@ const messages = {
|
|||
unlock_win_lyric: '解鎖桌面歌詞',
|
||||
top_win_lyric: '置頂歌詞',
|
||||
untop_win_lyric: '取消置頂',
|
||||
show_statusbar_lyric: '顯示狀態列歌詞',
|
||||
hide_statusbar_lyric: '隱藏狀態列歌詞',
|
||||
exit: '退出',
|
||||
},
|
||||
} as const
|
||||
|
@ -141,11 +149,12 @@ export const destroyTray = () => {
|
|||
if (!tray) return
|
||||
tray.destroy()
|
||||
isEnableTray = false
|
||||
isShowStatusBarLyric = false
|
||||
tray = null
|
||||
}
|
||||
|
||||
const handleUpdateConfig = (config: any) => {
|
||||
global.lx.event_app.update_config(config)
|
||||
const handleUpdateConfig = (setting: Partial<LX.AppSetting>) => {
|
||||
global.lx.event_app.update_config(setting)
|
||||
}
|
||||
|
||||
const createPlayerMenu = () => {
|
||||
|
@ -231,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()
|
||||
|
@ -263,6 +288,12 @@ 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']
|
||||
|
@ -272,6 +303,14 @@ const init = () => {
|
|||
isEnableTray = global.lx.appSetting['tray.enable']
|
||||
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()
|
||||
}
|
||||
|
||||
|
@ -317,21 +356,27 @@ 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
|
||||
|
|
|
@ -21,6 +21,8 @@ dd
|
|||
base-checkbox(id="setting_player_lyric_play_lxlrc" :model-value="appSetting['player.isPlayLxlrc']" :label="$t('setting__play_lyric_lxlrc')" @update:model-value="updateSetting({'player.isPlayLxlrc': $event})")
|
||||
.gap-top
|
||||
base-checkbox(id="setting_player_showTaskProgess" :model-value="appSetting['player.isShowTaskProgess']" :label="$t('setting__play_task_bar')" @update:model-value="updateSetting({'player.isShowTaskProgess': $event})")
|
||||
.gap-top(v-if="isMac")
|
||||
base-checkbox(id="setting_player_showStatusBarLyric" :model-value="appSetting['player.isShowStatusBarLyric']" :label="$t('setting__play_statusbar_lyric')" @update:model-value="updateSetting({'player.isShowStatusBarLyric': $event})")
|
||||
.gap-top
|
||||
base-checkbox(id="setting_player_isMaxOutputChannelCount" :model-value="isMaxOutputChannelCount" :label="$t('setting__play_max_output_channel_count')" @update:model-value="handleUpdateMaxOutputChannelCount")
|
||||
.gap-top
|
||||
|
@ -49,6 +51,7 @@ import { appSetting, saveMediaDeviceId, updateSetting } from '@renderer/store/se
|
|||
import { setPowerSaveBlocker } from '@renderer/core/player/utils'
|
||||
import { isPlay } from '@renderer/store/player/state'
|
||||
import { TRY_QUALITYS_LIST } from '@renderer/core/music/utils'
|
||||
import { isMac } from '@common/utils'
|
||||
|
||||
|
||||
export default {
|
||||
|
@ -140,6 +143,7 @@ export default {
|
|||
isMaxOutputChannelCount,
|
||||
handleUpdateMaxOutputChannelCount,
|
||||
playQualityList,
|
||||
isMac,
|
||||
}
|
||||
},
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue