From df63381413f9127ccea027e717525f956bafe390 Mon Sep 17 00:00:00 2001 From: tiny-craft <137850705+tiny-craft@users.noreply.github.com> Date: Mon, 28 Aug 2023 11:56:51 +0800 Subject: [PATCH] pref: add locale auto switch for components of naive ui --- frontend/src/App.vue | 1 + frontend/src/components/content/ContentLogPane.vue | 2 +- frontend/src/stores/preferences.js | 12 +++++++++++- 3 files changed, 13 insertions(+), 2 deletions(-) diff --git a/frontend/src/App.vue b/frontend/src/App.vue index 9090610..7ebeb41 100644 --- a/frontend/src/App.vue +++ b/frontend/src/App.vue @@ -59,6 +59,7 @@ watch( :inline-theme-disabled="true" :theme="prefStore.isDark ? darkTheme : undefined" :theme-overrides="themeOverrides" + :locale="prefStore.themeLocale" class="fill-height"> diff --git a/frontend/src/components/content/ContentLogPane.vue b/frontend/src/components/content/ContentLogPane.vue index d4ac8f8..3701949 100644 --- a/frontend/src/components/content/ContentLogPane.vue +++ b/frontend/src/components/content/ContentLogPane.vue @@ -64,7 +64,7 @@ defineExpose({ - + diff --git a/frontend/src/stores/preferences.js b/frontend/src/stores/preferences.js index 34289e4..bf5c05a 100644 --- a/frontend/src/stores/preferences.js +++ b/frontend/src/stores/preferences.js @@ -10,7 +10,7 @@ import { } from 'wailsjs/go/services/preferencesService.js' import { BrowserOpenURL } from 'wailsjs/runtime/runtime.js' import { i18nGlobal } from '@/utils/i18n.js' -import { useOsTheme } from 'naive-ui' +import { zhCN, enUS, useOsTheme } from 'naive-ui' const osTheme = useOsTheme() const usePreferencesStore = defineStore('preferences', { @@ -142,6 +142,16 @@ const usePreferencesStore = defineStore('preferences', { } }, + themeLocale() { + const lang = this.currentLanguage + switch (lang) { + case 'zh': + return zhCN + default: + return enUS + } + }, + autoCheckUpdate() { return get(this.general, 'checkUpdate', false) },