IYUUPlus-Windows/main.js

49 lines
1.1 KiB
JavaScript
Raw Permalink 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')
const server = require('./server/server');
2024-06-28 16:13:57 +08:00
const log = require('electron-log')
2024-07-01 14:08:06 +08:00
const mainWin = require('./windows/app');
2024-06-27 17:29:25 +08:00
app.whenReady().then(() => {
2024-06-28 16:13:57 +08:00
log.transports.file.encoding = 'utf8';
log.transports.file.file = path.join(app.getPath('userData'), 'logs/iyuu.log');
log.transports.file.format = '{y}-{m}-{d} {h}:{i}:{s} {text}';
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
}