@@ -4,16 +4,17 @@ import { error } from '@tauri-apps/plugin-log'
44import { openUrl } from ' @tauri-apps/plugin-opener'
55import { useEventListener } from ' @vueuse/core'
66import { ConfigProvider , theme } from ' ant-design-vue'
7- import zhCN from ' ant-design-vue/es/locale/zh_CN'
87import { isString } from ' es-toolkit'
98import isURL from ' is-url'
10- import { onMounted } from ' vue'
9+ import { onMounted , watch } from ' vue'
10+ import { useI18n } from ' vue-i18n'
1111import { RouterView } from ' vue-router'
1212
1313import { useTauriListen } from ' ./composables/useTauriListen'
1414import { useThemeVars } from ' ./composables/useThemeVars'
1515import { useWindowState } from ' ./composables/useWindowState'
16- import { LISTEN_KEY } from ' ./constants'
16+ import { LANGUAGE , LISTEN_KEY } from ' ./constants'
17+ import { getAntdLocale } from ' ./locales/index.ts'
1718import { hideWindow , showWindow } from ' ./plugins/window'
1819import { useAppStore } from ' ./stores/app'
1920import { useCatStore } from ' ./stores/cat'
@@ -30,6 +31,7 @@ const shortcutStore = useShortcutStore()
3031const appWindow = getCurrentWebviewWindow ()
3132const { isRestored, restoreState } = useWindowState ()
3233const { darkAlgorithm, defaultAlgorithm } = theme
34+ const { locale } = useI18n ()
3335
3436onMounted (async () => {
3537 generateColorVars ()
@@ -39,10 +41,15 @@ onMounted(async () => {
3941 await modelStore .$tauri .start ()
4042 await modelStore .init ()
4143 await catStore .$tauri .start ()
44+ catStore .init ()
4245 await generalStore .$tauri .start ()
46+ await generalStore .init ()
4347 await shortcutStore .$tauri .start ()
4448 await restoreState ()
45- catStore .init ()
49+ })
50+
51+ watch (() => generalStore .appearance .language , (value ) => {
52+ locale .value = value ?? LANGUAGE .EN_US
4653})
4754
4855useTauriListen (LISTEN_KEY .SHOW_WINDOW , ({ payload }) => {
@@ -82,7 +89,7 @@ useEventListener('click', (event) => {
8289
8390<template >
8491 <ConfigProvider
85- :locale =" zhCN "
92+ :locale =" getAntdLocale ( generalStore . appearance . language ) "
8693 :theme =" {
8794 algorithm: generalStore .appearance .isDark ? darkAlgorithm : defaultAlgorithm ,
8895 } "
0 commit comments