mirror of
https://gitee.com/dapppp/ruoyi-plus-vben5.git
synced 2026-03-08 07:31:09 +08:00
fix(workflow): 修复审批面板加载状态闪烁问题
引入防抖延迟设置 loading 状态,避免快速切换任务时出现闪烁
This commit is contained in:
@@ -89,12 +89,19 @@ const loading = ref(false);
|
||||
|
||||
// 存放所有请求取消函数
|
||||
const abortList: (() => void)[] = [];
|
||||
let loadingTimer: ReturnType<typeof setTimeout>;
|
||||
|
||||
async function handleLoadInfo(task: TaskInfo | undefined) {
|
||||
currentFlowInfo.value = undefined;
|
||||
onlyForBtnPermissionTask.value = undefined;
|
||||
if (!task) {
|
||||
return null;
|
||||
}
|
||||
clearTimeout(loadingTimer);
|
||||
try {
|
||||
loading.value = true;
|
||||
loadingTimer = setTimeout(() => {
|
||||
loading.value = true;
|
||||
}, 300);
|
||||
// 取消之前的请求 & 清空数组
|
||||
abortList.forEach((abort) => abort());
|
||||
abortList.length = 0;
|
||||
@@ -128,6 +135,7 @@ async function handleLoadInfo(task: TaskInfo | undefined) {
|
||||
} catch (error) {
|
||||
console.error(error);
|
||||
} finally {
|
||||
clearTimeout(loadingTimer);
|
||||
loading.value = false;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user