hookehuyr

fix: 在组件卸载时清理定时器防止内存泄漏

......@@ -63,6 +63,14 @@ const is_wx = computed(() => wxInfo().isWeiXin);
// iframe模式判断
const is_iframe = computed(() => window.self !== window.top);
// 组件卸载时清理定时器(必须在 setup 同步阶段注册钩子)
let upDater = null;
onUnmounted(() => {
if (upDater) {
upDater.destroy();
}
});
onMounted(async () => {
// 重置弹框状态,确保每次访问页面时都能正常显示未完成表单弹框
resetDialogState();
......@@ -242,7 +250,6 @@ onMounted(async () => {
}
// TAG:检查是否更新
let upDater = null;
if (import.meta.env.PROD) {
upDater = new Updater({
time: 30000
......@@ -261,12 +268,6 @@ onMounted(async () => {
})
}
// 组件卸载时清理定时器
onUnmounted(() => {
if (upDater) {
upDater.destroy();
}
});
});
</script>
......