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 { useCache } from '@/hooks/web/useCache'
|
||||||
import { refreshApi } from '@/api/login'
|
import { refreshApi } from '@/api/login'
|
||||||
import { useUserStoreWithOut } from '@/store/modules/user'
|
import { useUserStoreWithOut } from '@/store/modules/user'
|
||||||
|
import { useRequestStoreWithOut } from '@/store/modules/request'
|
||||||
|
|
||||||
import { isLink } from '@/utils/utils'
|
import { isLink } from '@/utils/utils'
|
||||||
const { wsCache } = useCache()
|
const { wsCache } = useCache()
|
||||||
const userStore = useUserStoreWithOut()
|
const userStore = useUserStoreWithOut()
|
||||||
|
const requestStore = useRequestStoreWithOut()
|
||||||
const refreshUrl = '/login/refresh'
|
const refreshUrl = '/login/refresh'
|
||||||
let cachedRequestList = []
|
|
||||||
|
|
||||||
const expConstants = 10000
|
const expConstants = 10000
|
||||||
|
|
||||||
@ -19,10 +20,15 @@ const isExpired = () => {
|
|||||||
}
|
}
|
||||||
|
|
||||||
const delayExecute = (token: string) => {
|
const delayExecute = (token: string) => {
|
||||||
|
const cachedRequestList = requestStore.getRequestList
|
||||||
cachedRequestList.forEach(cb => {
|
cachedRequestList.forEach(cb => {
|
||||||
cb(token)
|
cb(token)
|
||||||
})
|
})
|
||||||
cachedRequestList = []
|
requestStore.cleanCacheRequest()
|
||||||
|
/* cachedRequestList.forEach(cb => {
|
||||||
|
cb(token)
|
||||||
|
})
|
||||||
|
cachedRequestList = [] */
|
||||||
}
|
}
|
||||||
|
|
||||||
const getRefreshStatus = () => {
|
const getRefreshStatus = () => {
|
||||||
@ -33,7 +39,8 @@ const setRefreshStatus = (status: boolean) => {
|
|||||||
}
|
}
|
||||||
|
|
||||||
const cacheRequest = cb => {
|
const cacheRequest = cb => {
|
||||||
cachedRequestList.push(cb)
|
requestStore.addCacheRequest(cb)
|
||||||
|
// cachedRequestList.push(cb)
|
||||||
}
|
}
|
||||||
|
|
||||||
export const configHandler = config => {
|
export const configHandler = config => {
|
||||||
|
@ -5,12 +5,19 @@ interface RequestState {
|
|||||||
loadingMap: {
|
loadingMap: {
|
||||||
[key: string]: number
|
[key: string]: number
|
||||||
}
|
}
|
||||||
|
cachedRequestList: []
|
||||||
}
|
}
|
||||||
|
|
||||||
export const useRequestStore = defineStore('request', {
|
export const useRequestStore = defineStore('request', {
|
||||||
state: (): RequestState => {
|
state: (): RequestState => {
|
||||||
return {
|
return {
|
||||||
loadingMap: {}
|
loadingMap: {},
|
||||||
|
cachedRequestList: []
|
||||||
|
}
|
||||||
|
},
|
||||||
|
getters: {
|
||||||
|
getRequestList(): string {
|
||||||
|
return this.cachedRequestList
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
actions: {
|
actions: {
|
||||||
@ -34,6 +41,12 @@ export const useRequestStore = defineStore('request', {
|
|||||||
map[key] -= 1
|
map[key] -= 1
|
||||||
this.loadingMap = map
|
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