From e5e68ed8a8d1cba1786a1a44b7c2b765f4beebb7 Mon Sep 17 00:00:00 2001 From: wangdan-fit2cloud Date: Thu, 21 Mar 2024 16:26:03 +0800 Subject: [PATCH] =?UTF-8?q?feat:=20=E7=89=88=E6=9C=AC=E5=8F=B7=E4=BF=A1?= =?UTF-8?q?=E6=81=AF?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- ui/src/api/user.ts | 10 +++++++++- ui/src/stores/modules/user.ts | 12 +++++++++++- 2 files changed, 20 insertions(+), 2 deletions(-) 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() }) },