Skip to content

Commit 246123c

Browse files
fix: language
1 parent c2767ad commit 246123c

File tree

4 files changed

+6
-51
lines changed

4 files changed

+6
-51
lines changed

ui/src/stores/modules/application.ts

Lines changed: 0 additions & 40 deletions
Original file line numberDiff line numberDiff line change
@@ -2,25 +2,12 @@ import { defineStore } from 'pinia'
22
import applicationApi from '@/api/application/application'
33
import applicationXpackApi from '@/api/application/application-xpack'
44
import { type Ref } from 'vue'
5-
import { getBrowserLang } from '@/locales/index'
65
import useUserStore from './user'
76
const useApplicationStore = defineStore('application', {
87
state: () => ({
98
location: `${window.location.origin}${window.MaxKB.chatPrefix}/`,
109
}),
1110
actions: {
12-
async asyncGetAllApplication() {
13-
return new Promise((resolve, reject) => {
14-
// applicationApi
15-
// .getAllAppilcation()
16-
// .then((data) => {
17-
// resolve(data)
18-
// })
19-
// .catch((error) => {
20-
// reject(error)
21-
// })
22-
})
23-
},
2411

2512
async asyncGetApplicationDetail(id: string, loading?: Ref<boolean>) {
2613
return new Promise((resolve, reject) => {
@@ -60,21 +47,6 @@ const useApplicationStore = defineStore('application', {
6047
})
6148
},
6249

63-
async asyncGetAppProfile(loading?: Ref<boolean>) {
64-
return new Promise((resolve, reject) => {
65-
console.log('xxxx')
66-
applicationApi
67-
.getAppProfile(loading)
68-
.then((res: any) => {
69-
sessionStorage.setItem('language', res.data?.language || getBrowserLang())
70-
resolve(res)
71-
})
72-
.catch((error: any) => {
73-
reject(error)
74-
})
75-
})
76-
},
77-
7850
async asyncAppAuthentication(
7951
token: string,
8052
loading?: Ref<boolean>,
@@ -109,18 +81,6 @@ const useApplicationStore = defineStore('application', {
10981
})
11082
})
11183
},
112-
async validatePassword(id: string, password: string, loading?: Ref<boolean>) {
113-
return new Promise((resolve, reject) => {
114-
// applicationApi
115-
// .validatePassword(id, password, loading)
116-
// .then((data) => {
117-
// resolve(data)
118-
// })
119-
// .catch((error) => {
120-
// reject(error)
121-
// })
122-
})
123-
},
12484
},
12585
})
12686

ui/src/stores/modules/chat-user.ts

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,9 @@ import ChatAPI from '@/api/chat/chat'
33
import type { ChatProfile, ChatUserProfile } from '@/api/type/chat'
44
import type { LoginRequest } from '@/api/type/user'
55
import type { Ref } from 'vue'
6+
import { useLocalStorage } from '@vueuse/core'
7+
import { localeConfigKey } from '@/locales/index'
8+
import useUserStore from './user'
69
interface ChatUser {
710
// 用户id
811
id: string
@@ -38,6 +41,9 @@ const useChatUserStore = defineStore('chat-user', {
3841
applicationProfile() {
3942
return ChatAPI.applicationProfile().then((ok) => {
4043
this.application = ok.data
44+
const user = useUserStore()
45+
useLocalStorage<string>(localeConfigKey, 'en-US').value =
46+
ok?.data?.language || user.getLanguage()
4147
if (this.application.custom_theme) {
4248
this.application['custom_theme']['theme_color'] =
4349
ok.data?.custom_theme?.theme_color || '#3370FF'

ui/src/stores/modules/theme.ts

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -26,11 +26,6 @@ const useThemeStore = defineStore('theme', {
2626
async theme(loading?: Ref<boolean>) {
2727
return await ThemeApi.getThemeInfo(loading).then((ok) => {
2828
this.setTheme(ok.data)
29-
// window.document.title = this.themeInfo['title'] || 'MaxKB'
30-
// const link = document.querySelector('link[rel="icon"]') as any
31-
// if (link) {
32-
// link['href'] = this.themeInfo['icon'] || '/favicon.ico'
33-
// }
3429
})
3530
},
3631
},

ui/src/stores/modules/user.ts

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -99,12 +99,6 @@ const useUserStore = defineStore('user', {
9999
getEditionName() {
100100
return this.edition
101101
},
102-
changeUserType(num: number, token?: string) {
103-
this.userType = num
104-
const login = useLoginStore()
105-
login.userAccessToken = token || ''
106-
},
107-
108102
async profile(loading?: Ref<boolean>) {
109103
return UserApi.getUserProfile(loading).then((ok) => {
110104
this.userInfo = ok.data

0 commit comments

Comments
 (0)