fix -- 导入组长和路径图

This commit is contained in:
yuping
2023-02-21 03:02:34 +08:00
parent 86234bb1f0
commit 51b435c46b
4 changed files with 261 additions and 377 deletions

45
src/utils/useCommon.js Normal file
View File

@@ -0,0 +1,45 @@
import {ref} from "vue";
import {message} from "ant-design-vue";
export function useInterval(fun, time) {
const timer = ref();
function start(d) {
clearInterval(timer.value)
timer.value = setInterval(async () => {
if (await fun(d)) {
clearInterval(timer.value)
}
}, time);
}
return {start}
}
export function useTimeout(asyncFun, time) {
const timer = ref();
const maxCount = ref(0);
function start(d) {
clearTimeout(timer.value)
maxCount.value = 0
execute(d)
}
async function execute(d) {
if (maxCount.value > 300) {
message.error("等待超时,请联系管理员!")
throw Error("等待超时 查询任务结束")
}
try {
await asyncFun(d)
maxCount.value = maxCount.value + 1
timer.value = setTimeout(() => execute(d), time);
} catch (e) {
clearTimeout(timer.value)
console.log(e)
}
}
return {start}
}