refactor: 优化组件卸载时资源清理逻辑
This commit is contained in:
@@ -342,21 +342,29 @@ onMounted(async () => {
|
||||
});
|
||||
|
||||
onBeforeUnmount(() => {
|
||||
if (import.meta.hot) {
|
||||
// 热更新 ?
|
||||
console.log("onBeforeUnmount 开发环境热更新不卸载组件...");
|
||||
return; // 开发环境下不卸载组件
|
||||
}
|
||||
// if (import.meta.hot) {
|
||||
// // 热更新 ?
|
||||
// console.log("onBeforeUnmount 开发环境热更新不卸载组件...");
|
||||
// return; // 开发环境下不卸载组件
|
||||
// }
|
||||
console.log("onBeforeUnmount 组件卸载,清理资源...");
|
||||
canvasManager?.dispose?.();
|
||||
commandManager?.dispose?.();
|
||||
layerManager?.dispose?.();
|
||||
keyboardManager?.dispose?.();
|
||||
toolManager?.dispose?.();
|
||||
liquifyManager?.dispose?.();
|
||||
selectionManager?.dispose?.();
|
||||
redGreenModeManager?.dispose?.();
|
||||
// canvasManager?.dispose?.();
|
||||
// commandManager?.dispose?.();
|
||||
// layerManager?.dispose?.();
|
||||
// keyboardManager?.dispose?.();
|
||||
// toolManager?.dispose?.();
|
||||
// liquifyManager?.dispose?.();
|
||||
// selectionManager?.dispose?.();
|
||||
// redGreenModeManager?.dispose?.();
|
||||
// minimapManager?.dispose?.();
|
||||
canvasManager = null;
|
||||
commandManager = null;
|
||||
layerManager = null;
|
||||
keyboardManager = null;
|
||||
toolManager = null;
|
||||
liquifyManager = null;
|
||||
selectionManager = null;
|
||||
redGreenModeManager = null;
|
||||
|
||||
// 移除window resize事件监听
|
||||
window.removeEventListener("resize", handleWindowResize);
|
||||
|
||||
Reference in New Issue
Block a user