Skip to content

A full-featured download manager.

fix: change theme config

Dr_rOotafeee1fc86ba
diff --git a/src/main/Application.js b/src/main/Application.js
index 80d67aaa..b851cc53 100644
--- a/src/main/Application.js
+++ b/src/main/Application.js
@@ -142,7 +142,7 @@ export default class Application extends EventEmitter {
this.themeManager = new ThemeManager()
this.themeManager.on('system-theme-changed', (theme) => {
this.trayManager.changeIconTheme(theme)
- this.sendCommandToAll('application:theme', theme)
+ this.sendCommandToAll('application:system-theme', theme)
})
}
@@ -275,6 +275,11 @@ export default class Application extends EventEmitter {
this.updateManager.check()
})
+ this.on('application:change-theme', (theme) => {
+ this.themeManager.updateAppAppearance(theme)
+ this.sendCommandToAll('application:theme', theme)
+ })
+
this.on('application:change-locale', (locale) => {
logger.info('[Motrix] application:change-locale===>', locale)
this.localeManager.changeLanguageByLocale(locale)
diff --git a/src/main/ui/ThemeManager.js b/src/main/ui/ThemeManager.js
index b6698015..280a7155 100644
--- a/src/main/ui/ThemeManager.js
+++ b/src/main/ui/ThemeManager.js
@@ -31,9 +31,16 @@ export default class ThemeManager extends EventEmitter {
'AppleInterfaceThemeChangedNotification',
() => {
const theme = this.getSystemTheme()
- systemPreferences.setAppLevelAppearance(theme)
+ this.updateAppAppearance(theme)
this.emit('system-theme-changed', theme)
}
)
}
+
+ updateAppAppearance (theme) {
+ if (!is.macOS() || theme !== LIGHT_THEME || theme !== DARK_THEME) {
+ return
+ }
+ systemPreferences.setAppLevelAppearance(theme)
+ }
}
diff --git a/src/renderer/components/Command/index.js b/src/renderer/components/Command/index.js
index 638e9fd4..fafc27ac 100644
--- a/src/renderer/components/Command/index.js
+++ b/src/renderer/components/Command/index.js
@@ -13,6 +13,10 @@ function updateSystemTheme (theme) {
store.dispatch('app/updateSystemTheme', theme)
}
+function updateTheme (theme) {
+ store.dispatch('preference/changeThemeConfig', theme)
+}
+
function showAboutPanel () {
store.dispatch('app/showAboutPanel')
}
@@ -71,7 +75,8 @@ function resumeAllTask () {
store.dispatch('task/resumeAllTask')
}
-commands.register('application:theme', updateSystemTheme)
+commands.register('application:system-theme', updateSystemTheme)
+commands.register('application:theme', updateTheme)
commands.register('application:about', showAboutPanel)
commands.register('application:new-task', showAddTask)
commands.register('application:new-bt-task', showAddTask)
diff --git a/src/renderer/store/modules/preference.js b/src/renderer/store/modules/preference.js
index 61603b10..f08d1abd 100644
--- a/src/renderer/store/modules/preference.js
+++ b/src/renderer/store/modules/preference.js
@@ -1,36 +1,17 @@
import api from '@/api'
const state = {
- currentForm: 'basic',
engineMode: 'MAX',
config: {}
}
-const formTitles = {
- 'basic': '基础设置',
- 'advanced': '进阶设置',
- 'lab': '实验室'
-}
-
-const getters = {
- currentFormTitle: (state, getters) => {
- return formTitles[state.currentForm] ? formTitles[state.currentForm] : ''
- }
-}
-
const mutations = {
UPDATE_PREFERENCE_DATA (state, config) {
state.config = { ...state.config, ...config }
- },
- CHANGE_CURRENT_FORM (state, currentForm) {
- state.currentForm = currentForm
}
}
const actions = {
- changeCurrentForm ({ commit }, currentForm) {
- commit('CHANGE_CURRENT_FORM', currentForm)
- },
fetchPreference ({ commit }) {
return new Promise((resolve) => {
api.fetchPreference()
@@ -44,6 +25,9 @@ const actions = {
commit('UPDATE_PREFERENCE_DATA', config)
return api.savePreference(config)
},
+ changeThemeConfig ({ commit }, theme) {
+ commit('UPDATE_PREFERENCE_DATA', { theme })
+ },
toggleEngineMode () {
}
@@ -52,7 +36,6 @@ const actions = {
export default {
namespaced: true,
state,
- getters,
mutations,
actions
}
diff --git a/src/shared/configKeys.js b/src/shared/configKeys.js
index a0bc7eab..af3d5b8b 100644
--- a/src/shared/configKeys.js
+++ b/src/shared/configKeys.js
@@ -10,6 +10,7 @@ const userKeys = [
'log-path',
'session-path',
'enable-egg-features',
+ 'theme',
'auto-check-update',
'last-check-update-time'
]