refactor: 优化组件卸载时资源清理逻辑

This commit is contained in:
bighuixiang
2025-06-22 15:21:18 +08:00
parent fad2c220af
commit 9848efb589

View File

@@ -342,21 +342,29 @@ onMounted(async () => {
}); });
onBeforeUnmount(() => { onBeforeUnmount(() => {
if (import.meta.hot) { // if (import.meta.hot) {
// 热更新 // // 热更新
console.log("onBeforeUnmount 开发环境热更新不卸载组件..."); // console.log("onBeforeUnmount 开发环境热更新不卸载组件...");
return; // 开发环境下不卸载组件 // return; // 开发环境下不卸载组件
} // }
console.log("onBeforeUnmount 组件卸载,清理资源..."); console.log("onBeforeUnmount 组件卸载,清理资源...");
canvasManager?.dispose?.(); // canvasManager?.dispose?.();
commandManager?.dispose?.(); // commandManager?.dispose?.();
layerManager?.dispose?.(); // layerManager?.dispose?.();
keyboardManager?.dispose?.(); // keyboardManager?.dispose?.();
toolManager?.dispose?.(); // toolManager?.dispose?.();
liquifyManager?.dispose?.(); // liquifyManager?.dispose?.();
selectionManager?.dispose?.(); // selectionManager?.dispose?.();
redGreenModeManager?.dispose?.(); // redGreenModeManager?.dispose?.();
// minimapManager?.dispose?.(); // minimapManager?.dispose?.();
canvasManager = null;
commandManager = null;
layerManager = null;
keyboardManager = null;
toolManager = null;
liquifyManager = null;
selectionManager = null;
redGreenModeManager = null;
// 移除window resize事件监听 // 移除window resize事件监听
window.removeEventListener("resize", handleWindowResize); window.removeEventListener("resize", handleWindowResize);