fix: language
This commit is contained in:
parent
c2767addd2
commit
246123c506
@ -2,25 +2,12 @@ import { defineStore } from 'pinia'
|
|||||||
import applicationApi from '@/api/application/application'
|
import applicationApi from '@/api/application/application'
|
||||||
import applicationXpackApi from '@/api/application/application-xpack'
|
import applicationXpackApi from '@/api/application/application-xpack'
|
||||||
import { type Ref } from 'vue'
|
import { type Ref } from 'vue'
|
||||||
import { getBrowserLang } from '@/locales/index'
|
|
||||||
import useUserStore from './user'
|
import useUserStore from './user'
|
||||||
const useApplicationStore = defineStore('application', {
|
const useApplicationStore = defineStore('application', {
|
||||||
state: () => ({
|
state: () => ({
|
||||||
location: `${window.location.origin}${window.MaxKB.chatPrefix}/`,
|
location: `${window.location.origin}${window.MaxKB.chatPrefix}/`,
|
||||||
}),
|
}),
|
||||||
actions: {
|
actions: {
|
||||||
async asyncGetAllApplication() {
|
|
||||||
return new Promise((resolve, reject) => {
|
|
||||||
// applicationApi
|
|
||||||
// .getAllAppilcation()
|
|
||||||
// .then((data) => {
|
|
||||||
// resolve(data)
|
|
||||||
// })
|
|
||||||
// .catch((error) => {
|
|
||||||
// reject(error)
|
|
||||||
// })
|
|
||||||
})
|
|
||||||
},
|
|
||||||
|
|
||||||
async asyncGetApplicationDetail(id: string, loading?: Ref<boolean>) {
|
async asyncGetApplicationDetail(id: string, loading?: Ref<boolean>) {
|
||||||
return new Promise((resolve, reject) => {
|
return new Promise((resolve, reject) => {
|
||||||
@ -60,21 +47,6 @@ const useApplicationStore = defineStore('application', {
|
|||||||
})
|
})
|
||||||
},
|
},
|
||||||
|
|
||||||
async asyncGetAppProfile(loading?: Ref<boolean>) {
|
|
||||||
return new Promise((resolve, reject) => {
|
|
||||||
console.log('xxxx')
|
|
||||||
applicationApi
|
|
||||||
.getAppProfile(loading)
|
|
||||||
.then((res: any) => {
|
|
||||||
sessionStorage.setItem('language', res.data?.language || getBrowserLang())
|
|
||||||
resolve(res)
|
|
||||||
})
|
|
||||||
.catch((error: any) => {
|
|
||||||
reject(error)
|
|
||||||
})
|
|
||||||
})
|
|
||||||
},
|
|
||||||
|
|
||||||
async asyncAppAuthentication(
|
async asyncAppAuthentication(
|
||||||
token: string,
|
token: string,
|
||||||
loading?: Ref<boolean>,
|
loading?: Ref<boolean>,
|
||||||
@ -109,18 +81,6 @@ const useApplicationStore = defineStore('application', {
|
|||||||
})
|
})
|
||||||
})
|
})
|
||||||
},
|
},
|
||||||
async validatePassword(id: string, password: string, loading?: Ref<boolean>) {
|
|
||||||
return new Promise((resolve, reject) => {
|
|
||||||
// applicationApi
|
|
||||||
// .validatePassword(id, password, loading)
|
|
||||||
// .then((data) => {
|
|
||||||
// resolve(data)
|
|
||||||
// })
|
|
||||||
// .catch((error) => {
|
|
||||||
// reject(error)
|
|
||||||
// })
|
|
||||||
})
|
|
||||||
},
|
|
||||||
},
|
},
|
||||||
})
|
})
|
||||||
|
|
||||||
|
|||||||
@ -3,6 +3,9 @@ import ChatAPI from '@/api/chat/chat'
|
|||||||
import type { ChatProfile, ChatUserProfile } from '@/api/type/chat'
|
import type { ChatProfile, ChatUserProfile } from '@/api/type/chat'
|
||||||
import type { LoginRequest } from '@/api/type/user'
|
import type { LoginRequest } from '@/api/type/user'
|
||||||
import type { Ref } from 'vue'
|
import type { Ref } from 'vue'
|
||||||
|
import { useLocalStorage } from '@vueuse/core'
|
||||||
|
import { localeConfigKey } from '@/locales/index'
|
||||||
|
import useUserStore from './user'
|
||||||
interface ChatUser {
|
interface ChatUser {
|
||||||
// 用户id
|
// 用户id
|
||||||
id: string
|
id: string
|
||||||
@ -38,6 +41,9 @@ const useChatUserStore = defineStore('chat-user', {
|
|||||||
applicationProfile() {
|
applicationProfile() {
|
||||||
return ChatAPI.applicationProfile().then((ok) => {
|
return ChatAPI.applicationProfile().then((ok) => {
|
||||||
this.application = ok.data
|
this.application = ok.data
|
||||||
|
const user = useUserStore()
|
||||||
|
useLocalStorage<string>(localeConfigKey, 'en-US').value =
|
||||||
|
ok?.data?.language || user.getLanguage()
|
||||||
if (this.application.custom_theme) {
|
if (this.application.custom_theme) {
|
||||||
this.application['custom_theme']['theme_color'] =
|
this.application['custom_theme']['theme_color'] =
|
||||||
ok.data?.custom_theme?.theme_color || '#3370FF'
|
ok.data?.custom_theme?.theme_color || '#3370FF'
|
||||||
|
|||||||
@ -26,11 +26,6 @@ const useThemeStore = defineStore('theme', {
|
|||||||
async theme(loading?: Ref<boolean>) {
|
async theme(loading?: Ref<boolean>) {
|
||||||
return await ThemeApi.getThemeInfo(loading).then((ok) => {
|
return await ThemeApi.getThemeInfo(loading).then((ok) => {
|
||||||
this.setTheme(ok.data)
|
this.setTheme(ok.data)
|
||||||
// window.document.title = this.themeInfo['title'] || 'MaxKB'
|
|
||||||
// const link = document.querySelector('link[rel="icon"]') as any
|
|
||||||
// if (link) {
|
|
||||||
// link['href'] = this.themeInfo['icon'] || '/favicon.ico'
|
|
||||||
// }
|
|
||||||
})
|
})
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
|
|||||||
@ -99,12 +99,6 @@ const useUserStore = defineStore('user', {
|
|||||||
getEditionName() {
|
getEditionName() {
|
||||||
return this.edition
|
return this.edition
|
||||||
},
|
},
|
||||||
changeUserType(num: number, token?: string) {
|
|
||||||
this.userType = num
|
|
||||||
const login = useLoginStore()
|
|
||||||
login.userAccessToken = token || ''
|
|
||||||
},
|
|
||||||
|
|
||||||
async profile(loading?: Ref<boolean>) {
|
async profile(loading?: Ref<boolean>) {
|
||||||
return UserApi.getUserProfile(loading).then((ok) => {
|
return UserApi.getUserProfile(loading).then((ok) => {
|
||||||
this.userInfo = ok.data
|
this.userInfo = ok.data
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user