fix: 🐛 修复设置主题跟随系统后没有生效的问题

This commit is contained in:
viarotel 2023-10-28 21:00:16 +08:00
parent eff127a940
commit 95a83f4072
5 changed files with 8 additions and 8 deletions

View File

@ -8,7 +8,7 @@
@change="onChange"
>
<el-option
v-for="(item, index) in options"
v-for="(item, index) in data.options"
:key="index"
:label="$t(item.label)"
:value="item.value"

View File

@ -178,6 +178,7 @@
>
</el-option>
</el-select>
<component
:is="item_1.type"
v-else

View File

@ -106,7 +106,7 @@
"preferences.common.theme.placeholder": "Set theme",
"preferences.common.theme.options[0]": "Light Mode",
"preferences.common.theme.options[1]": "Dark Mode",
"preferences.common.theme.options[2]": "System Default",
"preferences.common.theme.options[2]": "Following system",
"preferences.common.debug.name": "Debug",
"preferences.common.debug.placeholder": "Enable debug mode",
"preferences.common.debug.tips": "Show debug info in log, disable to improve performance. Restart to take effect.",

View File

@ -106,7 +106,7 @@
"preferences.common.theme.placeholder": "设置主题",
"preferences.common.theme.options[0]": "浅色模式",
"preferences.common.theme.options[1]": "深色模式",
"preferences.common.theme.options[2]": "系统自适应",
"preferences.common.theme.options[2]": "跟随系统",
"preferences.common.debug.name": "调试",
"preferences.common.debug.placeholder": "是否启动软件调试",
"preferences.common.debug.tips": "启用后可以在运行日志中查看软件运行情况,一般不需要开启可能会影响性能,注意: 改变此选项需要重启软件后才能生效。",

View File

@ -2,12 +2,11 @@ import { defineStore } from 'pinia'
const systemTheme = (key, value) => {
if (key === 'change') {
window.electron.ipcRenderer.on('app-theme-change', (_, ...args) =>
return window.electron.ipcRenderer.on('app-theme-change', (_, ...args) =>
value(...args),
)
return
}
window.electron.ipcRenderer.invoke(`app-theme-${key}`, value)
return window.electron.ipcRenderer.invoke(`app-theme-${key}`, value)
}
export const useThemeStore = defineStore({
@ -55,9 +54,9 @@ export const useThemeStore = defineStore({
/** 监听系统主题色变化 */
systemTheme('change', ({ value }) => {
// console.log('systemTheme.change.value', value)
console.log('systemTheme.change.value', value)
const themeStore = useThemeStore()
if (value !== themeStore.value) {
if (value === 'system') {
themeStore.update(value)
}
})