forked from github/dataease
perf(X-Pack): 导航栏组织切换器加载慢
This commit is contained in:
parent
72df84e837
commit
7c666b5301
@ -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 => {
|
||||
|
@ -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 = []
|
||||
}
|
||||
}
|
||||
})
|
||||
|
2
de-xpack
2
de-xpack
@ -1 +1 @@
|
||||
Subproject commit fcf1317c371f3e31bf5279d05e701de209567e8c
|
||||
Subproject commit 697683f9f013c50fd6aef0a9d723b1876f7018af
|
Loading…
Reference in New Issue
Block a user