修复windows下界面缩放后移动桌面歌词会改变歌词窗口大小的问题(#2244)

pull/2266/head
lyswhut 2025-02-07 12:54:41 +08:00
parent 691d835d16
commit b80d48aa91
4 changed files with 31 additions and 13 deletions

View File

@ -1,4 +1,5 @@
### 修复 ### 修复
- 修复 Windows 下桌面歌词最小高度设置问题(#2244 - 修复 Windows 下桌面歌词最小高度设置问题(#2244
- 修复 Windows 下界面缩放后移动桌面歌词会改变歌词窗口大小的问题(#2244
- 修复 tx 歌单搜索名字、描述出现乱码的问题(#2250 - 修复 tx 歌单搜索名字、描述出现乱码的问题(#2250

View File

@ -14,11 +14,9 @@ export let minHeight = 38
* @param param * @param param
* @returns * @returns
*/ */
export const getLyricWindowBounds = (bounds: Electron.Rectangle, { x = 0, y = 0, w, h }: LX.DesktopLyric.NewBounds): Electron.Rectangle => { export const getLyricWindowBounds = (bounds: Electron.Rectangle, { x, y, w, h }: LX.DesktopLyric.NewBounds): Electron.Rectangle => {
if (w == 0) w = bounds.width if (w < minWidth) w = minWidth
else if (w < minWidth) w = minWidth if (h < minHeight) h = minHeight
if (h == 0) h = bounds.height
else if (h < minHeight) h = minHeight
if (global.lx.appSetting['desktopLyric.isLockScreen']) { if (global.lx.appSetting['desktopLyric.isLockScreen']) {
if (!global.envParams.workAreaSize) return bounds if (!global.envParams.workAreaSize) return bounds

View File

@ -22,6 +22,8 @@ export default (isComputeHeight) => {
isMsDown: false, isMsDown: false,
msDownX: 0, msDownX: 0,
msDownY: 0, msDownY: 0,
windowW: 0,
windowH: 0,
} }
let msDownY = 0 let msDownY = 0
@ -83,6 +85,8 @@ export default (isComputeHeight) => {
winEvent.isMsDown = true winEvent.isMsDown = true
winEvent.msDownX = x winEvent.msDownX = x
winEvent.msDownY = y winEvent.msDownY = y
winEvent.windowW = window.innerWidth
winEvent.windowH = window.innerHeight
} }
} }
const handleLyricMouseDown = event => { const handleLyricMouseDown = event => {
@ -114,8 +118,8 @@ export default (isComputeHeight) => {
setWindowBounds({ setWindowBounds({
x: x - winEvent.msDownX, x: x - winEvent.msDownX,
y: y - winEvent.msDownY, y: y - winEvent.msDownY,
w: 0, w: winEvent.windowW,
h: 0, h: winEvent.windowH,
}) })
} else { } else {
setWindowBounds({ setWindowBounds({

View File

@ -3,6 +3,7 @@ import { scrollXRTo } from '@common/utils/renderer'
import { lyric } from '@lyric/store/lyric' import { lyric } from '@lyric/store/lyric'
import { isPlay, setting } from '@lyric/store/state' import { isPlay, setting } from '@lyric/store/state'
import { setWindowBounds } from '@lyric/utils/ipc' import { setWindowBounds } from '@lyric/utils/ipc'
import { isWin } from '@common/utils'
const getOffsetTop = (contentWidth, lineWidth) => { const getOffsetTop = (contentWidth, lineWidth) => {
switch (setting['desktopLyric.scrollAlign']) { switch (setting['desktopLyric.scrollAlign']) {
@ -21,6 +22,8 @@ export default (isComputeWidth) => {
isMsDown: false, isMsDown: false,
msDownX: 0, msDownX: 0,
msDownY: 0, msDownY: 0,
windowW: 0,
windowH: 0,
} }
let msDownX = 0 let msDownX = 0
@ -82,6 +85,8 @@ export default (isComputeWidth) => {
winEvent.isMsDown = true winEvent.isMsDown = true
winEvent.msDownX = x winEvent.msDownX = x
winEvent.msDownY = y winEvent.msDownY = y
winEvent.windowW = window.innerWidth
winEvent.windowH = window.innerHeight
} }
} }
const handleLyricMouseDown = event => { const handleLyricMouseDown = event => {
@ -108,6 +113,15 @@ export default (isComputeWidth) => {
dom_lyric.value.scrollLeft = msDownScrollX + msDownX - x dom_lyric.value.scrollLeft = msDownScrollX + msDownX - x
startLyricScrollTimeout() startLyricScrollTimeout()
} else if (winEvent.isMsDown) { } else if (winEvent.isMsDown) {
// 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({ setWindowBounds({
x: x - winEvent.msDownX, x: x - winEvent.msDownX,
y: y - winEvent.msDownY, y: y - winEvent.msDownY,
@ -116,6 +130,7 @@ export default (isComputeWidth) => {
}) })
} }
} }
}
const handleMouseMsMove = event => { const handleMouseMsMove = event => {
handleMove(event.clientX, event.clientY) handleMove(event.clientX, event.clientY)
} }