perf(X-Pack): 导航栏组织切换器加载慢

This commit is contained in:
fit2cloud-chenyw 2024-07-12 17:36:17 +08:00
parent 72df84e837
commit 7c666b5301
3 changed files with 25 additions and 5 deletions

View File

@ -1,12 +1,13 @@
import { useCache } from '@/hooks/web/useCache'
import { refreshApi } from '@/api/login'
import { useUserStoreWithOut } from '@/store/modules/user'
import { useRequestStoreWithOut } from '@/store/modules/request'
import { isLink } from '@/utils/utils'
const { wsCache } = useCache()
const userStore = useUserStoreWithOut()
const requestStore = useRequestStoreWithOut()
const refreshUrl = '/login/refresh'
let cachedRequestList = []
const expConstants = 10000
@ -19,10 +20,15 @@ const isExpired = () => {
}
const delayExecute = (token: string) => {
const cachedRequestList = requestStore.getRequestList
cachedRequestList.forEach(cb => {
cb(token)
})
cachedRequestList = []
requestStore.cleanCacheRequest()
/* cachedRequestList.forEach(cb => {
cb(token)
})
cachedRequestList = [] */
}
const getRefreshStatus = () => {
@ -33,7 +39,8 @@ const setRefreshStatus = (status: boolean) => {
}
const cacheRequest = cb => {
cachedRequestList.push(cb)
requestStore.addCacheRequest(cb)
// cachedRequestList.push(cb)
}
export const configHandler = config => {

View File

@ -5,12 +5,19 @@ interface RequestState {
loadingMap: {
[key: string]: number
}
cachedRequestList: []
}
export const useRequestStore = defineStore('request', {
state: (): RequestState => {
return {
loadingMap: {}
loadingMap: {},
cachedRequestList: []
}
},
getters: {
getRequestList(): string {
return this.cachedRequestList
}
},
actions: {
@ -34,6 +41,12 @@ export const useRequestStore = defineStore('request', {
map[key] -= 1
this.loadingMap = map
}
},
addCacheRequest(fun) {
this.cachedRequestList.push(fun)
},
cleanCacheRequest() {
this.cachedRequestList = []
}
}
})

@ -1 +1 @@
Subproject commit fcf1317c371f3e31bf5279d05e701de209567e8c
Subproject commit 697683f9f013c50fd6aef0a9d723b1876f7018af