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"
}
*/
const getProfile: (loading?: Ref<boolean>) => Promise<any> = (loading) => {
const getAppProfile: (loading?: Ref<boolean>) => Promise<any> = (loading) => {
return get(`${prefix}/profile`, undefined, loading)
}
@ -263,7 +263,7 @@ export default {
getAccessToken,
putAccessToken,
postAppAuthentication,
getProfile,
getAppProfile,
putChatVote,
getApplicationHitTest,
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)
}
@ -155,6 +155,6 @@ export default {
resetCurrentUserPassword,
logout,
getUserList,
getVersion,
getProfile,
getValid
}

View File

@ -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()
})
},

View File

@ -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
})

View File

@ -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)

View File

@ -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)