新增动态主题“道法自然”
This commit is contained in:
+9
-2
@@ -1,4 +1,4 @@
|
||||
const { app, BrowserWindow, shell } = require('electron')
|
||||
const { app, BrowserWindow, shell, nativeTheme } = require('electron')
|
||||
const path = require('path')
|
||||
|
||||
const urlSchemeRxp = /^lxmusic:\/\//
|
||||
@@ -180,7 +180,14 @@ function createWindow() {
|
||||
},
|
||||
})
|
||||
|
||||
global.modules.mainWindow.loadURL(winURL + `?dt=${!!global.envParams.cmdParams.dt}&theme=${themes.find(t => t.id == global.appSetting.themeId)?.className ?? themes[0].className}`)
|
||||
const shouldUseDarkColors = nativeTheme.shouldUseDarkColors
|
||||
const themeId = global.appSetting.theme.id == 'auto'
|
||||
? shouldUseDarkColors
|
||||
? global.appSetting.theme.darkId
|
||||
: global.appSetting.theme.lightId
|
||||
: global.appSetting.theme.id
|
||||
const themeClass = themes.find(t => t.id == themeId)?.className ?? themes[0].className
|
||||
global.modules.mainWindow.loadURL(winURL + `?dt=${!!global.envParams.cmdParams.dt}&dark=${shouldUseDarkColors}&theme=${themeClass}`)
|
||||
|
||||
winEvent(global.modules.mainWindow)
|
||||
// global.modules.mainWindow.webContents.openDevTools()
|
||||
|
||||
@@ -22,6 +22,7 @@ require('./musicUrl')
|
||||
require('./systemFonts')
|
||||
require('./wait')
|
||||
require('./openDevtools')
|
||||
require('./nativeTheme')
|
||||
|
||||
if (isWin) require('./taskbar')
|
||||
|
||||
|
||||
@@ -0,0 +1,11 @@
|
||||
const { nativeTheme } = require('electron')
|
||||
|
||||
const { NAMES: { mainWindow: ipcMainWindowNames }, mainSend } = require('@common/ipc')
|
||||
|
||||
nativeTheme.addListener('updated', (event) => {
|
||||
// console.log(event.sender.shouldUseDarkColors)
|
||||
if (!global.modules.mainWindow) return
|
||||
mainSend(global.modules.mainWindow, ipcMainWindowNames.system_theme_change, event.sender.shouldUseDarkColors)
|
||||
// console.log(nativeTheme.themeSource)
|
||||
})
|
||||
|
||||
Reference in New Issue
Block a user