yangjie #49

Merged
yangqiang merged 71 commits from yangjie into master 2025-03-10 14:21:26 +08:00
1 changed files with 14 additions and 0 deletions
Showing only changes of commit d11f437e2d - Show all commits

14
main.js
View File

@ -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) {