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