Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

markdown 编辑器内容有意外丢失的风险 #32

Open
yhf2000 opened this issue Dec 6, 2022 · 1 comment
Open

markdown 编辑器内容有意外丢失的风险 #32

yhf2000 opened this issue Dec 6, 2022 · 1 comment
Labels
bug Something isn't working

Comments

@yhf2000
Copy link
Collaborator

yhf2000 commented Dec 6, 2022

No description provided.

@yhf2000 yhf2000 added the bug Something isn't working label Dec 6, 2022
@yhf2000 yhf2000 changed the title markdown 编辑器的本地缓存在新打开页面是被覆盖 markdown 编辑器内容有意外丢失的风险 May 8, 2023
@yhf2000
Copy link
Collaborator Author

yhf2000 commented May 8, 2023

  1. 本地记录历史信息
  2. 阻止页面退出
  componentWillMount () {
    // 拦截判断是否离开当前页面
    window.addEventListener('beforeunload', this.beforeunload);
  }
  componentWillUnmount () {
    // 销毁拦截判断是否离开当前页面
    window.removeEventListener('beforeunload', this.beforeunload);
  }
  beforeunload (e) {
    let confirmationMessage = '你确定离开此页面吗?';
    (e || window.event).returnValue = confirmationMessage;
    return confirmationMessage;
  }

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

1 participant