Fix: clear Interval

This commit is contained in:
Lazy 2024-01-08 23:41:46 +08:00
parent 8b2e658340
commit 544bebad96

View File

@ -16,6 +16,7 @@ import { useFileManager } from "@/hooks/useFileManager";
import FileEditor from "./dialogs/FileEditor.vue";
import type { DataType } from "@/types/fileManager";
import type { AntColumnsType } from "@/types/ant";
import { onUnmounted } from "vue";
const props = defineProps<{
card: LayoutCard;
@ -133,7 +134,8 @@ watch(
}, 1000)
);
setInterval(async () => {
let task: NodeJS.Timer | undefined;
task = setInterval(async () => {
await getFileStatus();
}, 3000);
@ -150,6 +152,11 @@ onMounted(() => {
getFileList();
dialog.value.loading = false;
});
onUnmounted(() => {
if (task) clearInterval(task);
task = undefined;
});
</script>
<template>