修复 Windows 下桌面歌词最小高度与宽度设置问题,允许更小的桌面歌词窗口宽度(#2244)

This commit is contained in:
lyswhut
2025-02-10 18:17:45 +08:00
parent 1f8df84b87
commit 92c9808bfb
8 changed files with 31 additions and 8 deletions
+8 -3
View File
@@ -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 = <T = any>(name: string, params?: T) => {
if (!browserWindow) return
mainSend(browserWindow, name, params)
+5 -1
View File
@@ -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<boolean>(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 ...
+1 -1
View File
@@ -1,5 +1,5 @@
// 设置窗口位置、大小
export let minWidth = 80
export let minWidth = 38
export let minHeight = 38