-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathmain.js
111 lines (75 loc) · 2.79 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
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
import {app, ipcMain, crashReporter, screen, BrowserWindow, Menu} from 'electron';
import * as controllers from './main/controllers';
import bindEventName from './main/decorators/bindEventName';
import {Helper, MenuConfig} from './main/services';
import {PATH_APP_DOC} from './main/constants/appConstants';
const ipc = bindEventName(ipcMain);
crashReporter.start({
companyName: 'dharma-treasure',
submitURL: 'https://log.dharma-treasure.org/ketaka-lite'
});
let mainWindow = null;
let closeConfirmed = false;
app.on('window-all-closed', () => {
app.quit();
});
app.on('ready', () => {
let size = screen.getPrimaryDisplay().workAreaSize;
mainWindow = new BrowserWindow({width: size.width, height: size.height});
Helper.mkdirp(PATH_APP_DOC)
.then(() => {
mainWindow.loadURL('file://' + __dirname + '/index.html');
mainWindow.on('close', event => {
if (! closeConfirmed) {
event.preventDefault();
mainWindow.webContents.send('app-close');
}
});
ipc.on('close', () => {
if (app._isExportingZip) {
mainWindow.webContents.send('app-still-exporting-zip');
return false;
}
closeConfirmed = true;
mainWindow.close();
});
ipc.on('trigger-undo', () => {
mainWindow.webContents.undo();
});
ipc.on('trigger-redo', () => {
mainWindow.webContents.redo();
});
ipc.on('trigger-selectall', () => {
mainWindow.webContents.selectAll();
});
mainWindow.on('closed', () => {
mainWindow = null;
});
});
});
app.once('ready', () => {
let template = MenuConfig.getTemplate({mainWindow: mainWindow});
let menu = Menu.buildFromTemplate(template);
Menu.setApplicationMenu(menu);
});
ipc.on('import-button-clicked', controllers.importButtonClicked);
ipc.on('import-zip', controllers.importZip);
ipc.on('save', controllers.save);
ipc.on('save-as', controllers.saveAs);
ipc.on('page-image-upload-button-clicked', controllers.pageImageUploadButtonClicked);
ipc.on('add-doc', controllers.addDoc);
ipc.on('list-doc-name', controllers.listDocName);
ipc.on('change-doc-settings', controllers.changeDocSettings);
ipc.on('open', controllers.open);
ipc.on('open-bamboo', controllers.openBamboo);
ipc.on('delete-doc', controllers.deleteDoc);
ipc.on('delete-docs', controllers.deleteDocs);
ipc.on('export-zip', controllers.exportZip);
ipc.on('export-file-with-pb', controllers.exportFileWithPb);
ipc.on('add-pb-files', controllers.addPbFiles);
ipc.on('get-app-data', controllers.getAppData);
ipc.on('get-versions', controllers.getVersions);
ipc.on('delete-page-image', controllers.deletePageImage);
ipc.on('add-history', controllers.addHistory);
ipc.on('undo-history', controllers.undoHistory);
ipc.on('redo-history', controllers.redoHistory);