diff --git a/ui/src/api/user.ts b/ui/src/api/user.ts index 3dbe9211f..a49646d62 100644 --- a/ui/src/api/user.ts +++ b/ui/src/api/user.ts @@ -124,6 +124,13 @@ const getUserList: (email_or_username: string, loading?: Ref) => Promis return get('/user/list', { email_or_username }, loading) } +/** + * 获取version + */ +const getVersion: (loading?: Ref) => Promise> = (loading) => { + return get('/api/profile', undefined, loading) +} + export default { login, register, @@ -134,5 +141,6 @@ export default { sendEmailToCurrent, resetCurrentUserPassword, logout, - getUserList + getUserList, + getVersion } diff --git a/ui/src/stores/modules/user.ts b/ui/src/stores/modules/user.ts index ecdc07763..471542cc6 100644 --- a/ui/src/stores/modules/user.ts +++ b/ui/src/stores/modules/user.ts @@ -6,6 +6,7 @@ export interface userStateTypes { userType: number // 1 系统操作者 2 对话用户 userInfo: User | null token: any + version?: string } const useUserStore = defineStore({ @@ -13,7 +14,8 @@ const useUserStore = defineStore({ state: (): userStateTypes => ({ userType: 1, userInfo: null, - token: '' + token: '', + version: '' }), actions: { getToken(): String | null { @@ -42,9 +44,17 @@ const useUserStore = defineStore({ changeUserType(num: number) { this.userType = num }, + + async asyncGetVersion() { + return UserApi.getVersion().then((ok) => { + this.version = ok.data + }) + }, + async profile() { return UserApi.profile().then((ok) => { this.userInfo = ok.data + this.asyncGetVersion() }) },