diff --git a/publish/changeLog.md b/publish/changeLog.md index 9b68f321..07d08b74 100644 --- a/publish/changeLog.md +++ b/publish/changeLog.md @@ -8,6 +8,7 @@ - 重构数据同步功能,新增客户端模式 - 新增全屏时自动关闭歌词设置,默认开启,可以去设置-桌面歌词设置更改 +- 新增设置-桌面歌词设置-重置窗口设置功能,点击时会重置桌面歌词窗口大小及位置 ### 优化 diff --git a/src/lang/en-us.json b/src/lang/en-us.json index adf3046d..3cff6a52 100644 --- a/src/lang/en-us.json +++ b/src/lang/en-us.json @@ -327,6 +327,8 @@ "setting__desktop_lyric_lock": "Lock lyrics", "setting__desktop_lyric_lock_screen": "It is not allowed to drag the lyrics window out of the main screen", "setting__desktop_lyric_played_color": "color played", + "setting__desktop_lyric_reset": "Reset", + "setting__desktop_lyric_reset_window": "Reset window settings", "setting__desktop_lyric_scroll_align": "now playing lyrics scroll position", "setting__desktop_lyric_scroll_align_center": "Center", "setting__desktop_lyric_scroll_align_top": "Top", diff --git a/src/lang/zh-cn.json b/src/lang/zh-cn.json index c268f95c..515c037e 100644 --- a/src/lang/zh-cn.json +++ b/src/lang/zh-cn.json @@ -329,6 +329,8 @@ "setting__desktop_lyric_lock": "锁定歌词", "setting__desktop_lyric_lock_screen": "不允许歌词窗口拖出主屏幕之外", "setting__desktop_lyric_played_color": "已播放颜色", + "setting__desktop_lyric_reset": "重置", + "setting__desktop_lyric_reset_window": "重置窗口设置", "setting__desktop_lyric_scroll_align": "正在播放歌词滚动位置", "setting__desktop_lyric_scroll_align_center": "中心", "setting__desktop_lyric_scroll_align_top": "顶部", diff --git a/src/lang/zh-tw.json b/src/lang/zh-tw.json index 81f5366b..4c52f05e 100644 --- a/src/lang/zh-tw.json +++ b/src/lang/zh-tw.json @@ -328,6 +328,8 @@ "setting__desktop_lyric_lock": "鎖定歌詞", "setting__desktop_lyric_lock_screen": "不允許歌詞窗口拖出主屏幕之外", "setting__desktop_lyric_played_color": "已播放顏色", + "setting__desktop_lyric_reset": "重置", + "setting__desktop_lyric_reset_window": "重置窗口設置", "setting__desktop_lyric_scroll_align": "正在播放歌詞滾動位置", "setting__desktop_lyric_scroll_align_center": "中心", "setting__desktop_lyric_scroll_align_top": "頂部", diff --git a/src/main/modules/winLyric/config.ts b/src/main/modules/winLyric/config.ts index 6a04a351..59c9e94d 100644 --- a/src/main/modules/winLyric/config.ts +++ b/src/main/modules/winLyric/config.ts @@ -1,7 +1,7 @@ import { isLinux } from '@common/utils' import { closeWindow, createWindow, getBounds, isExistWindow, alwaysOnTopTools, setBounds, setIgnoreMouseEvents, setSkipTaskbar } from './main' import { sendConfigChange } from './rendererEvent' -import { buildLyricConfig, getLyricWindowBounds, watchConfigKeys } from './utils' +import { buildLyricConfig, getLyricWindowBounds, initWindowSize, watchConfigKeys } from './utils' let isLock: boolean let isEnable: boolean @@ -62,6 +62,14 @@ export const setLrcConfig = (keys: Array, setting: Partial< })) } } + if (keys.includes('desktopLyric.x') && setting['desktopLyric.x'] == null) { + setBounds(initWindowSize( + global.lx.appSetting['desktopLyric.x'], + global.lx.appSetting['desktopLyric.y'], + global.lx.appSetting['desktopLyric.width'], + global.lx.appSetting['desktopLyric.height'], + )) + } } if (keys.includes('desktopLyric.enable') && isEnable != global.lx.appSetting['desktopLyric.enable']) { isEnable = global.lx.appSetting['desktopLyric.enable'] diff --git a/src/main/modules/winLyric/main.ts b/src/main/modules/winLyric/main.ts index 061466df..94200ca7 100644 --- a/src/main/modules/winLyric/main.ts +++ b/src/main/modules/winLyric/main.ts @@ -1,7 +1,7 @@ import { join } from 'path' import { BrowserWindow } from 'electron' import { debounce, isLinux } from '@common/utils' -import { getLyricWindowBounds, minHeight, minWidth, padding } from './utils' +import { initWindowSize } from './utils' import { mainSend } from '@common/mainIpc' import { encodePath } from '@common/utils/electron' @@ -9,11 +9,11 @@ import { encodePath } from '@common/utils/electron' // require('./rendererEvent') let browserWindow: Electron.BrowserWindow | null = null -let isWinBoundsUdating = false +let isWinBoundsUpdateing = false const saveBoundsConfig = debounce((config: Partial) => { global.lx.event_app.update_config(config) - if (isWinBoundsUdating) isWinBoundsUdating = false + if (isWinBoundsUpdateing) isWinBoundsUpdateing = false }, 500) const winEvent = () => { @@ -32,8 +32,8 @@ const winEvent = () => { browserWindow.on('move', () => { // bounds = browserWindow.getBounds() - // console.log('move', isWinBoundsUdating) - if (isWinBoundsUdating) { + // console.log('move', isWinBoundsUpdateing) + if (isWinBoundsUpdateing) { const bounds = browserWindow!.getBounds() saveBoundsConfig({ 'desktopLyric.x': bounds.x, @@ -95,27 +95,12 @@ export const createWindow = () => { // let isLockScreen = global.lx.appSetting['desktopLyric.isLockScreen'] let isShowTaskbar = global.lx.appSetting['desktopLyric.isShowTaskbar'] // let { width: screenWidth, height: screenHeight } = global.envParams.workAreaSize - if (x == null || y == null) { - if (width < minWidth) width = minWidth - if (height < minHeight) height = minHeight - if (global.envParams.workAreaSize) { - x = global.envParams.workAreaSize.width + padding - width - y = global.envParams.workAreaSize.height + padding - height - } else { - x = y = -padding - } - } else { - let bounds = getLyricWindowBounds({ x, y, width, height }, { x: 0, y: 0, w: width, h: height }) - x = bounds.x - y = bounds.y - width = bounds.width - height = bounds.height - } + const winSize = initWindowSize(x, y, width, height) global.lx.event_app.update_config({ - 'desktopLyric.x': x, - 'desktopLyric.y': y, - 'desktopLyric.width': width, - 'desktopLyric.height': height, + 'desktopLyric.x': winSize.x, + 'desktopLyric.y': winSize.y, + 'desktopLyric.width': winSize.width, + 'desktopLyric.height': winSize.height, }) const { shouldUseDarkColors, theme } = global.lx.theme @@ -124,10 +109,10 @@ export const createWindow = () => { * Initial window options */ browserWindow = new BrowserWindow({ - height, - width, - x, - y, + height: winSize.height, + width: winSize.width, + x: winSize.x, + y: winSize.y, minWidth: 380, minHeight: 80, useContentSize: true, @@ -183,7 +168,7 @@ export const getBounds = (): Electron.Rectangle => { export const setBounds = (bounds: Electron.Rectangle) => { if (!browserWindow) return - isWinBoundsUdating = true + isWinBoundsUpdateing = true browserWindow.setBounds(bounds) } diff --git a/src/main/modules/winLyric/utils.ts b/src/main/modules/winLyric/utils.ts index b55e1e18..ddf06b2f 100644 --- a/src/main/modules/winLyric/utils.ts +++ b/src/main/modules/winLyric/utils.ts @@ -95,3 +95,28 @@ export const buildLyricConfig = (appSetting: Partial): Partial { + if (x == null || y == null) { + if (width < minWidth) width = minWidth + if (height < minHeight) height = minHeight + if (global.envParams.workAreaSize) { + x = global.envParams.workAreaSize.width + padding - width + y = global.envParams.workAreaSize.height + padding - height + } else { + x = y = -padding + } + } else { + let bounds = getLyricWindowBounds({ x, y, width, height }, { x: 0, y: 0, w: width, h: height }) + x = bounds.x + y = bounds.y + width = bounds.width + height = bounds.height + } + return { + x, + y, + width, + height, + } +} diff --git a/src/renderer/views/Setting/components/SettingDesktopLyric.vue b/src/renderer/views/Setting/components/SettingDesktopLyric.vue index aa16a9fc..322435c6 100644 --- a/src/renderer/views/Setting/components/SettingDesktopLyric.vue +++ b/src/renderer/views/Setting/components/SettingDesktopLyric.vue @@ -81,6 +81,13 @@ dd h3#desktop_lyric_font {{$t('setting__desktop_lyric_font')}} div base-selection.gap-teft(:list="fontList" :modelValue="appSetting['desktopLyric.style.font']" @update:modelValue="updateSetting({ 'desktopLyric.style.font': $event })" item-key="id" item-name="label") + +dd + h3#desktop_lyric_reset {{ $t('setting__desktop_lyric_reset') }} + div + p.gap-top + base-btn.btn(min @click="resetWindowSetting") {{$t('setting__desktop_lyric_reset_window')}} +