Browse Source

go

main
583641232@qq.com 1 year ago
parent
commit
89f467a238
  1. 12
      main.js

12
main.js

@ -23,7 +23,7 @@ function createWindow () {
mainWindow.loadFile('./dist/index.html')
// Open the DevTools.
// mainWindow.webContents.openDevTools()
mainWindow.webContents.openDevTools()
mainWindow.on('close', e => {
const choice = dialog.showMessageBoxSync(mainWindow, {
@ -36,7 +36,7 @@ function createWindow () {
})
const leave = choice === 0;
if (!leave) {
clearCache(mainWindow)
} else {
// 点击取消按钮
e.preventDefault();
@ -48,6 +48,14 @@ function createWindow () {
})
}
/**
 * @description 清除缓存
 */
function clearCache(mainWindow) {
// 在窗口即将关闭时清除 localStorage 和 sessionStorage
mainWindow.webContents.executeJavaScript('localStorage.clear();')
mainWindow.webContents.executeJavaScript('sessionStorage.clear();')
}
// This method will be called when Electron has finished
// initialization and is ready to create browser windows.
// Some APIs can only be used after this event occurs.

Loading…
Cancel
Save