perf: 优化接口文件

This commit is contained in:
wangdan-fit2cloud 2024-07-11 18:28:01 +08:00
parent 475ff183ac
commit 8994ac4b20
6 changed files with 27 additions and 20 deletions

View File

@ -135,7 +135,7 @@ const postAppAuthentication: (access_token: string, loading?: Ref<boolean>) => P
"access_token": "string" "access_token": "string"
} }
*/ */
const getProfile: (loading?: Ref<boolean>) => Promise<any> = (loading) => { const getAppProfile: (loading?: Ref<boolean>) => Promise<any> = (loading) => {
return get(`${prefix}/profile`, undefined, loading) return get(`${prefix}/profile`, undefined, loading)
} }
@ -263,7 +263,7 @@ export default {
getAccessToken, getAccessToken,
putAccessToken, putAccessToken,
postAppAuthentication, postAppAuthentication,
getProfile, getAppProfile,
putChatVote, putChatVote,
getApplicationHitTest, getApplicationHitTest,
getApplicationModel, getApplicationModel,

View File

@ -125,9 +125,9 @@ const getUserList: (email_or_username: string, loading?: Ref<boolean>) => Promis
} }
/** /**
* version * profile
*/ */
const getVersion: (loading?: Ref<boolean>) => Promise<Result<any>> = (loading) => { const getProfile: (loading?: Ref<boolean>) => Promise<Result<any>> = (loading) => {
return get('/profile', undefined, loading) return get('/profile', undefined, loading)
} }
@ -155,6 +155,6 @@ export default {
resetCurrentUserPassword, resetCurrentUserPassword,
logout, logout,
getUserList, getUserList,
getVersion, getProfile,
getValid getValid
} }

View File

@ -63,18 +63,25 @@ const useUserStore = defineStore({
this.userType = num this.userType = num
}, },
async asyncGetVersion() { async asyncGetProfile() {
return UserApi.getVersion().then((ok) => { return new Promise((resolve, reject) => {
this.version = ok.data?.version || '-' UserApi.getProfile()
this.isXPack = ok.data?.IS_XPACK .then((ok) => {
this.XPACK_LICENSE_IS_VALID = ok.data?.XPACK_LICENSE_IS_VALID 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() { async profile() {
return UserApi.profile().then((ok) => { return UserApi.profile().then((ok) => {
this.userInfo = ok.data this.userInfo = ok.data
this.asyncGetVersion() this.asyncGetProfile()
}) })
}, },

View File

@ -35,15 +35,15 @@ function getAccessToken(token: string) {
application application
.asyncAppAuthentication(token, loading) .asyncAppAuthentication(token, loading)
.then(() => { .then(() => {
getProfile() getAppProfile()
}) })
.catch(() => { .catch(() => {
applicationAvailable.value = false applicationAvailable.value = false
}) })
} }
function getProfile() { function getAppProfile() {
applicationApi applicationApi
.getProfile(loading) .getAppProfile(loading)
.then((res) => { .then((res) => {
applicationDetail.value = res.data applicationDetail.value = res.data
}) })

View File

@ -148,15 +148,15 @@ function getAccessToken(token: string) {
application application
.asyncAppAuthentication(token, loading) .asyncAppAuthentication(token, loading)
.then(() => { .then(() => {
getProfile() getAppProfile()
}) })
.catch(() => { .catch(() => {
applicationAvailable.value = false applicationAvailable.value = false
}) })
} }
function getProfile() { function getAppProfile() {
applicationApi applicationApi
.getProfile(loading) .getAppProfile(loading)
.then((res) => { .then((res) => {
applicationDetail.value = res.data applicationDetail.value = res.data
getChatLog(applicationDetail.value.id) getChatLog(applicationDetail.value.id)

View File

@ -189,16 +189,16 @@ function getAccessToken(token: string) {
application application
.asyncAppAuthentication(token, loading) .asyncAppAuthentication(token, loading)
.then(() => { .then(() => {
getProfile() getAppProfile()
}) })
.catch(() => { .catch(() => {
applicationAvailable.value = false applicationAvailable.value = false
}) })
} }
function getProfile() { function getAppProfile() {
applicationApi applicationApi
.getProfile(loading) .getAppProfile(loading)
.then((res) => { .then((res) => {
applicationDetail.value = res.data applicationDetail.value = res.data
getChatLog(applicationDetail.value.id) getChatLog(applicationDetail.value.id)