feat: macOS状态栏增加歌词显示

This commit is contained in:
Mxtzz 2024-06-13 16:44:05 +08:00 committed by lyswhut
parent de5ea4f0aa
commit 080150acc9
10 changed files with 26 additions and 4 deletions

View File

@ -72,6 +72,7 @@ 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,

View File

@ -319,6 +319,11 @@ declare global {
*/
'desktopLyric.isShowTaskbar': boolean
/**
*
*/
'desktopLyric.isShowStatusBar': boolean
/**
*
*/

View File

@ -6,6 +6,7 @@ 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']

View File

@ -388,6 +388,7 @@
"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",

View File

@ -388,6 +388,7 @@
"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": "保存",

View File

@ -388,6 +388,7 @@
"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": "儲存",

View File

@ -13,6 +13,7 @@ import { quitApp } from '@main/app'
let tray: Electron.Tray | null
let isEnableTray: boolean = false
let themeId: number
let isShowStatusBar: boolean = false
const playerState = {
empty: false,
@ -26,6 +27,7 @@ const watchConfigKeys = [
'desktopLyric.enable',
'desktopLyric.isLock',
'desktopLyric.isAlwaysOnTop',
'desktopLyric.isShowStatusBar',
'tray.themeId',
'tray.enable',
'common.langId',
@ -124,7 +126,7 @@ const getIconPath = (id: number) => {
export const createTray = () => {
// eslint-disable-next-line @typescript-eslint/prefer-nullish-coalescing
if ((tray && !tray.isDestroyed()) || !global.lx.appSetting['tray.enable']) return
if ((tray && !tray.isDestroyed())) return
// 托盘
tray = new Tray(nativeImage.createFromPath(getIconPath(global.lx.appSetting['tray.themeId'])))
@ -141,6 +143,7 @@ export const destroyTray = () => {
if (!tray) return
tray.destroy()
isEnableTray = false
isShowStatusBar = false
tray = null
}
@ -268,9 +271,10 @@ const init = () => {
themeId = global.lx.appSetting['tray.themeId']
setTrayImage(themeId)
}
if (isEnableTray !== global.lx.appSetting['tray.enable']) {
if (isEnableTray !== global.lx.appSetting['tray.enable'] || isShowStatusBar !== global.lx.appSetting['desktopLyric.isShowStatusBar']) {
isEnableTray = global.lx.appSetting['tray.enable']
global.lx.appSetting['tray.enable'] ? createTray() : destroyTray()
isShowStatusBar = global.lx.appSetting['desktopLyric.isShowStatusBar']
global.lx.appSetting['tray.enable'] || global.lx.appSetting['desktopLyric.isShowStatusBar'] ? createTray() : destroyTray()
}
createMenu()
}
@ -338,5 +342,8 @@ export default () => {
updated = true
}
if (updated) init()
if (tray && isShowStatusBar && status.lyricLineText) {
tray.setTitle(status.lyricLineText)
}
})
}

View File

@ -53,6 +53,7 @@ export const watchConfigKeys = [
'desktopLyric.isAlwaysOnTop',
'desktopLyric.isAlwaysOnTopLoop',
'desktopLyric.isShowTaskbar',
'desktopLyric.isShowStatusBar',
'desktopLyric.audioVisualization',
'desktopLyric.width',
'desktopLyric.height',

View File

@ -6,6 +6,7 @@ export const setting = shallowReactive<LX.DesktopLyric.Config>({
'desktopLyric.isAlwaysOnTop': false,
'desktopLyric.isAlwaysOnTopLoop': false,
'desktopLyric.isShowTaskbar': true,
'desktopLyric.isShowStatusBar': false,
'desktopLyric.audioVisualization': false,
'desktopLyric.width': 450,
'desktopLyric.height': 300,

View File

@ -15,6 +15,8 @@ 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
@ -93,7 +95,7 @@ dd
<script>
import { ref, computed, onMounted, onBeforeUnmount } from '@common/utils/vueTools'
import { getSystemFonts } from '@renderer/utils/ipc'
import { isLinux } from '@common/utils'
import { isLinux, isMac } from '@common/utils'
import { appSetting, updateSetting } from '@renderer/store/setting'
import { useI18n } from '@renderer/plugins/i18n'
import { pickrTools } from '@renderer/utils/pickrTools'
@ -294,6 +296,7 @@ export default {
fontList,
isLinux,
isMac,
}
},
}