yangjie #49
14
main.js
14
main.js
|
|
@ -11,6 +11,7 @@ const {
|
|||
crashReporter,
|
||||
desktopCapturer,
|
||||
powerSaveBlocker,
|
||||
net
|
||||
} = require('electron');
|
||||
const path = require('node:path')
|
||||
const updateJs = require('./src/utils/package/update')
|
||||
|
|
@ -70,6 +71,15 @@ function quit() {
|
|||
app.quit()
|
||||
}
|
||||
let tray;
|
||||
// 检查网络状态
|
||||
function checkNetworkStatus() {
|
||||
if (!net.isOnline()) {
|
||||
dialog.showErrorBox('网络连接错误', '当前无网络连接,请检查您的网络设置。');
|
||||
app.quit();
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
function createTray() {
|
||||
const iconPath = `${__dirname}/src/assets/${updateJs.getIcon(env)}.png`;
|
||||
const trayIcon = nativeImage.createFromPath(iconPath);
|
||||
|
|
@ -93,6 +103,10 @@ function createWindow() {
|
|||
}
|
||||
const additionalData = { myKey: 'myValue' }
|
||||
app.on('ready', () => {
|
||||
// 检查网络状态
|
||||
if (!checkNetworkStatus()) {
|
||||
return;
|
||||
}
|
||||
// const gotTheLock = true
|
||||
const gotTheLock = app.requestSingleInstanceLock(additionalData)
|
||||
if (gotTheLock) {
|
||||
|
|
|
|||
Loading…
Reference in New Issue