diff --git a/publish/changeLog.md b/publish/changeLog.md index 3ce2d164..1542a19b 100644 --- a/publish/changeLog.md +++ b/publish/changeLog.md @@ -1,5 +1,9 @@ ### 修复 -- 修复 Windows 下桌面歌词最小高度设置问题(#2244) +- 修复 Windows 下桌面歌词最小高度与宽度设置问题(#2244) - 修复 Windows 下界面缩放后移动桌面歌词会改变歌词窗口大小的问题(#2244) - 修复 tx 歌单搜索名字、描述出现乱码的问题(#2250) + +### 优化 + +- 允许更小的桌面歌词窗口宽度 diff --git a/src/common/ipcNames.ts b/src/common/ipcNames.ts index d2d5d026..4084c9d4 100644 --- a/src/common/ipcNames.ts +++ b/src/common/ipcNames.ts @@ -162,6 +162,7 @@ const modules = { on_config_change: 'on_config_change', main_window_inited: 'main_window_inited', set_win_bounds: 'set_win_bounds', + set_win_resizeable: 'set_win_resizeable', key_down: 'key_down', request_main_window_channel: 'request_main_window_channel', provide_main_window_channel: 'provide_main_window_channel', diff --git a/src/main/modules/winLyric/main.ts b/src/main/modules/winLyric/main.ts index 5ee4a4dd..68c5ed66 100644 --- a/src/main/modules/winLyric/main.ts +++ b/src/main/modules/winLyric/main.ts @@ -1,7 +1,7 @@ import path from 'node:path' import { BrowserWindow } from 'electron' import { debounce, getPlatform, isLinux, isWin } from '@common/utils' -import { initWindowSize } from './utils' +import { initWindowSize, minHeight, minWidth } from './utils' import { mainSend } from '@common/mainIpc' import { encodePath } from '@common/utils/electron' @@ -115,8 +115,8 @@ export const createWindow = () => { width: winSize.width, x: winSize.x, y: winSize.y, - minWidth: 380, - minHeight: 38, + minWidth, + minHeight, useContentSize: true, frame: false, transparent: true, @@ -160,6 +160,11 @@ export const showWindow = () => { browserWindow.show() } +export const setResizeable = (isResizeable: boolean) => { + if (!browserWindow) return + browserWindow.setResizable(isResizeable) +} + export const sendEvent = (name: string, params?: T) => { if (!browserWindow) return mainSend(browserWindow, name, params) diff --git a/src/main/modules/winLyric/rendererEvent.ts b/src/main/modules/winLyric/rendererEvent.ts index e08daddc..2b0f0a7e 100644 --- a/src/main/modules/winLyric/rendererEvent.ts +++ b/src/main/modules/winLyric/rendererEvent.ts @@ -3,7 +3,7 @@ import { mainOn, mainHandle } from '@common/mainIpc' import { WIN_LYRIC_RENDERER_EVENT_NAME } from '@common/ipcNames' import { buildLyricConfig, getLyricWindowBounds } from './utils' import { sendNewDesktopLyricClient } from '@main/modules/winMain' -import { getBounds, getMainFrame, sendEvent, setBounds } from './main' +import { getBounds, getMainFrame, sendEvent, setBounds, setResizeable } from './main' import { MessageChannelMain } from 'electron' @@ -29,6 +29,10 @@ export default () => { setBounds(getLyricWindowBounds(getBounds(), options)) }) + mainOn(WIN_LYRIC_RENDERER_EVENT_NAME.set_win_resizeable, ({ params: resizable }) => { + setResizeable(resizable) + }) + mainOn(WIN_LYRIC_RENDERER_EVENT_NAME.request_main_window_channel, ({ event }) => { if (event.senderFrame !== getMainFrame()) return // Create a new channel ... diff --git a/src/main/modules/winLyric/utils.ts b/src/main/modules/winLyric/utils.ts index ebfdd793..a9fe9fb1 100644 --- a/src/main/modules/winLyric/utils.ts +++ b/src/main/modules/winLyric/utils.ts @@ -1,5 +1,5 @@ // 设置窗口位置、大小 -export let minWidth = 80 +export let minWidth = 38 export let minHeight = 38 diff --git a/src/renderer-lyric/components/layout/LyricHorizontal/useLyric.js b/src/renderer-lyric/components/layout/LyricHorizontal/useLyric.js index 24094aad..6bd3e2ea 100644 --- a/src/renderer-lyric/components/layout/LyricHorizontal/useLyric.js +++ b/src/renderer-lyric/components/layout/LyricHorizontal/useLyric.js @@ -2,7 +2,7 @@ import { ref, onMounted, onBeforeUnmount, watch, nextTick } from '@common/utils/ import { scrollTo } from '@common/utils/renderer' import { lyric } from '@lyric/store/lyric' import { isPlay, setting } from '@lyric/store/state' -import { setWindowBounds } from '@lyric/utils/ipc' +import { setWindowBounds, setWindowResizeable } from '@lyric/utils/ipc' import { isWin } from '@common/utils' const getOffsetTop = (contentHeight, lineHeight) => { @@ -87,6 +87,8 @@ export default (isComputeHeight) => { winEvent.msDownY = y winEvent.windowW = window.innerWidth winEvent.windowH = window.innerHeight + // https://github.com/lyswhut/lx-music-desktop/issues/2244 + if (isWin) setWindowResizeable(false) } } const handleLyricMouseDown = event => { @@ -101,6 +103,7 @@ export default (isComputeHeight) => { const handleMouseMsUp = () => { isMsDown.value = false winEvent.isMsDown = false + if (isWin) setWindowResizeable(true) } const handleMove = (x, y) => { diff --git a/src/renderer-lyric/components/layout/LyricVertical/useLyric.js b/src/renderer-lyric/components/layout/LyricVertical/useLyric.js index 7d9108a7..8d6cf47f 100644 --- a/src/renderer-lyric/components/layout/LyricVertical/useLyric.js +++ b/src/renderer-lyric/components/layout/LyricVertical/useLyric.js @@ -2,7 +2,7 @@ import { ref, onMounted, onBeforeUnmount, watch, nextTick } from '@common/utils/ import { scrollXRTo } from '@common/utils/renderer' import { lyric } from '@lyric/store/lyric' import { isPlay, setting } from '@lyric/store/state' -import { setWindowBounds } from '@lyric/utils/ipc' +import { setWindowBounds, setWindowResizeable } from '@lyric/utils/ipc' import { isWin } from '@common/utils' const getOffsetTop = (contentWidth, lineWidth) => { @@ -87,6 +87,8 @@ export default (isComputeWidth) => { winEvent.msDownY = y winEvent.windowW = window.innerWidth winEvent.windowH = window.innerHeight + // https://github.com/lyswhut/lx-music-desktop/issues/2244 + if (isWin) setWindowResizeable(false) } } const handleLyricMouseDown = event => { @@ -101,6 +103,7 @@ export default (isComputeWidth) => { const handleMouseMsUp = () => { isMsDown.value = false winEvent.isMsDown = false + if (isWin) setWindowResizeable(true) } const handleMove = (x, y) => { diff --git a/src/renderer-lyric/utils/ipc.ts b/src/renderer-lyric/utils/ipc.ts index 346dfa1e..55859722 100644 --- a/src/renderer-lyric/utils/ipc.ts +++ b/src/renderer-lyric/utils/ipc.ts @@ -18,6 +18,9 @@ export const onSettingChanged = (listener: LX.IpcRendererEventListenerParams { rendererSend(WIN_LYRIC_RENDERER_EVENT_NAME.set_win_bounds, bounds) } +export const setWindowResizeable = (resizable: boolean) => { + rendererSend(WIN_LYRIC_RENDERER_EVENT_NAME.set_win_resizeable, resizable) +} export const sendConnectMainWindowEvent = () => { rendererSend(WIN_LYRIC_RENDERER_EVENT_NAME.request_main_window_channel)