From cb4ab411f9087020a9aee8ceefda7fd178bc9570 Mon Sep 17 00:00:00 2001 From: lyswhut Date: Sat, 4 Mar 2023 16:10:34 +0800 Subject: [PATCH] =?UTF-8?q?=E6=96=B0=E5=A2=9E=E5=85=A8=E5=B1=8F=E6=97=B6?= =?UTF-8?q?=E8=87=AA=E5=8A=A8=E5=85=B3=E9=97=AD=E6=AD=8C=E8=AF=8D=E8=AE=BE?= =?UTF-8?q?=E7=BD=AE?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- publish/changeLog.md | 1 + src/common/defaultSetting.ts | 1 + src/common/types/app_setting.d.ts | 5 +++++ src/lang/en-us.json | 1 + src/lang/zh-cn.json | 1 + src/lang/zh-tw.json | 1 + src/main/event/AppEvent.ts | 4 ++++ src/main/modules/winLyric/index.ts | 22 +++++++++++++++++-- src/main/modules/winMain/rendererEvent/app.ts | 1 + .../components/SettingDesktopLyric.vue | 2 ++ 10 files changed, 37 insertions(+), 2 deletions(-) diff --git a/publish/changeLog.md b/publish/changeLog.md index 16803afb..f02834f4 100644 --- a/publish/changeLog.md +++ b/publish/changeLog.md @@ -1,6 +1,7 @@ ### 新增 - 重构数据同步功能,新增客户端模式 +- 新增全屏时自动关闭歌词设置,默认开启,可以去设置-桌面歌词设置更改 ### 优化 diff --git a/src/common/defaultSetting.ts b/src/common/defaultSetting.ts index 4199ae12..d261052e 100644 --- a/src/common/defaultSetting.ts +++ b/src/common/defaultSetting.ts @@ -49,6 +49,7 @@ const defaultSetting: LX.AppSetting = { 'desktopLyric.isAlwaysOnTopLoop': false, 'desktopLyric.isShowTaskbar': false, 'desktopLyric.audioVisualization': false, + 'desktopLyric.fullscreenHide': true, 'desktopLyric.width': 450, 'desktopLyric.height': 300, 'desktopLyric.x': null, diff --git a/src/common/types/app_setting.d.ts b/src/common/types/app_setting.d.ts index 8cb3b6d5..a0e23abf 100644 --- a/src/common/types/app_setting.d.ts +++ b/src/common/types/app_setting.d.ts @@ -219,6 +219,11 @@ declare global { */ 'desktopLyric.audioVisualization': boolean + /** + * 是否在全屏时隐藏歌词 + */ + 'desktopLyric.fullscreenHide': boolean + /** * 桌面歌词窗口宽度 */ diff --git a/src/lang/en-us.json b/src/lang/en-us.json index 6b2bea51..adf3046d 100644 --- a/src/lang/en-us.json +++ b/src/lang/en-us.json @@ -319,6 +319,7 @@ "setting__desktop_lyric_font": "Lyric font", "setting__desktop_lyric_font_default": "Default", "setting__desktop_lyric_font_weight": "Bold font", + "setting__desktop_lyric_fullscreen_hide": "Automatically close lyrics when full screen", "setting__desktop_lyric_hover_hide": "Reduce the transparency of lyrics when the mouse moves into the lyrics area (this feature has platform compatibility issues)", "setting__desktop_lyric_line_gap": "Lyric spacing ({num})", "setting__desktop_lyric_line_gap_add": "Increase spacing", diff --git a/src/lang/zh-cn.json b/src/lang/zh-cn.json index f48ffa7e..c268f95c 100644 --- a/src/lang/zh-cn.json +++ b/src/lang/zh-cn.json @@ -321,6 +321,7 @@ "setting__desktop_lyric_font": "歌词字体", "setting__desktop_lyric_font_default": "默认", "setting__desktop_lyric_font_weight": "加粗字体", + "setting__desktop_lyric_fullscreen_hide": "全屏时自动关闭歌词", "setting__desktop_lyric_hover_hide": "鼠标移入歌词区域时降低歌词透明度(此功能存在平台兼容性问题)", "setting__desktop_lyric_line_gap": "歌词间距({num})", "setting__desktop_lyric_line_gap_add": "加大间距", diff --git a/src/lang/zh-tw.json b/src/lang/zh-tw.json index 1b29f243..81f5366b 100644 --- a/src/lang/zh-tw.json +++ b/src/lang/zh-tw.json @@ -320,6 +320,7 @@ "setting__desktop_lyric_font": "歌詞字體", "setting__desktop_lyric_font_default": "默認", "setting__desktop_lyric_font_weight": "加粗字體", + "setting__desktop_lyric_fullscreen_hide": "全屏時自動關閉歌詞", "setting__desktop_lyric_hover_hide": "鼠標移入歌詞區域時降低歌詞透明度(此功能存在平台兼容性問題)", "setting__desktop_lyric_line_gap": "歌詞間距({num})", "setting__desktop_lyric_line_gap_add": "加大間距", diff --git a/src/main/event/AppEvent.ts b/src/main/event/AppEvent.ts index 831fc2a3..9d826771 100644 --- a/src/main/event/AppEvent.ts +++ b/src/main/event/AppEvent.ts @@ -88,6 +88,10 @@ export class Event extends EventEmitter { main_window_close() { this.emit('main_window_close') } + + main_window_fullscreen(isFullscreen: boolean) { + this.emit('main_window_fullscreen', isFullscreen) + } } diff --git a/src/main/modules/winLyric/index.ts b/src/main/modules/winLyric/index.ts index 9f636522..f08aeba5 100644 --- a/src/main/modules/winLyric/index.ts +++ b/src/main/modules/winLyric/index.ts @@ -6,6 +6,7 @@ import { closeWindow, createWindow, isExistWindow } from './main' // import main from './main' // import { Event, EVENT_NAMES } from './event' +let isMainWidnowFullscreen = false export default () => { initRendererEvent() @@ -13,17 +14,34 @@ export default () => { // global.app_event.winMain. global.lx.event_app.on('main_window_inited', () => { + isMainWidnowFullscreen = global.lx.appSetting['common.startInFullscreen'] + if (global.lx.appSetting['desktopLyric.enable']) { - if (isExistWindow()) sendMainWindowInitedEvent() - else createWindow() + if (global.lx.appSetting['desktopLyric.fullscreenHide'] && isMainWidnowFullscreen) { + closeWindow() + } else { + if (isExistWindow()) sendMainWindowInitedEvent() + else createWindow() + } } }) global.lx.event_app.on('updated_config', (keys, setting) => { setLrcConfig(keys, setting) + if (keys.includes('desktopLyric.fullscreenHide') && global.lx.appSetting['desktopLyric.enable'] && isMainWidnowFullscreen) { + if (global.lx.appSetting['desktopLyric.fullscreenHide']) closeWindow() + else if (!isExistWindow()) createWindow() + } }) global.lx.event_app.on('main_window_close', () => { closeWindow() }) + global.lx.event_app.on('main_window_fullscreen', (isFullscreen) => { + isMainWidnowFullscreen = isFullscreen + if (global.lx.appSetting['desktopLyric.enable'] && global.lx.appSetting['desktopLyric.fullscreenHide']) { + if (isFullscreen) closeWindow() + else if (!isExistWindow()) createWindow() + } + }) // global.lx_event.mainWindow.on(MAIN_WINDOW_EVENT_NAME.setLyricInfo, info => { diff --git a/src/main/modules/winMain/rendererEvent/app.ts b/src/main/modules/winMain/rendererEvent/app.ts index e68177c0..631b7dc6 100644 --- a/src/main/modules/winMain/rendererEvent/app.ts +++ b/src/main/modules/winMain/rendererEvent/app.ts @@ -64,6 +64,7 @@ export default () => { }) // 全屏 mainHandle(WIN_MAIN_RENDERER_EVENT_NAME.fullscreen, async({ params: isFullscreen }) => { + global.lx.event_app.main_window_fullscreen(isFullscreen) return setFullScreen(isFullscreen) }) diff --git a/src/renderer/views/Setting/components/SettingDesktopLyric.vue b/src/renderer/views/Setting/components/SettingDesktopLyric.vue index c6ed0aef..aa16a9fc 100644 --- a/src/renderer/views/Setting/components/SettingDesktopLyric.vue +++ b/src/renderer/views/Setting/components/SettingDesktopLyric.vue @@ -5,6 +5,8 @@ dd base-checkbox(id="setting_desktop_lyric_enable" :modelValue="appSetting['desktopLyric.enable']" @update:modelValue="updateSetting({ 'desktopLyric.enable': $event })" :label="$t('setting__desktop_lyric_enable')") .gap-top base-checkbox(id="setting_desktop_lyric_lock" :modelValue="appSetting['desktopLyric.isLock']" @update:modelValue="updateSetting({ 'desktopLyric.isLock': $event })" :label="$t('setting__desktop_lyric_lock')") + .gap-top + base-checkbox(id="setting_desktop_lyric_fullscreen_hide" :modelValue="appSetting['desktopLyric.fullscreenHide']" @update:modelValue="updateSetting({ 'desktopLyric.fullscreenHide': $event })" :label="$t('setting__desktop_lyric_fullscreen_hide')") .gap-top base-checkbox(id="setting_desktop_lyric_audio_visualization" :modelValue="appSetting['desktopLyric.audioVisualization']" @update:modelValue="updateSetting({ 'desktopLyric.audioVisualization': $event })" :label="$t('setting__desktop_lyric_audio_visualization')") .gap-top