|
|
@@ -1,20 +1,9 @@
|
|
|
-const {app, BrowserWindow, Menu, ipcMain, globalShortcut } = require('electron')// 引入electron
|
|
|
-const path = require('path')
|
|
|
+const { app, BrowserWindow, Menu, ipcMain, globalShortcut } = require('electron');// 引入electron
|
|
|
+const path = require('path');
|
|
|
let win, loadingWin;
|
|
|
Menu.setApplicationMenu(null) // 去掉菜单栏
|
|
|
app.commandLine.appendSwitch('wm-window-animations-disabled') // 拖动闪屏
|
|
|
|
|
|
-// 消息通知
|
|
|
-function notifiction(title, options) {
|
|
|
- const WebNotification = window.Notification || window.mozNotification || window.webkitNotification
|
|
|
- const isTrue = WebNotification.requestPermission(result => {
|
|
|
- return (result === 'granted') // granted(允许) || denied(拒绝)
|
|
|
- })
|
|
|
- const noti = new WebNotification(title, options)
|
|
|
- noti.onclick = () => {
|
|
|
- console.log('关闭')
|
|
|
- }
|
|
|
-}
|
|
|
|
|
|
// 创建loading 窗口
|
|
|
const showLoading = () => {
|
|
|
@@ -44,7 +33,7 @@ const createWindow = () => {
|
|
|
contextIsolation: true,
|
|
|
nodeIntegration: true,
|
|
|
webSecurity: false, // 去掉跨越
|
|
|
- preload: path.join(__dirname, 'preload.js')
|
|
|
+ preload: path.join(__dirname, './preload.js')
|
|
|
},
|
|
|
show: false
|
|
|
})// 创建一个窗口
|
|
|
@@ -55,7 +44,7 @@ const createWindow = () => {
|
|
|
} else {
|
|
|
win.loadURL('http://localhost:6547/')
|
|
|
}
|
|
|
-
|
|
|
+
|
|
|
// 事件监听
|
|
|
win.on('close', () => {
|
|
|
// 回收BrowserWindow对象
|
|
|
@@ -69,14 +58,14 @@ app.on('ready', async () => {
|
|
|
createWindow()
|
|
|
// 监听渲染进行
|
|
|
ipcMain.once('close-loading', () => {
|
|
|
- loadingWin.close()
|
|
|
- win.show()
|
|
|
+ loadingWin?.close()
|
|
|
+ win?.show()
|
|
|
})
|
|
|
// 在BrowserWindow创建完成后,注册全局快捷键
|
|
|
globalShortcut.register('Control+F12', () => {
|
|
|
- win.webContents.toggleDevTools()
|
|
|
+ win?.webContents.toggleDevTools()
|
|
|
})
|
|
|
-
|
|
|
+
|
|
|
})
|
|
|
|
|
|
app.on('window-all-closed', () => {
|