fix: 去除定时存储数据的逻辑

This commit is contained in:
奔跑的面条
2023-05-30 09:34:54 +08:00
parent afc6cf04a1
commit 2f43ddd59b
2 changed files with 32 additions and 2 deletions
+20
View File
@@ -330,3 +330,23 @@ export const JSONParse = (data: string) => {
export const setTitle = (title?: string) => {
title && (document.title = title)
}
/**
* 处理网页关闭事件
*/
export const addWindowUnload = () => {
// 关闭网页出现离开提示
window.onbeforeunload = function (e) {
e = e || window.event
// 兼容IE8和Firefox 4之前的版本
if (e) {
e.returnValue = '您确定要离开当前页面吗?请确认是否保存数据!'
}
// Chrome, Safari, Firefox 4+, Opera 12+ , IE 9+
return '您确定要离开当前页面吗?请确认是否保存数据!'
}
// 返回销毁事件函数
return () => {
window.onbeforeunload = null
}
}