mirror of
https://github.com/yangjian102621/geekai.git
synced 2026-05-05 09:24:29 +08:00
clear setInterval() when the component is unMounted
This commit is contained in:
@@ -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();
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user