Commit f0f1015b authored by 罗超's avatar 罗超

修改弹窗规则

parent 894675de
...@@ -27,9 +27,9 @@ onMounted(async () => { ...@@ -27,9 +27,9 @@ onMounted(async () => {
snapshotStore.initSnapshotDatabase() snapshotStore.initSnapshotDatabase()
mainStore.setAvailableFonts() mainStore.setAvailableFonts()
}) })
if (process.env.NODE_ENV === 'production') { // if (process.env.NODE_ENV === 'production') {
window.onbeforeunload = () => false // window.onbeforeunload = () => false
} // }
// 应用注销时向 localStorage 中记录下本次 indexedDB 的数据库ID,用于之后清除数据库 // 应用注销时向 localStorage 中记录下本次 indexedDB 的数据库ID,用于之后清除数据库
window.addEventListener('unload', () => { window.addEventListener('unload', () => {
const discardedDB = localStorage.getItem(LOCALSTORAGE_KEY_DISCARDED_DB) const discardedDB = localStorage.getItem(LOCALSTORAGE_KEY_DISCARDED_DB)
...@@ -51,10 +51,20 @@ setInterval(() => { ...@@ -51,10 +51,20 @@ setInterval(() => {
healthCheckHandler() healthCheckHandler()
}, 1000*60) }, 1000*60)
onMounted( () => { onMounted(() => {
const rules = ['/editor/','/team_editor/','/manager_template/','/create_template/']
window.onbeforeunload = function(event) { window.onbeforeunload = function(event) {
const currentUrl = window.location.pathname;
const shouldShowWarning = rules.some(rule => currentUrl.includes(rule));
console.log(shouldShowWarning)
if (shouldShowWarning) {
event.preventDefault(); event.preventDefault();
}; const confirmationMessage = "你确定要离开这个页面吗?离开前注意检查是否已经保存";
event.returnValue = confirmationMessage;
return confirmationMessage;
}
return null;
}
}) })
</script> </script>
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment