IYUUPlus-Windows/main.js

54 lines
1.2 KiB
JavaScript
Raw Normal View History

2024-07-01 16:50:17 +08:00
const { app } = require('electron')
2024-06-27 17:29:25 +08:00
const path = require('node:path')
2024-06-28 16:13:57 +08:00
const log = require('electron-log')
2024-07-03 18:35:02 +08:00
log.initialize();
console.log = log.log;
log.transports.file.resolvePathFn = () => path.join(app.getPath('appData'), 'iyuu-plus/logs/iyuu.log');
log.transports.file.format = '[{y}-{m}-{d} {h}:{i}:{s}.{ms}] [{level}]{scope} {text}';
log.transports.file.encoding = 'utf8';
log.info('App is starting...');
2024-06-28 16:13:57 +08:00
2024-07-03 18:35:02 +08:00
const server = require('./server/server');
2024-07-01 14:08:06 +08:00
const mainWin = require('./windows/app');
2024-07-03 18:35:02 +08:00
2024-06-27 17:29:25 +08:00
app.whenReady().then(() => {
2024-06-28 16:13:57 +08:00
log.info('App is starting...');
2024-06-27 17:29:25 +08:00
server.startServer()
2024-07-01 14:08:06 +08:00
require("./menu/tray.js")
2024-06-28 16:13:57 +08:00
log.info("[About] 新疆萌森软件开发工作室提供技术支持");
2024-06-27 17:29:25 +08:00
2024-06-28 12:21:47 +08:00
setTimeout(() => {
2024-07-01 14:08:06 +08:00
mainWin.createWindow()
}, 3000)
2024-06-29 00:41:06 +08:00
})
2024-06-27 17:29:25 +08:00
app.on('window-all-closed', () => {
2024-07-01 14:08:06 +08:00
mainWin.hideWindows()
2024-06-28 16:13:57 +08:00
})
2024-06-29 00:41:06 +08:00
app.on('before-quit', () => {
2024-07-01 16:50:17 +08:00
mainWin.closeWindows()
log.info('App Windows are closing...');
})
app.on('will-quit', () => {
2024-06-29 00:41:06 +08:00
server.stopServer()
log.info('App is quitting...');
})
2024-06-28 16:13:57 +08:00
2024-07-01 14:08:06 +08:00
app.on('quit', () => {
2024-07-01 16:50:17 +08:00
mainWin.closeWindows()
server.stopServer()
2024-07-01 14:08:06 +08:00
log.info('App is quitted');
2024-07-01 16:50:17 +08:00
})
if (require('electron-squirrel-startup')) {
server.stopServer()
app.quit()
return
}