mirror of
https://github.com/1Panel-dev/MaxKB.git
synced 2025-12-25 17:22:55 +00:00
feat: i18n
This commit is contained in:
parent
9e5352b8d7
commit
059ffc1b01
|
|
@ -0,0 +1,4 @@
|
|||
export default {
|
||||
createChat: 'Create Chat',
|
||||
history: 'History record'
|
||||
}
|
||||
|
|
@ -1,4 +1,4 @@
|
|||
|
||||
import chat from './ai-chat'
|
||||
export default {
|
||||
|
||||
};
|
||||
chat,
|
||||
}
|
||||
|
|
@ -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)
|
||||
|
|
|
|||
|
|
@ -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
|
||||
|
|
|
|||
|
|
@ -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<boolean>(false)
|
|||
const applicationAvailable = ref<boolean>(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
|
||||
})
|
||||
|
|
|
|||
Loading…
Reference in New Issue