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