|
@ -1,5 +1,5 @@ |
|
|
// Modules to control application life and create native browser window
|
|
|
// Modules to control application life and create native browser window
|
|
|
const { app, BrowserWindow ,dialog} = require('electron') |
|
|
|
|
|
|
|
|
const { app, BrowserWindow ,dialog, globalShortcut} = require('electron') |
|
|
const { execSync } = require('child_process'); |
|
|
const { execSync } = require('child_process'); |
|
|
const path = require('node:path') |
|
|
const path = require('node:path') |
|
|
|
|
|
|
|
@ -22,6 +22,7 @@ function createWindow () { |
|
|
//mainWindow.loadFile('index.html')
|
|
|
//mainWindow.loadFile('index.html')
|
|
|
// window.isElectron = true;
|
|
|
// window.isElectron = true;
|
|
|
mainWindow.loadFile('./dist/index.html') |
|
|
mainWindow.loadFile('./dist/index.html') |
|
|
|
|
|
// mainWindow.loadURL('http://localhost:8888/')
|
|
|
|
|
|
|
|
|
// Open the DevTools.
|
|
|
// Open the DevTools.
|
|
|
// mainWindow.webContents.openDevTools()
|
|
|
// mainWindow.webContents.openDevTools()
|
|
@ -47,6 +48,16 @@ function createWindow () { |
|
|
mainWindow.on('closed', () => { |
|
|
mainWindow.on('closed', () => { |
|
|
app.quit() // 关闭应用程序
|
|
|
app.quit() // 关闭应用程序
|
|
|
}) |
|
|
}) |
|
|
|
|
|
|
|
|
|
|
|
// 注册快捷键
|
|
|
|
|
|
// mainWindow.on('focus', () => {
|
|
|
|
|
|
// globalShortcut.register('CommandOrControl+Alt+F', function () {
|
|
|
|
|
|
// mainWindow && mainWindow.webContents.toggleDevTools()
|
|
|
|
|
|
// })
|
|
|
|
|
|
// })
|
|
|
|
|
|
// mainWindow.on('blur', () => {
|
|
|
|
|
|
// globalShortcut.unregisterAll() // 注销键盘事件
|
|
|
|
|
|
// })
|
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
/** |
|
|
/** |
|
@ -54,7 +65,7 @@ function createWindow () { |
|
|
*/ |
|
|
*/ |
|
|
function clearCache(mainWindow) { |
|
|
function clearCache(mainWindow) { |
|
|
// 在窗口即将关闭时清除 localStorage 和 sessionStorage
|
|
|
// 在窗口即将关闭时清除 localStorage 和 sessionStorage
|
|
|
mainWindow.webContents.executeJavaScript('localStorage.clear();') |
|
|
|
|
|
|
|
|
mainWindow.webContents.executeJavaScript('localStorage.removeItem("Admin-Token");') |
|
|
mainWindow.webContents.executeJavaScript('sessionStorage.clear();') |
|
|
mainWindow.webContents.executeJavaScript('sessionStorage.clear();') |
|
|
} |
|
|
} |
|
|
// This method will be called when Electron has finished
|
|
|
// This method will be called when Electron has finished
|
|
|