新增动态主题“道法自然”

This commit is contained in:
lyswhut
2022-03-10 16:07:51 +08:00
parent d35a6f504f
commit 88b3d8ee4a
22 changed files with 358 additions and 32 deletions
+9 -2
View File
@@ -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()
+1
View File
@@ -22,6 +22,7 @@ require('./musicUrl')
require('./systemFonts')
require('./wait')
require('./openDevtools')
require('./nativeTheme')
if (isWin) require('./taskbar')
+11
View File
@@ -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)
})