clear setInterval() when the component is unMounted

This commit is contained in:
RockYang
2025-03-05 14:36:41 +08:00
parent f580f671a3
commit 43f00b1481
8 changed files with 47 additions and 18 deletions

View File

@@ -229,6 +229,7 @@ const params = ref({
const runningJobs = ref([]);
const finishedJobs = ref([]);
const allowPulling = ref(true); // 是否允许轮询
const tastPullHandler = ref(null);
const router = useRouter();
// 检查是否有画同款的参数
const _params = router.currentRoute.value.params["copyParams"];
@@ -264,7 +265,9 @@ onMounted(() => {
onUnmounted(() => {
clipboard.value.destroy();
store.removeMessageHandler("sd");
if (tastPullHandler.value) {
clearInterval(tastPullHandler.value);
}
});
const initData = () => {
@@ -276,7 +279,7 @@ const initData = () => {
fetchRunningJobs();
fetchFinishJobs(1);
setInterval(() => {
tastPullHandler.value = setInterval(() => {
if (allowPulling.value) {
fetchRunningJobs();
}