refactor: 点击当前仪表板支持取消上次仪表板请求

This commit is contained in:
wangjiahao 2025-01-08 13:37:28 +08:00 committed by 王嘉豪
parent 6430159b79
commit 50cd883870
2 changed files with 29 additions and 1 deletions

View File

@ -296,4 +296,23 @@ const executeVersionHandler = (response: AxiosResponse) => {
showMsg('系统有升级请点击刷新页面', '-sys-upgrade-')
}
}
export { service, cancelMap }
const cancelRequestBatch = cancelKey => {
if (cancelKey) {
if (cancelKey.indexOf('/**') > -1) {
const cancelKeyPre = cancelKey.split('/**')[0]
Object.keys(cancelMap).forEach(key => {
if (key.indexOf(cancelKeyPre) > -1) {
cancelMap[key]?.(() => {
console.warn('Operation canceled by the user,url:' + key)
})
}
})
} else {
cancelMap[cancelKey]?.(() => {
console.warn('Operation canceled by the user,url:' + cancelKey)
})
}
}
}
export { service, cancelMap, cancelRequestBatch }

View File

@ -47,6 +47,7 @@ import { findParentIdByChildIdRecursive } from '@/utils/canvasUtils'
import { XpackComponent } from '@/components/plugin'
import treeSort, { treeParentWeight } from '@/utils/treeSortUtils'
import router from '@/router'
import { cancelRequestBatch } from '@/config/axios/service'
const { wsCache } = useCache()
const dvMainStore = dvMainStoreWithOut()
@ -232,8 +233,16 @@ const filterNode = (value: string, data: BusiTreeNode) => {
if (!value) return true
return data.name?.toLocaleLowerCase().includes(value.toLocaleLowerCase())
}
//
const cancelPreRequest = () => {
cancelRequestBatch('/dataVisualization/findById')
cancelRequestBatch('/chartData/getData')
cancelRequestBatch('/linkage/getVisualizationAllLinkageInfo/**')
cancelRequestBatch('/linkJump/queryVisualizationJumpInfo/**')
}
const nodeClick = (data: BusiTreeNode) => {
cancelPreRequest()
selectedNodeKey.value = data.id
if (data.leaf) {
emit('nodeClick', data)