-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathmain.js
58 lines (46 loc) · 1.37 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
const { app, BrowserWindow, Menu, ipcMain } = require('electron');
const create_window = (template) => {
// Create the browser window.
let win = new BrowserWindow({ fullscreen : false, resizable : true });
// and load the index.html of the app.
win.loadFile(template);
};
menu_template = [
{
label: "Point Cloud Visualizer",
submenu: [
{
label: 'Preference',
click: () => { create_window("config.html"); },
accelerator: process.platform === 'darwin' ? 'Cmd+,' : 'Ctrl+,'
},
{role: 'toggledevtools'},
{role: 'quit'},
{role: 'close'}
]
},
];
const menu = Menu.buildFromTemplate(menu_template);
Menu.setApplicationMenu(menu);
const initGlobalShareObj = (event, arg) => {
global.shareObj = {
filenames : null,
filepaths : null,
extensions : null,
};
};
const setGlobalShareObj = (event, data) => {
global.shareObj = data;
};
initGlobalShareObj();
setGlobalShareObj();
ipcMain.on('init-global-share-object', initGlobalShareObj);
ipcMain.on('set-global-share-object', setGlobalShareObj);
ipcMain.on('open-config', () => {create_window("config.html")});
ipcMain.on('quit-app', () => {app.quit();});
app.on('ready', () => {
create_window("index.html");
});
app.on('close', () => {
app.quit();
});