@@ -137,7 +137,7 @@ const initLyricIpc = (): void => {
137137 // 更新歌词窗口配置
138138 ipcMain . on ( "update-desktop-lyric-option" , ( _ , option , callback : boolean = false ) => {
139139 const mainWin = mainWindow . getWin ( ) ;
140- if ( ! option || ! isWinAlive ( lyricWin ) ) return ;
140+ if ( ! option ) return ;
141141 // 增量更新
142142 const prevOption = store . get ( "lyric.config" ) ;
143143 if ( prevOption ) {
@@ -193,25 +193,28 @@ const initLyricIpc = (): void => {
193193 if ( ! isWinAlive ( lyricWin ) ) return ;
194194 lyricWin . setBounds ( { x, y, width, height } ) ;
195195 // 保存配置
196- store . set ( "lyric" , { ...store . get ( "lyric" ) , x, y, width, height } ) ;
196+ store . set ( "lyric.x" , x ) ;
197+ store . set ( "lyric.y" , y ) ;
198+ store . set ( "lyric.width" , width ) ;
199+ store . set ( "lyric.height" , height ) ;
197200 } ) ;
198201
199202 // 更新歌词窗口宽高
200203 ipcMain . on ( "update-lyric-size" , ( _ , width , height ) => {
201204 if ( ! isWinAlive ( lyricWin ) ) return ;
202205 // 更新窗口宽度
203206 lyricWin . setBounds ( { width, height } ) ;
204- store . set ( "lyric" , { ...store . get ( "lyric" ) , width, height } ) ;
207+ store . set ( "lyric.width" , width ) ;
208+ store . set ( "lyric.height" , height ) ;
205209 } ) ;
206210
207211 // 更新高度
208212 ipcMain . on ( "update-window-height" , ( _ , height ) => {
209213 if ( ! isWinAlive ( lyricWin ) ) return ;
210- const store = useStore ( ) ;
211214 const { width } = lyricWin . getBounds ( ) ;
212215 // 更新窗口高度
213216 lyricWin . setBounds ( { width, height } ) ;
214- store . set ( "lyric" , { ... store . get ( "lyric" ) , height } ) ;
217+ store . set ( "lyric.height" , height ) ;
215218 } ) ;
216219
217220 // 是否固定当前最大宽高
@@ -256,23 +259,26 @@ const initLyricIpc = (): void => {
256259 // 锁定/解锁桌面歌词
257260 ipcMain . on ( "toggle-desktop-lyric-lock" , ( _ , isLock : boolean , isTemp : boolean = false ) => {
258261 const mainWin = mainWindow . getWin ( ) ;
259- if ( ! isWinAlive ( lyricWin ) || ! isWinAlive ( mainWin ) ) return ;
260262
261263 // 更新锁定状态
262264 if ( ! isTemp ) isLocked = isLock ;
263265
264266 // 设置鼠标事件穿透
265- if ( isLock ) {
266- lyricWin . setIgnoreMouseEvents ( true , { forward : true } ) ;
267- } else {
268- lyricWin . setIgnoreMouseEvents ( false ) ;
267+ if ( isWinAlive ( lyricWin ) ) {
268+ if ( isLock ) {
269+ lyricWin . setIgnoreMouseEvents ( true , { forward : true } ) ;
270+ } else {
271+ lyricWin . setIgnoreMouseEvents ( false ) ;
272+ }
269273 }
270274
271275 if ( isTemp ) return ;
272- store . set ( "lyric.config" , { ... store . get ( "lyric.config" ) , isLock } ) ;
276+ store . set ( "lyric.config.isLock" , isLock ) ;
273277 // 触发窗口更新
274278 const config = store . get ( "lyric.config" ) ;
275- mainWin ?. webContents . send ( "update-desktop-lyric-option" , config ) ;
279+ if ( isWinAlive ( mainWin ) ) {
280+ mainWin . webContents . send ( "update-desktop-lyric-option" , config ) ;
281+ }
276282 } ) ;
277283} ;
278284
0 commit comments