Skip to content

Commit

Permalink
fix: 🐛 修复设置主题跟随系统后没有生效的问题
Browse files Browse the repository at this point in the history
  • Loading branch information
viarotel committed Oct 28, 2023
1 parent eff127a commit 95a83f4
Show file tree
Hide file tree
Showing 5 changed files with 8 additions and 8 deletions.
2 changes: 1 addition & 1 deletion src/components/Preference/LanguageSelect/index.vue
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down
1 change: 1 addition & 0 deletions src/components/Preference/index.vue
Original file line number Diff line number Diff line change
Expand Up @@ -178,6 +178,7 @@
>
</el-option>
</el-select>

<component
:is="item_1.type"
v-else
Expand Down
2 changes: 1 addition & 1 deletion src/locales/languages/en_US.json
Original file line number Diff line number Diff line change
Expand Up @@ -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.",
Expand Down
2 changes: 1 addition & 1 deletion src/locales/languages/zh_CN.json
Original file line number Diff line number Diff line change
Expand Up @@ -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": "启用后可以在运行日志中查看软件运行情况,一般不需要开启可能会影响性能,注意: 改变此选项需要重启软件后才能生效。",
Expand Down
9 changes: 4 additions & 5 deletions src/store/theme/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -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({
Expand Down Expand Up @@ -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)
}
})

0 comments on commit 95a83f4

Please sign in to comment.