mirror of
https://github.com/yangjian102621/geekai.git
synced 2026-05-07 18:24:54 +08:00
clear setInterval() when the component is unMounted
This commit is contained in:
@@ -276,6 +276,7 @@ const params = ref({
|
|||||||
const finishedJobs = ref([]);
|
const finishedJobs = ref([]);
|
||||||
const runningJobs = ref([]);
|
const runningJobs = ref([]);
|
||||||
const allowPulling = ref(true); // 是否允许轮询
|
const allowPulling = ref(true); // 是否允许轮询
|
||||||
|
const tastPullHandler = ref(null);
|
||||||
const power = ref(0);
|
const power = ref(0);
|
||||||
const dallPower = ref(0); // 画一张 SD 图片消耗算力
|
const dallPower = ref(0); // 画一张 SD 图片消耗算力
|
||||||
const clipboard = ref(null);
|
const clipboard = ref(null);
|
||||||
@@ -316,7 +317,9 @@ onMounted(() => {
|
|||||||
|
|
||||||
onUnmounted(() => {
|
onUnmounted(() => {
|
||||||
clipboard.value.destroy();
|
clipboard.value.destroy();
|
||||||
store.removeMessageHandler("dall");
|
if (tastPullHandler.value) {
|
||||||
|
clearInterval(tastPullHandler.value);
|
||||||
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
const initData = () => {
|
const initData = () => {
|
||||||
@@ -330,7 +333,7 @@ const initData = () => {
|
|||||||
fetchFinishJobs();
|
fetchFinishJobs();
|
||||||
|
|
||||||
// 轮询运行中任务
|
// 轮询运行中任务
|
||||||
setInterval(() => {
|
tastPullHandler.value = setInterval(() => {
|
||||||
if (allowPulling.value) {
|
if (allowPulling.value) {
|
||||||
fetchRunningJobs();
|
fetchRunningJobs();
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -772,7 +772,9 @@ const activeName = ref("txt2img");
|
|||||||
const runningJobs = ref([]);
|
const runningJobs = ref([]);
|
||||||
const finishedJobs = ref([]);
|
const finishedJobs = ref([]);
|
||||||
const taskPulling = ref(true); // 任务轮询
|
const taskPulling = ref(true); // 任务轮询
|
||||||
|
const tastPullHandler = ref(null);
|
||||||
const downloadPulling = ref(false); // 图片下载轮询
|
const downloadPulling = ref(false); // 图片下载轮询
|
||||||
|
const downloadPullHandler = ref(null);
|
||||||
|
|
||||||
const power = ref(0);
|
const power = ref(0);
|
||||||
const userId = ref(0);
|
const userId = ref(0);
|
||||||
@@ -793,7 +795,12 @@ onMounted(() => {
|
|||||||
|
|
||||||
onUnmounted(() => {
|
onUnmounted(() => {
|
||||||
clipboard.value.destroy();
|
clipboard.value.destroy();
|
||||||
store.removeMessageHandler("mj");
|
if (tastPullHandler.value) {
|
||||||
|
clearInterval(tastPullHandler.value);
|
||||||
|
}
|
||||||
|
if (downloadPullHandler.value) {
|
||||||
|
clearInterval(downloadPullHandler.value);
|
||||||
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
// 初始化数据
|
// 初始化数据
|
||||||
@@ -806,13 +813,13 @@ const initData = () => {
|
|||||||
page.value = 0;
|
page.value = 0;
|
||||||
fetchFinishJobs();
|
fetchFinishJobs();
|
||||||
|
|
||||||
setInterval(() => {
|
tastPullHandler.value = setInterval(() => {
|
||||||
if (taskPulling.value) {
|
if (taskPulling.value) {
|
||||||
fetchRunningJobs();
|
fetchRunningJobs();
|
||||||
}
|
}
|
||||||
}, 5000);
|
}, 5000);
|
||||||
|
|
||||||
setInterval(() => {
|
downloadPullHandler.value = setInterval(() => {
|
||||||
if (downloadPulling.value) {
|
if (downloadPulling.value) {
|
||||||
page.value = 0;
|
page.value = 0;
|
||||||
fetchFinishJobs();
|
fetchFinishJobs();
|
||||||
|
|||||||
@@ -374,6 +374,7 @@ const params = ref({
|
|||||||
const runningJobs = ref([]);
|
const runningJobs = ref([]);
|
||||||
const finishedJobs = ref([]);
|
const finishedJobs = ref([]);
|
||||||
const allowPulling = ref(true); // 是否允许轮询
|
const allowPulling = ref(true); // 是否允许轮询
|
||||||
|
const tastPullHandler = ref(null);
|
||||||
const router = useRouter();
|
const router = useRouter();
|
||||||
// 检查是否有画同款的参数
|
// 检查是否有画同款的参数
|
||||||
const _params = router.currentRoute.value.params["copyParams"];
|
const _params = router.currentRoute.value.params["copyParams"];
|
||||||
@@ -408,7 +409,9 @@ onMounted(() => {
|
|||||||
|
|
||||||
onUnmounted(() => {
|
onUnmounted(() => {
|
||||||
clipboard.value.destroy();
|
clipboard.value.destroy();
|
||||||
store.removeMessageHandler("sd");
|
if (tastPullHandler.value) {
|
||||||
|
clearInterval(tastPullHandler.value);
|
||||||
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
const initData = () => {
|
const initData = () => {
|
||||||
@@ -421,7 +424,7 @@ const initData = () => {
|
|||||||
fetchRunningJobs();
|
fetchRunningJobs();
|
||||||
fetchFinishJobs();
|
fetchFinishJobs();
|
||||||
|
|
||||||
setInterval(() => {
|
tastPullHandler.value = setInterval(() => {
|
||||||
if (allowPulling.value) {
|
if (allowPulling.value) {
|
||||||
fetchRunningJobs();
|
fetchRunningJobs();
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -92,7 +92,7 @@
|
|||||||
</div>
|
</div>
|
||||||
|
|
||||||
<!-- 仅在simple模式下显示详细配置 -->
|
<!-- 仅在simple模式下显示详细配置 -->
|
||||||
<div class="camera-control" v-if="params.camera_control.type === 'simple'">
|
<div class="camera-control mt-2" v-if="params.camera_control.type === 'simple'">
|
||||||
<el-form-item label="水平移动">
|
<el-form-item label="水平移动">
|
||||||
<el-slider v-model="params.camera_control.config.horizontal" :min="-10" :max="10" />
|
<el-slider v-model="params.camera_control.config.horizontal" :min="-10" :max="10" />
|
||||||
</el-form-item>
|
</el-form-item>
|
||||||
@@ -556,7 +556,7 @@ const fetchData = (_page) => {
|
|||||||
let needPull = false;
|
let needPull = false;
|
||||||
const items = [];
|
const items = [];
|
||||||
for (let v of res.data.items) {
|
for (let v of res.data.items) {
|
||||||
if (v.progress < 100 || (v.progress === 100 && v.video_url === "")) {
|
if (v.progress === 0 || v.progress === 102) {
|
||||||
needPull = true;
|
needPull = true;
|
||||||
}
|
}
|
||||||
items.push({
|
items.push({
|
||||||
|
|||||||
@@ -330,6 +330,7 @@ const playerRef = ref(null);
|
|||||||
const showPlayer = ref(false);
|
const showPlayer = ref(false);
|
||||||
const list = ref([]);
|
const list = ref([]);
|
||||||
const taskPulling = ref(true);
|
const taskPulling = ref(true);
|
||||||
|
const tastPullHandler = ref(null);
|
||||||
const btnText = ref("开始创作");
|
const btnText = ref("开始创作");
|
||||||
const refSong = ref(null);
|
const refSong = ref(null);
|
||||||
const showDialog = ref(false);
|
const showDialog = ref(false);
|
||||||
@@ -350,7 +351,7 @@ onMounted(() => {
|
|||||||
checkSession()
|
checkSession()
|
||||||
.then(() => {
|
.then(() => {
|
||||||
fetchData(1);
|
fetchData(1);
|
||||||
setInterval(() => {
|
tastPullHandler.value = setInterval(() => {
|
||||||
if (taskPulling.value) {
|
if (taskPulling.value) {
|
||||||
fetchData(1);
|
fetchData(1);
|
||||||
}
|
}
|
||||||
@@ -361,7 +362,9 @@ onMounted(() => {
|
|||||||
|
|
||||||
onUnmounted(() => {
|
onUnmounted(() => {
|
||||||
clipboard.value.destroy();
|
clipboard.value.destroy();
|
||||||
store.removeMessageHandler("suno");
|
if (tastPullHandler.value) {
|
||||||
|
clearInterval(tastPullHandler.value);
|
||||||
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
const page = ref(1);
|
const page = ref(1);
|
||||||
|
|||||||
@@ -191,6 +191,7 @@ const showModelPicker = ref(false);
|
|||||||
const runningJobs = ref([]);
|
const runningJobs = ref([]);
|
||||||
const finishedJobs = ref([]);
|
const finishedJobs = ref([]);
|
||||||
const allowPulling = ref(true); // 是否允许轮询
|
const allowPulling = ref(true); // 是否允许轮询
|
||||||
|
const tastPullHandler = ref(null);
|
||||||
const router = useRouter();
|
const router = useRouter();
|
||||||
const power = ref(0);
|
const power = ref(0);
|
||||||
const dallPower = ref(0); // 画一张 DALL 图片消耗算力
|
const dallPower = ref(0); // 画一张 DALL 图片消耗算力
|
||||||
@@ -236,7 +237,9 @@ onMounted(() => {
|
|||||||
|
|
||||||
onUnmounted(() => {
|
onUnmounted(() => {
|
||||||
clipboard.value.destroy();
|
clipboard.value.destroy();
|
||||||
store.removeMessageHandler("dall");
|
if (tastPullHandler.value) {
|
||||||
|
clearInterval(tastPullHandler.value);
|
||||||
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
const initData = () => {
|
const initData = () => {
|
||||||
@@ -247,7 +250,7 @@ const initData = () => {
|
|||||||
fetchRunningJobs();
|
fetchRunningJobs();
|
||||||
fetchFinishJobs(1);
|
fetchFinishJobs(1);
|
||||||
|
|
||||||
setInterval(() => {
|
tastPullHandler.value = setInterval(() => {
|
||||||
if (allowPulling.value) {
|
if (allowPulling.value) {
|
||||||
fetchRunningJobs();
|
fetchRunningJobs();
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -310,7 +310,9 @@ const prompt = ref("");
|
|||||||
const store = useSharedStore();
|
const store = useSharedStore();
|
||||||
const clipboard = ref(null);
|
const clipboard = ref(null);
|
||||||
const taskPulling = ref(true);
|
const taskPulling = ref(true);
|
||||||
|
const tastPullHandler = ref(null);
|
||||||
const downloadPulling = ref(false);
|
const downloadPulling = ref(false);
|
||||||
|
const downloadPullHandler = ref(null);
|
||||||
|
|
||||||
onMounted(() => {
|
onMounted(() => {
|
||||||
clipboard.value = new Clipboard(".copy-prompt");
|
clipboard.value = new Clipboard(".copy-prompt");
|
||||||
@@ -329,13 +331,13 @@ onMounted(() => {
|
|||||||
fetchRunningJobs();
|
fetchRunningJobs();
|
||||||
fetchFinishJobs(1);
|
fetchFinishJobs(1);
|
||||||
|
|
||||||
setInterval(() => {
|
tastPullHandler.value = setInterval(() => {
|
||||||
if (taskPulling.value) {
|
if (taskPulling.value) {
|
||||||
fetchRunningJobs();
|
fetchRunningJobs();
|
||||||
}
|
}
|
||||||
}, 5000);
|
}, 5000);
|
||||||
|
|
||||||
setInterval(() => {
|
downloadPullHandler.value = setInterval(() => {
|
||||||
if (downloadPulling.value) {
|
if (downloadPulling.value) {
|
||||||
page.value = 1;
|
page.value = 1;
|
||||||
fetchFinishJobs(1);
|
fetchFinishJobs(1);
|
||||||
@@ -349,7 +351,12 @@ onMounted(() => {
|
|||||||
|
|
||||||
onUnmounted(() => {
|
onUnmounted(() => {
|
||||||
clipboard.value.destroy();
|
clipboard.value.destroy();
|
||||||
store.removeMessageHandler("mj");
|
if (tastPullHandler.value) {
|
||||||
|
clearInterval(tastPullHandler.value);
|
||||||
|
}
|
||||||
|
if (downloadPullHandler.value) {
|
||||||
|
clearInterval(downloadPullHandler.value);
|
||||||
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
const mjPower = ref(1);
|
const mjPower = ref(1);
|
||||||
|
|||||||
@@ -229,6 +229,7 @@ const params = ref({
|
|||||||
const runningJobs = ref([]);
|
const runningJobs = ref([]);
|
||||||
const finishedJobs = ref([]);
|
const finishedJobs = ref([]);
|
||||||
const allowPulling = ref(true); // 是否允许轮询
|
const allowPulling = ref(true); // 是否允许轮询
|
||||||
|
const tastPullHandler = ref(null);
|
||||||
const router = useRouter();
|
const router = useRouter();
|
||||||
// 检查是否有画同款的参数
|
// 检查是否有画同款的参数
|
||||||
const _params = router.currentRoute.value.params["copyParams"];
|
const _params = router.currentRoute.value.params["copyParams"];
|
||||||
@@ -264,7 +265,9 @@ onMounted(() => {
|
|||||||
|
|
||||||
onUnmounted(() => {
|
onUnmounted(() => {
|
||||||
clipboard.value.destroy();
|
clipboard.value.destroy();
|
||||||
store.removeMessageHandler("sd");
|
if (tastPullHandler.value) {
|
||||||
|
clearInterval(tastPullHandler.value);
|
||||||
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
const initData = () => {
|
const initData = () => {
|
||||||
@@ -276,7 +279,7 @@ const initData = () => {
|
|||||||
fetchRunningJobs();
|
fetchRunningJobs();
|
||||||
fetchFinishJobs(1);
|
fetchFinishJobs(1);
|
||||||
|
|
||||||
setInterval(() => {
|
tastPullHandler.value = setInterval(() => {
|
||||||
if (allowPulling.value) {
|
if (allowPulling.value) {
|
||||||
fetchRunningJobs();
|
fetchRunningJobs();
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user