clear setInterval() when the component is unMounted

This commit is contained in:
RockYang
2025-03-05 14:36:41 +08:00
parent f580f671a3
commit 43f00b1481
8 changed files with 47 additions and 18 deletions

View File

@@ -330,6 +330,7 @@ const playerRef = ref(null);
const showPlayer = ref(false);
const list = ref([]);
const taskPulling = ref(true);
const tastPullHandler = ref(null);
const btnText = ref("开始创作");
const refSong = ref(null);
const showDialog = ref(false);
@@ -350,7 +351,7 @@ onMounted(() => {
checkSession()
.then(() => {
fetchData(1);
setInterval(() => {
tastPullHandler.value = setInterval(() => {
if (taskPulling.value) {
fetchData(1);
}
@@ -361,7 +362,9 @@ onMounted(() => {
onUnmounted(() => {
clipboard.value.destroy();
store.removeMessageHandler("suno");
if (tastPullHandler.value) {
clearInterval(tastPullHandler.value);
}
});
const page = ref(1);