From 8994ac4b20fd7eefc7628c7f18c3f7ac106e4fe1 Mon Sep 17 00:00:00 2001 From: wangdan-fit2cloud Date: Thu, 11 Jul 2024 18:28:01 +0800 Subject: [PATCH] =?UTF-8?q?perf:=20=E4=BC=98=E5=8C=96=E6=8E=A5=E5=8F=A3?= =?UTF-8?q?=E6=96=87=E4=BB=B6?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- ui/src/api/application.ts | 4 ++-- ui/src/api/user.ts | 6 +++--- ui/src/stores/modules/user.ts | 19 +++++++++++++------ ui/src/views/chat/base/index.vue | 6 +++--- ui/src/views/chat/embed/index.vue | 6 +++--- ui/src/views/chat/pc/index.vue | 6 +++--- 6 files changed, 27 insertions(+), 20 deletions(-) diff --git a/ui/src/api/application.ts b/ui/src/api/application.ts index f37f67937..3aa7c29b1 100644 --- a/ui/src/api/application.ts +++ b/ui/src/api/application.ts @@ -135,7 +135,7 @@ const postAppAuthentication: (access_token: string, loading?: Ref) => P "access_token": "string" } */ -const getProfile: (loading?: Ref) => Promise = (loading) => { +const getAppProfile: (loading?: Ref) => Promise = (loading) => { return get(`${prefix}/profile`, undefined, loading) } @@ -263,7 +263,7 @@ export default { getAccessToken, putAccessToken, postAppAuthentication, - getProfile, + getAppProfile, putChatVote, getApplicationHitTest, getApplicationModel, diff --git a/ui/src/api/user.ts b/ui/src/api/user.ts index d162d46e6..c345c3381 100644 --- a/ui/src/api/user.ts +++ b/ui/src/api/user.ts @@ -125,9 +125,9 @@ const getUserList: (email_or_username: string, loading?: Ref) => Promis } /** - * 获取version + * 获取profile */ -const getVersion: (loading?: Ref) => Promise> = (loading) => { +const getProfile: (loading?: Ref) => Promise> = (loading) => { return get('/profile', undefined, loading) } @@ -155,6 +155,6 @@ export default { resetCurrentUserPassword, logout, getUserList, - getVersion, + getProfile, getValid } diff --git a/ui/src/stores/modules/user.ts b/ui/src/stores/modules/user.ts index e62e325df..61817feee 100644 --- a/ui/src/stores/modules/user.ts +++ b/ui/src/stores/modules/user.ts @@ -63,18 +63,25 @@ const useUserStore = defineStore({ this.userType = num }, - async asyncGetVersion() { - return UserApi.getVersion().then((ok) => { - this.version = ok.data?.version || '-' - this.isXPack = ok.data?.IS_XPACK - this.XPACK_LICENSE_IS_VALID = ok.data?.XPACK_LICENSE_IS_VALID + async asyncGetProfile() { + return new Promise((resolve, reject) => { + UserApi.getProfile() + .then((ok) => { + this.version = ok.data?.version || '-' + this.isXPack = ok.data?.IS_XPACK + this.XPACK_LICENSE_IS_VALID = ok.data?.XPACK_LICENSE_IS_VALID + resolve(ok) + }) + .catch((error) => { + reject(error) + }) }) }, async profile() { return UserApi.profile().then((ok) => { this.userInfo = ok.data - this.asyncGetVersion() + this.asyncGetProfile() }) }, diff --git a/ui/src/views/chat/base/index.vue b/ui/src/views/chat/base/index.vue index 0c8145a02..91027dedf 100644 --- a/ui/src/views/chat/base/index.vue +++ b/ui/src/views/chat/base/index.vue @@ -35,15 +35,15 @@ function getAccessToken(token: string) { application .asyncAppAuthentication(token, loading) .then(() => { - getProfile() + getAppProfile() }) .catch(() => { applicationAvailable.value = false }) } -function getProfile() { +function getAppProfile() { applicationApi - .getProfile(loading) + .getAppProfile(loading) .then((res) => { applicationDetail.value = res.data }) diff --git a/ui/src/views/chat/embed/index.vue b/ui/src/views/chat/embed/index.vue index 7747a00fd..583f85be1 100644 --- a/ui/src/views/chat/embed/index.vue +++ b/ui/src/views/chat/embed/index.vue @@ -148,15 +148,15 @@ function getAccessToken(token: string) { application .asyncAppAuthentication(token, loading) .then(() => { - getProfile() + getAppProfile() }) .catch(() => { applicationAvailable.value = false }) } -function getProfile() { +function getAppProfile() { applicationApi - .getProfile(loading) + .getAppProfile(loading) .then((res) => { applicationDetail.value = res.data getChatLog(applicationDetail.value.id) diff --git a/ui/src/views/chat/pc/index.vue b/ui/src/views/chat/pc/index.vue index cf2c4538d..994287f5a 100644 --- a/ui/src/views/chat/pc/index.vue +++ b/ui/src/views/chat/pc/index.vue @@ -189,16 +189,16 @@ function getAccessToken(token: string) { application .asyncAppAuthentication(token, loading) .then(() => { - getProfile() + getAppProfile() }) .catch(() => { applicationAvailable.value = false }) } -function getProfile() { +function getAppProfile() { applicationApi - .getProfile(loading) + .getAppProfile(loading) .then((res) => { applicationDetail.value = res.data getChatLog(applicationDetail.value.id)