-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.js
executable file
·82 lines (72 loc) · 1.69 KB
/
main.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
const { Application } = require('ee-core');
const EE = require('ee-core/ee');
const { app, BrowserWindow, Notification,ipcMain } = require('electron')
// process.env['ELECTRON_DISABLE_SECURITY_WARNINGS'] = 'true'
class Main extends Application {
constructor() {
super();
// this === eeApp;
}
/**
* core app have been loaded
*/
async ready () {
// do some things
}
/**
* electron app ready
*/
async electronAppReady () {
// do some things
}
showNotification (NOTIFICATION_TITLE = 'Basic Notification',NOTIFICATION_BODY = 'Notification from the Main process') {
new Notification({ title: NOTIFICATION_TITLE, body: NOTIFICATION_BODY }).show()
}
/**
* main window have been loaded
*/
async windowReady () {
// do some things
// 延迟加载,无白屏
const winOpt = this.config.windowsOption;
if (winOpt.show == false) {
const win = this.electron.mainWindow;
win.once('ready-to-show', () => {
win.maximize();
win.show();
win.setTitle(`DCE财讯通`)
this.showNotification('标题',win)
win.webContents.openDevTools();
})
}
}
/**
* before app close
*/
async beforeClose () {
// do some things
}
}
// Instantiate an app object
EE.app = new Main();
app.on('window-all-closed', () => {
// Log.info('[addon:tray] will be closed All system');
app.quit()
})
// 老项目拿过来的
ipcMain.on('window-min', () => {
if (!win) return
win.minimize()
})
ipcMain.on('window-max', () => {
if (!win) return
if (win.isMaximized()) {
win.unmaximize()
} else {
win.maximize()
}
})
ipcMain.on('window-close', () => {
if (!win) return
win.destroy()
})