From 544bebad96ac88b3ab1e145ab7646e89c957e0f6 Mon Sep 17 00:00:00 2001 From: Lazy <2211717435@qq.com> Date: Mon, 8 Jan 2024 23:41:46 +0800 Subject: [PATCH] Fix: clear Interval --- frontend/src/widgets/instance/FileManager.vue | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/frontend/src/widgets/instance/FileManager.vue b/frontend/src/widgets/instance/FileManager.vue index 3656b098..85c53436 100644 --- a/frontend/src/widgets/instance/FileManager.vue +++ b/frontend/src/widgets/instance/FileManager.vue @@ -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; +});