|
@ -23,7 +23,7 @@ function createWindow () { |
|
|
mainWindow.loadFile('./dist/index.html') |
|
|
mainWindow.loadFile('./dist/index.html') |
|
|
|
|
|
|
|
|
// Open the DevTools.
|
|
|
// Open the DevTools.
|
|
|
// mainWindow.webContents.openDevTools()
|
|
|
|
|
|
|
|
|
mainWindow.webContents.openDevTools() |
|
|
|
|
|
|
|
|
mainWindow.on('close', e => { |
|
|
mainWindow.on('close', e => { |
|
|
const choice = dialog.showMessageBoxSync(mainWindow, { |
|
|
const choice = dialog.showMessageBoxSync(mainWindow, { |
|
@ -36,7 +36,7 @@ function createWindow () { |
|
|
}) |
|
|
}) |
|
|
const leave = choice === 0; |
|
|
const leave = choice === 0; |
|
|
if (!leave) { |
|
|
if (!leave) { |
|
|
|
|
|
|
|
|
|
|
|
clearCache(mainWindow) |
|
|
} else { |
|
|
} else { |
|
|
// 点击取消按钮
|
|
|
// 点击取消按钮
|
|
|
e.preventDefault(); |
|
|
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
|
|
|
// This method will be called when Electron has finished
|
|
|
// initialization and is ready to create browser windows.
|
|
|
// initialization and is ready to create browser windows.
|
|
|
// Some APIs can only be used after this event occurs.
|
|
|
// Some APIs can only be used after this event occurs.
|
|
|