From b80d48aa91d5f9ead4b5cccd8748800e0036f7a5 Mon Sep 17 00:00:00 2001 From: lyswhut Date: Fri, 7 Feb 2025 12:54:41 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E5=A4=8Dwindows=E4=B8=8B=E7=95=8C?= =?UTF-8?q?=E9=9D=A2=E7=BC=A9=E6=94=BE=E5=90=8E=E7=A7=BB=E5=8A=A8=E6=A1=8C?= =?UTF-8?q?=E9=9D=A2=E6=AD=8C=E8=AF=8D=E4=BC=9A=E6=94=B9=E5=8F=98=E6=AD=8C?= =?UTF-8?q?=E8=AF=8D=E7=AA=97=E5=8F=A3=E5=A4=A7=E5=B0=8F=E7=9A=84=E9=97=AE?= =?UTF-8?q?=E9=A2=98=EF=BC=88#2244=EF=BC=89?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- publish/changeLog.md | 1 + src/main/modules/winLyric/utils.ts | 8 +++--- .../layout/LyricHorizontal/useLyric.js | 8 ++++-- .../layout/LyricVertical/useLyric.js | 27 ++++++++++++++----- 4 files changed, 31 insertions(+), 13 deletions(-) diff --git a/publish/changeLog.md b/publish/changeLog.md index 090fb449..3ce2d164 100644 --- a/publish/changeLog.md +++ b/publish/changeLog.md @@ -1,4 +1,5 @@ ### 修复 - 修复 Windows 下桌面歌词最小高度设置问题(#2244) +- 修复 Windows 下界面缩放后移动桌面歌词会改变歌词窗口大小的问题(#2244) - 修复 tx 歌单搜索名字、描述出现乱码的问题(#2250) diff --git a/src/main/modules/winLyric/utils.ts b/src/main/modules/winLyric/utils.ts index 0c1bfbb7..ebfdd793 100644 --- a/src/main/modules/winLyric/utils.ts +++ b/src/main/modules/winLyric/utils.ts @@ -14,11 +14,9 @@ export let minHeight = 38 * @param param 新设置(相对于当前设置) * @returns */ -export const getLyricWindowBounds = (bounds: Electron.Rectangle, { x = 0, y = 0, w, h }: LX.DesktopLyric.NewBounds): Electron.Rectangle => { - if (w == 0) w = bounds.width - else if (w < minWidth) w = minWidth - if (h == 0) h = bounds.height - else if (h < minHeight) h = minHeight +export const getLyricWindowBounds = (bounds: Electron.Rectangle, { x, y, w, h }: LX.DesktopLyric.NewBounds): Electron.Rectangle => { + if (w < minWidth) w = minWidth + if (h < minHeight) h = minHeight if (global.lx.appSetting['desktopLyric.isLockScreen']) { if (!global.envParams.workAreaSize) return bounds diff --git a/src/renderer-lyric/components/layout/LyricHorizontal/useLyric.js b/src/renderer-lyric/components/layout/LyricHorizontal/useLyric.js index 1b00049b..24094aad 100644 --- a/src/renderer-lyric/components/layout/LyricHorizontal/useLyric.js +++ b/src/renderer-lyric/components/layout/LyricHorizontal/useLyric.js @@ -22,6 +22,8 @@ export default (isComputeHeight) => { isMsDown: false, msDownX: 0, msDownY: 0, + windowW: 0, + windowH: 0, } let msDownY = 0 @@ -83,6 +85,8 @@ export default (isComputeHeight) => { winEvent.isMsDown = true winEvent.msDownX = x winEvent.msDownY = y + winEvent.windowW = window.innerWidth + winEvent.windowH = window.innerHeight } } const handleLyricMouseDown = event => { @@ -114,8 +118,8 @@ export default (isComputeHeight) => { setWindowBounds({ x: x - winEvent.msDownX, y: y - winEvent.msDownY, - w: 0, - h: 0, + w: winEvent.windowW, + h: winEvent.windowH, }) } else { setWindowBounds({ diff --git a/src/renderer-lyric/components/layout/LyricVertical/useLyric.js b/src/renderer-lyric/components/layout/LyricVertical/useLyric.js index 2648ee03..7d9108a7 100644 --- a/src/renderer-lyric/components/layout/LyricVertical/useLyric.js +++ b/src/renderer-lyric/components/layout/LyricVertical/useLyric.js @@ -3,6 +3,7 @@ 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 { isWin } from '@common/utils' const getOffsetTop = (contentWidth, lineWidth) => { switch (setting['desktopLyric.scrollAlign']) { @@ -21,6 +22,8 @@ export default (isComputeWidth) => { isMsDown: false, msDownX: 0, msDownY: 0, + windowW: 0, + windowH: 0, } let msDownX = 0 @@ -82,6 +85,8 @@ export default (isComputeWidth) => { winEvent.isMsDown = true winEvent.msDownX = x winEvent.msDownY = y + winEvent.windowW = window.innerWidth + winEvent.windowH = window.innerHeight } } const handleLyricMouseDown = event => { @@ -108,12 +113,22 @@ export default (isComputeWidth) => { dom_lyric.value.scrollLeft = msDownScrollX + msDownX - x startLyricScrollTimeout() } else if (winEvent.isMsDown) { - setWindowBounds({ - x: x - winEvent.msDownX, - y: y - winEvent.msDownY, - w: window.innerWidth, - h: window.innerHeight, - }) + // https://github.com/lyswhut/lx-music-desktop/issues/2244 + if (isWin) { + setWindowBounds({ + x: x - winEvent.msDownX, + y: y - winEvent.msDownY, + w: winEvent.windowW, + h: winEvent.windowH, + }) + } else { + setWindowBounds({ + x: x - winEvent.msDownX, + y: y - winEvent.msDownY, + w: window.innerWidth, + h: window.innerHeight, + }) + } } } const handleMouseMsMove = event => {