-
Notifications
You must be signed in to change notification settings - Fork 3
/
index.js
executable file
·73 lines (59 loc) · 2.1 KB
/
index.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
const { app } = require('electron');
const path = require('path');
const { ipcMain } = require('electron');
const { readFileSync } = require('./app/utils/write-file');
const { checkEnvFiles } = require('./app/utils/utils');
const { MessageChannel, BrowserService } = require('electron-re');
const requireLang = require('./app/lang');
/* ------------------- Env ------------------- */
global.nodeEnv = process.env.NODE_ENV;
global.pathRuntime = checkEnvFiles().pathRuntime;
const { result, error } = readFileSync(path.join(app.getAppPath(), 'app/runtime/database/setting.json'), true);
requireLang(result ? result.lang : '');
/* ------------------- self module ------------------- */
global.pathLocator = require('./app/utils/path-locator.js');
global.consoleLog = require('./app/utils/console-log.js');
const IpcMainClass = require('./app/services/main/');
const IpcMaiWindowClass = require('./app/services/main/ipcMainWindow');
const fsChmodShell = require('./app/utils/fs-chmod-shell.js');
/* ------------------- Middleware ------------------- */
fsChmodShell();
global.ipcMainProcess = new IpcMainClass(ipcMain);
global.ipcMainWindow = new IpcMaiWindowClass();
/* -------------- listener -------------- */
app.on('ready', () => {
if (global.nodeEnv === 'development') {
require('source-map-support').install();
}
/* services */
this.appService = new BrowserService('app', path.join(app.getAppPath(), 'app/services/child/app.service.js'), {
webContents: {
webSecurity: false,
},
});
global.ipcMainWindow.createWindow();
});
app.on('window-all-closed', () => {
console.log('window-all-closed');
global.ipcMainWindow.writeAppConf().then(() => 0, (err) => {
console.error(err);
throw new Error('App quit: view-conf write error !');
});
if (process.platform !== 'darwin') {
app.quit();
}
});
app.on('will-quit', () => {
console.log('will-quit');
});
app.on('before-quit', () => {
console.log('before-quit');
});
app.on('quit', () => {
console.log('quit');
});
app.on('activate', () => {
if (global.ipcMainWindow.window === null) {
global.ipcMainWindow.createWindow();
}
});