mirror of
https://github.com/kuaifan/dootask.git
synced 2025-12-13 12:02:51 +00:00
perf: 优化主题变化逻辑
This commit is contained in:
parent
964611eba4
commit
d9aadb4f30
10
electron/electron.js
vendored
10
electron/electron.js
vendored
@ -810,6 +810,16 @@ if (!getTheLock) {
|
|||||||
createMainWindow()
|
createMainWindow()
|
||||||
// 预创建子窗口
|
// 预创建子窗口
|
||||||
preCreateChildWindow()
|
preCreateChildWindow()
|
||||||
|
// 监听主题变化(重建预窗口)
|
||||||
|
let currentTheme = nativeTheme.shouldUseDarkColors ? 'dark' : 'light';
|
||||||
|
nativeTheme.on('updated', () => {
|
||||||
|
const newTheme = nativeTheme.shouldUseDarkColors ? 'dark' : 'light';
|
||||||
|
if (currentTheme !== newTheme) {
|
||||||
|
currentTheme = newTheme;
|
||||||
|
preloadWindow?.close()
|
||||||
|
preCreateChildWindow()
|
||||||
|
}
|
||||||
|
})
|
||||||
// 创建托盘
|
// 创建托盘
|
||||||
if (['darwin', 'win32'].includes(process.platform) && utils.isJson(config.trayIcon)) {
|
if (['darwin', 'win32'].includes(process.platform) && utils.isJson(config.trayIcon)) {
|
||||||
mainTray = new Tray(path.join(__dirname, config.trayIcon[devloadUrl ? 'dev' : 'prod'][process.platform === 'darwin' ? 'mac' : 'win']));
|
mainTray = new Tray(path.join(__dirname, config.trayIcon[devloadUrl ? 'dev' : 'prod'][process.platform === 'darwin' ? 'mac' : 'win']));
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user