hookehuyr

fix

...@@ -1082,17 +1082,6 @@ export default { ...@@ -1082,17 +1082,6 @@ export default {
1082 } else { // 预览模式下不显示刷新提示框 1082 } else { // 预览模式下不显示刷新提示框
1083 localStorage.setItem('showConfirmation', '0'); 1083 localStorage.setItem('showConfirmation', '0');
1084 } 1084 }
1085 - // 监听 beforeunload 事件
1086 - window.addEventListener('beforeunload', function (event) {
1087 - const confirmationMessage = "确定要离开此页面吗?您所做的更改可能不会被保存。";
1088 -
1089 - if (localStorage.getItem('showConfirmation') === '1') {
1090 - // 取消事件的默认行为(弹出确认对话框)
1091 - event.preventDefault();
1092 - event.returnValue = confirmationMessage; 
1093 - return confirmationMessage;
1094 - }
1095 - });
1096 // 监听 unload 事件 1085 // 监听 unload 事件
1097 window.addEventListener('unload', function () { 1086 window.addEventListener('unload', function () {
1098 // 设置标志位为 false,避免在刷新页面时再次显示提示框 1087 // 设置标志位为 false,避免在刷新页面时再次显示提示框
...@@ -1839,6 +1828,19 @@ export default { ...@@ -1839,6 +1828,19 @@ export default {
1839 state.detailModel = null; 1828 state.detailModel = null;
1840 editor.closeModel(); 1829 editor.closeModel();
1841 } 1830 }
1831 +
1832 + // 监听 beforeunload 事件
1833 + window.addEventListener('beforeunload', function (event) {
1834 + const confirmationMessage = "确定要离开此页面吗?您所做的更改可能不会被保存。";
1835 +
1836 + if (localStorage.getItem('showConfirmation') === '1') {
1837 + // 取消事件的默认行为(弹出确认对话框)
1838 + event.preventDefault();
1839 + event.returnValue = confirmationMessage; 
1840 + return confirmationMessage;
1841 + }
1842 +
1843 + });
1842 } 1844 }
1843 1845
1844 /** 1846 /**
...@@ -2302,6 +2304,18 @@ export default { ...@@ -2302,6 +2304,18 @@ export default {
2302 } 2304 }
2303 2305
2304 const onDragCanvas = (evt) => { 2306 const onDragCanvas = (evt) => {
2307 + // 监听 beforeunload 事件
2308 + window.addEventListener('beforeunload', function (event) {
2309 + const confirmationMessage = "确定要离开此页面吗?您所做的更改可能不会被保存。";
2310 +
2311 + if (localStorage.getItem('showConfirmation') === '1') {
2312 + // 取消事件的默认行为(弹出确认对话框)
2313 + event.preventDefault();
2314 + event.returnValue = confirmationMessage; 
2315 + return confirmationMessage;
2316 + }
2317 +
2318 + });
2305 } 2319 }
2306 2320
2307 /** 2321 /**
......