summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorzyh <[email protected]>2024-11-27 13:49:30 +0800
committerzyh <[email protected]>2024-11-27 13:49:30 +0800
commit3289faf3e6bc005b28d75f5cfd44b8977f0befc6 (patch)
treecb92975995f328f580b12e84975b2c1e2d0b7064
parent4ceb5e4f08d4d0079ab20a0fb1c2cb2fd1e0ff99 (diff)
ASW-203 fix: application 编辑页面缺少未保存提示
-rw-r--r--src/components/monaco/index.vue4
-rw-r--r--src/views/applications/edit.vue25
2 files changed, 28 insertions, 1 deletions
diff --git a/src/components/monaco/index.vue b/src/components/monaco/index.vue
index 4dcc5ad..227dce7 100644
--- a/src/components/monaco/index.vue
+++ b/src/components/monaco/index.vue
@@ -81,6 +81,10 @@ const initEditor = () => {
scrollbar: {
alwaysConsumeMouseWheel: false,
},
+ unicodeHighlight: {
+ ambiguousCharacters: false,
+ invisibleCharacters: false,
+ },
});
if (
!get(monaco, 'languages.json.jsonDefaults._diagnosticsOptions.schemas', [])
diff --git a/src/views/applications/edit.vue b/src/views/applications/edit.vue
index 86f74c1..05d6536 100644
--- a/src/views/applications/edit.vue
+++ b/src/views/applications/edit.vue
@@ -431,7 +431,14 @@
<script setup>
import { useRouter } from 'vue-router';
-import { ref, computed, onBeforeMount, nextTick, watch } from 'vue';
+import {
+ ref,
+ computed,
+ onBeforeMount,
+ onBeforeUnmount,
+ nextTick,
+ watch,
+} from 'vue';
import {
applicationDetailApi,
applicationEditApi,
@@ -916,8 +923,24 @@ const jumpBack = () => {
});
};
+const beforeunloadHandler = (event) => {
+ if (modifiedList.value.length) {
+ // 定义提示消息
+ const message = '系统可能不会保存您所做的更改。';
+ // 标准方式:现代浏览器通常不允许自定义文本
+ event.returnValue = message; // Chrome 和现代浏览器需要这行代码来触发提示框
+ // 兼容旧版浏览器
+ return message; // Firefox 需要这行代码来触发提示框
+ }
+};
+
onBeforeMount(() => {
getData();
+ window.addEventListener('beforeunload', beforeunloadHandler);
+});
+
+onBeforeUnmount(() => {
+ window.removeEventListener('beforeunload', beforeunloadHandler);
});
watch(