mirror of
https://github.com/yangjian102621/geekai.git
synced 2026-05-05 17:34:25 +08:00
clear setInterval() when the component is unMounted
This commit is contained in:
@@ -191,6 +191,7 @@ const showModelPicker = ref(false);
|
||||
const runningJobs = ref([]);
|
||||
const finishedJobs = ref([]);
|
||||
const allowPulling = ref(true); // 是否允许轮询
|
||||
const tastPullHandler = ref(null);
|
||||
const router = useRouter();
|
||||
const power = ref(0);
|
||||
const dallPower = ref(0); // 画一张 DALL 图片消耗算力
|
||||
@@ -236,7 +237,9 @@ onMounted(() => {
|
||||
|
||||
onUnmounted(() => {
|
||||
clipboard.value.destroy();
|
||||
store.removeMessageHandler("dall");
|
||||
if (tastPullHandler.value) {
|
||||
clearInterval(tastPullHandler.value);
|
||||
}
|
||||
});
|
||||
|
||||
const initData = () => {
|
||||
@@ -247,7 +250,7 @@ const initData = () => {
|
||||
fetchRunningJobs();
|
||||
fetchFinishJobs(1);
|
||||
|
||||
setInterval(() => {
|
||||
tastPullHandler.value = setInterval(() => {
|
||||
if (allowPulling.value) {
|
||||
fetchRunningJobs();
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user