From 3bff44da0c262aee8f879be702cca45cf5b76d53 Mon Sep 17 00:00:00 2001 From: lyswhut Date: Tue, 7 Feb 2023 11:56:19 +0800 Subject: [PATCH] =?UTF-8?q?=E9=98=B2=E6=AD=A2=E6=A1=8C=E9=9D=A2=E6=AD=8C?= =?UTF-8?q?=E8=AF=8D=E7=AA=97=E5=8F=A3=E5=9C=A8=E5=B1=8F=E5=B9=95=E5=88=86?= =?UTF-8?q?=E8=BE=A8=E7=8E=87=E5=8F=98=E5=B0=8F=E6=97=B6=EF=BC=8C=E7=AA=97?= =?UTF-8?q?=E5=8F=A3=E4=BD=8D=E7=BD=AE=E8=B7=9F=E9=9A=8F=E5=88=86=E8=BE=A8?= =?UTF-8?q?=E7=8E=87=E5=8F=98=E5=8C=96=E7=9A=84=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- publish/changeLog.md | 2 ++ src/main/modules/winLyric/main.ts | 35 ++++++++++++++++++--------- src/main/worker/dbService/verifyDB.ts | 4 +++ 3 files changed, 30 insertions(+), 11 deletions(-) diff --git a/publish/changeLog.md b/publish/changeLog.md index 79e42e25..9da7c1e8 100644 --- a/publish/changeLog.md +++ b/publish/changeLog.md @@ -16,6 +16,7 @@ - 调整了桌面歌词在启用滚动到顶部时的距离,现在滚动到顶部的歌词更靠边,不再受字体大小、歌词间距影响 - 优化更新弹窗内容的显示,添加了自动更新失败时的更新指引 - 为所有文本输入框添加右键快速粘贴的功能,右击输入框可以自动粘贴剪贴板的文字,若选中文字时将粘贴并替换选中文字 +- 防止桌面歌词窗口在屏幕分辨率变小时,窗口位置跟随分辨率变化的问题,现在若屏幕分辨率变小后窗口位置仍会在原始分辨率的位置(添加这个机制是为了解决屏幕分辨率被临时调整时的位置更新问题,如运行某些低分辨率的全屏游戏、高分辨率外接屏幕休眠时),但若你的分辨率调整不是临时的,因窗口在原始位置导致看不到窗口可以开关桌面歌词即可重新自动调节回屏幕内 ### 修复 @@ -23,3 +24,4 @@ - 修复较旧Linux arm64系统下无法启动软件的问题(将预构建模块的所需glibc版本降级到2.27)(#1161) - 修改列表响应式更新机制,尝试修复偶现的删除歌曲列表未更新的问题 - 修复某些kg歌单链接无法打开的问题 +- 修复将桌面歌词放到屏幕边缘时,偶现的开启桌面歌词后出现歌词窗口位置出现少许偏移的问题,以及将歌词窗口调整到全屏大小后,重开桌面歌词窗口被缩小出现边距的问题 diff --git a/src/main/modules/winLyric/main.ts b/src/main/modules/winLyric/main.ts index 230ee7bd..2ea09ca2 100644 --- a/src/main/modules/winLyric/main.ts +++ b/src/main/modules/winLyric/main.ts @@ -9,10 +9,11 @@ import { encodePath } from '@common/utils/electron' // require('./rendererEvent') let browserWindow: Electron.BrowserWindow | null = null +let isWinBoundsUdating = false - -const setLyricsConfig = debounce((config: Partial) => { +const saveBoundsConfig = debounce((config: Partial) => { global.lx.event_app.update_config(config) + if (isWinBoundsUdating) isWinBoundsUdating = false }, 500) const winEvent = () => { @@ -31,21 +32,31 @@ const winEvent = () => { browserWindow.on('move', () => { // bounds = browserWindow.getBounds() - // console.log(bounds) - const bounds = browserWindow!.getBounds() - setLyricsConfig({ - 'desktopLyric.x': bounds.x, - 'desktopLyric.y': bounds.y, - 'desktopLyric.width': bounds.width, - 'desktopLyric.height': bounds.height, - }) + // console.log('move', isWinBoundsUdating) + if (isWinBoundsUdating) { + const bounds = browserWindow!.getBounds() + saveBoundsConfig({ + 'desktopLyric.x': bounds.x, + 'desktopLyric.y': bounds.y, + 'desktopLyric.width': bounds.width, + 'desktopLyric.height': bounds.height, + }) + } else { + // 非主动调整窗口触发的窗口位置变化将重置回设置值 + browserWindow!.setBounds({ + x: global.lx.appSetting['desktopLyric.x'] ?? 0, + y: global.lx.appSetting['desktopLyric.y'] ?? 0, + width: global.lx.appSetting['desktopLyric.width'], + height: global.lx.appSetting['desktopLyric.height'], + }) + } }) browserWindow.on('resize', () => { // bounds = browserWindow.getBounds() // console.log(bounds) const bounds = browserWindow!.getBounds() - setLyricsConfig({ + saveBoundsConfig({ 'desktopLyric.x': bounds.x, 'desktopLyric.y': bounds.y, 'desktopLyric.width': bounds.width, @@ -102,6 +113,7 @@ export const createWindow = () => { } const { shouldUseDarkColors, theme } = global.lx.theme + isWinBoundsUdating = true /** * Initial window options @@ -166,6 +178,7 @@ export const getBounds = (): Electron.Rectangle => { export const setBounds = (bounds: Electron.Rectangle) => { if (!browserWindow) return + isWinBoundsUdating = true browserWindow.setBounds(bounds) } diff --git a/src/main/worker/dbService/verifyDB.ts b/src/main/worker/dbService/verifyDB.ts index e0411ea8..4116fd2f 100644 --- a/src/main/worker/dbService/verifyDB.ts +++ b/src/main/worker/dbService/verifyDB.ts @@ -8,6 +8,10 @@ export default (db: Database.Database) => { for (const info of result) dbTableMap.set(info.name, info.sql.replace(rxp, '')) return Array.from(tables.entries()).every(([name, sql]) => { const dbSql = dbTableMap.get(name) + // if (!(dbSql && dbSql == sql.replace(rxp, ''))) { + // console.log('dbSql:', dbSql, '\nsql:', sql.replace(rxp, '')) + // } + // return true return dbSql && dbSql == sql.replace(rxp, '') }) // console.log(dbTableMap)