Skip to content

A full-featured download manager.

fix: auto theme

Dr_rOot87635ade345a
diff --git a/src/main/Application.js b/src/main/Application.js
index 2c0d256f..b670296b 100644
--- a/src/main/Application.js
+++ b/src/main/Application.js
@@ -652,7 +652,7 @@ export default class Application extends EventEmitter {
})
this.on('application:change-theme', (theme) => {
- this.themeManager.updateAppAppearance(theme)
+ this.themeManager.updateSystemTheme(theme)
this.sendCommandToAll('application:update-theme', { theme })
})
diff --git a/src/main/ui/ThemeManager.js b/src/main/ui/ThemeManager.js
index ac92f7d6..b77dbc43 100644
--- a/src/main/ui/ThemeManager.js
+++ b/src/main/ui/ThemeManager.js
@@ -1,8 +1,9 @@
import { EventEmitter } from 'events'
-import { nativeTheme, systemPreferences } from 'electron'
+import { nativeTheme } from 'electron'
import is from 'electron-is'
import { APP_THEME } from '@shared/constants'
+import logger from '../core/Logger'
import { getSystemTheme } from '../utils'
export default class ThemeManager extends EventEmitter {
@@ -31,19 +32,13 @@ export default class ThemeManager extends EventEmitter {
nativeTheme.on('updated', () => {
const theme = getSystemTheme()
this.systemTheme = theme
- console.log('nativeTheme updated===>', theme)
+ logger.info('[Motrix] nativeTheme updated===>', theme)
this.emit('system-theme-change', theme)
})
}
- /**
- * deprecated
- * @see https://www.electronjs.org/docs/all#systempreferencessetapplevelappearanceappearance-macos-deprecated
- */
- updateAppAppearance (theme) {
- if (!is.macOS() || theme !== APP_THEME.LIGHT || theme !== APP_THEME.DARK) {
- return
- }
- systemPreferences.setAppLevelAppearance(theme)
+ updateSystemTheme (theme) {
+ theme = theme === APP_THEME.AUTO ? 'system' : theme
+ nativeTheme.themeSource = theme
}
}