feat: i18n
This commit is contained in:
parent
9e5352b8d7
commit
059ffc1b01
4
ui/src/locales/lang/en-US/components/ai-chat.ts
Normal file
4
ui/src/locales/lang/en-US/components/ai-chat.ts
Normal file
@ -0,0 +1,4 @@
|
|||||||
|
export default {
|
||||||
|
createChat: 'Create Chat',
|
||||||
|
history: 'History record'
|
||||||
|
}
|
||||||
@ -1,4 +1,4 @@
|
|||||||
|
import chat from './ai-chat'
|
||||||
export default {
|
export default {
|
||||||
|
chat,
|
||||||
};
|
}
|
||||||
@ -4,12 +4,10 @@ import applicationXpackApi from '@/api/application-xpack'
|
|||||||
import { type Ref } from 'vue'
|
import { type Ref } from 'vue'
|
||||||
|
|
||||||
import useUserStore from './user'
|
import useUserStore from './user'
|
||||||
|
|
||||||
const useApplicationStore = defineStore({
|
const useApplicationStore = defineStore({
|
||||||
id: 'application',
|
id: 'application',
|
||||||
state: () => ({
|
state: () => ({
|
||||||
location: `${window.location.origin}/ui/chat/`,
|
location: `${window.location.origin}/ui/chat/`
|
||||||
userLanguage: ''
|
|
||||||
}),
|
}),
|
||||||
actions: {
|
actions: {
|
||||||
async asyncGetAllApplication() {
|
async asyncGetAllApplication() {
|
||||||
@ -80,9 +78,10 @@ const useApplicationStore = defineStore({
|
|||||||
return new Promise((resolve, reject) => {
|
return new Promise((resolve, reject) => {
|
||||||
applicationApi
|
applicationApi
|
||||||
.getAppProfile(loading)
|
.getAppProfile(loading)
|
||||||
.then((data) => {
|
.then((res) => {
|
||||||
this.userLanguage = data.data?.language
|
sessionStorage.setItem('language', res.data?.language)
|
||||||
resolve(data)
|
|
||||||
|
resolve(res)
|
||||||
})
|
})
|
||||||
.catch((error) => {
|
.catch((error) => {
|
||||||
reject(error)
|
reject(error)
|
||||||
|
|||||||
@ -33,10 +33,9 @@ const useUserStore = defineStore({
|
|||||||
}),
|
}),
|
||||||
actions: {
|
actions: {
|
||||||
getLanguage() {
|
getLanguage() {
|
||||||
const application = useApplicationStore()
|
|
||||||
return this.userType === 1
|
return this.userType === 1
|
||||||
? this.userInfo?.language || localStorage.getItem('MaxKB-locale')
|
? localStorage.getItem('MaxKB-locale')
|
||||||
: application?.userLanguage
|
: sessionStorage.getItem('language')
|
||||||
},
|
},
|
||||||
showXpack() {
|
showXpack() {
|
||||||
return this.isXPack
|
return this.isXPack
|
||||||
|
|||||||
@ -24,6 +24,8 @@ import { useRoute } from 'vue-router'
|
|||||||
import useStore from '@/stores'
|
import useStore from '@/stores'
|
||||||
import Auth from '@/views/chat/auth/index.vue'
|
import Auth from '@/views/chat/auth/index.vue'
|
||||||
import { hexToRgba } from '@/utils/theme'
|
import { hexToRgba } from '@/utils/theme'
|
||||||
|
import { useI18n } from 'vue-i18n'
|
||||||
|
const { locale } = useI18n({ useScope: 'global' })
|
||||||
const route = useRoute()
|
const route = useRoute()
|
||||||
const { application, user } = useStore()
|
const { application, user } = useStore()
|
||||||
|
|
||||||
@ -78,6 +80,7 @@ const init_data_end = ref<boolean>(false)
|
|||||||
const applicationAvailable = ref<boolean>(true)
|
const applicationAvailable = ref<boolean>(true)
|
||||||
function getAppProfile() {
|
function getAppProfile() {
|
||||||
return application.asyncGetAppProfile(loading).then((res: any) => {
|
return application.asyncGetAppProfile(loading).then((res: any) => {
|
||||||
|
locale.value = res.data?.language
|
||||||
show_history.value = res.data?.show_history
|
show_history.value = res.data?.show_history
|
||||||
application_profile.value = res.data
|
application_profile.value = res.data
|
||||||
})
|
})
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user