fix: language

This commit is contained in:
wangdan-fit2cloud 2025-07-08 16:17:07 +08:00
parent c2767addd2
commit 246123c506
4 changed files with 6 additions and 51 deletions

View File

@ -2,25 +2,12 @@ import { defineStore } from 'pinia'
import applicationApi from '@/api/application/application'
import applicationXpackApi from '@/api/application/application-xpack'
import { type Ref } from 'vue'
import { getBrowserLang } from '@/locales/index'
import useUserStore from './user'
const useApplicationStore = defineStore('application', {
state: () => ({
location: `${window.location.origin}${window.MaxKB.chatPrefix}/`,
}),
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>) {
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(
token: string,
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)
// })
})
},
},
})

View File

@ -3,6 +3,9 @@ import ChatAPI from '@/api/chat/chat'
import type { ChatProfile, ChatUserProfile } from '@/api/type/chat'
import type { LoginRequest } from '@/api/type/user'
import type { Ref } from 'vue'
import { useLocalStorage } from '@vueuse/core'
import { localeConfigKey } from '@/locales/index'
import useUserStore from './user'
interface ChatUser {
// 用户id
id: string
@ -38,6 +41,9 @@ const useChatUserStore = defineStore('chat-user', {
applicationProfile() {
return ChatAPI.applicationProfile().then((ok) => {
this.application = ok.data
const user = useUserStore()
useLocalStorage<string>(localeConfigKey, 'en-US').value =
ok?.data?.language || user.getLanguage()
if (this.application.custom_theme) {
this.application['custom_theme']['theme_color'] =
ok.data?.custom_theme?.theme_color || '#3370FF'

View File

@ -26,11 +26,6 @@ const useThemeStore = defineStore('theme', {
async theme(loading?: Ref<boolean>) {
return await ThemeApi.getThemeInfo(loading).then((ok) => {
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'
// }
})
},
},

View File

@ -99,12 +99,6 @@ const useUserStore = defineStore('user', {
getEditionName() {
return this.edition
},
changeUserType(num: number, token?: string) {
this.userType = num
const login = useLoginStore()
login.userAccessToken = token || ''
},
async profile(loading?: Ref<boolean>) {
return UserApi.getUserProfile(loading).then((ok) => {
this.userInfo = ok.data