diff --git a/ui/src/locales/lang/en-US/components/ai-chat.ts b/ui/src/locales/lang/en-US/components/ai-chat.ts new file mode 100644 index 000000000..a3365e4b8 --- /dev/null +++ b/ui/src/locales/lang/en-US/components/ai-chat.ts @@ -0,0 +1,4 @@ +export default { + createChat: 'Create Chat', + history: 'History record' +} diff --git a/ui/src/locales/lang/en-US/components/index.ts b/ui/src/locales/lang/en-US/components/index.ts index bd77588db..a81c8b467 100644 --- a/ui/src/locales/lang/en-US/components/index.ts +++ b/ui/src/locales/lang/en-US/components/index.ts @@ -1,4 +1,4 @@ - +import chat from './ai-chat' export default { - -}; + chat, +} \ No newline at end of file diff --git a/ui/src/stores/modules/application.ts b/ui/src/stores/modules/application.ts index 359f952b5..3d30e62dd 100644 --- a/ui/src/stores/modules/application.ts +++ b/ui/src/stores/modules/application.ts @@ -4,12 +4,10 @@ import applicationXpackApi from '@/api/application-xpack' import { type Ref } from 'vue' import useUserStore from './user' - const useApplicationStore = defineStore({ id: 'application', state: () => ({ - location: `${window.location.origin}/ui/chat/`, - userLanguage: '' + location: `${window.location.origin}/ui/chat/` }), actions: { async asyncGetAllApplication() { @@ -80,9 +78,10 @@ const useApplicationStore = defineStore({ return new Promise((resolve, reject) => { applicationApi .getAppProfile(loading) - .then((data) => { - this.userLanguage = data.data?.language - resolve(data) + .then((res) => { + sessionStorage.setItem('language', res.data?.language) + + resolve(res) }) .catch((error) => { reject(error) diff --git a/ui/src/stores/modules/user.ts b/ui/src/stores/modules/user.ts index 5a47600a7..4b739d170 100644 --- a/ui/src/stores/modules/user.ts +++ b/ui/src/stores/modules/user.ts @@ -33,10 +33,9 @@ const useUserStore = defineStore({ }), actions: { getLanguage() { - const application = useApplicationStore() return this.userType === 1 - ? this.userInfo?.language || localStorage.getItem('MaxKB-locale') - : application?.userLanguage + ? localStorage.getItem('MaxKB-locale') + : sessionStorage.getItem('language') }, showXpack() { return this.isXPack diff --git a/ui/src/views/chat/index.vue b/ui/src/views/chat/index.vue index 36b8e4473..89bff9b06 100644 --- a/ui/src/views/chat/index.vue +++ b/ui/src/views/chat/index.vue @@ -24,6 +24,8 @@ import { useRoute } from 'vue-router' import useStore from '@/stores' import Auth from '@/views/chat/auth/index.vue' import { hexToRgba } from '@/utils/theme' +import { useI18n } from 'vue-i18n' +const { locale } = useI18n({ useScope: 'global' }) const route = useRoute() const { application, user } = useStore() @@ -78,6 +80,7 @@ const init_data_end = ref(false) const applicationAvailable = ref(true) function getAppProfile() { return application.asyncGetAppProfile(loading).then((res: any) => { + locale.value = res.data?.language show_history.value = res.data?.show_history application_profile.value = res.data })