-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.js
111 lines (98 loc) · 2.31 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
// importing stuff
const {
app,
BrowserWindow,
Menu,
ipcMain
} = require('electron');
const url = require('url');
const path = require('path');
// variables
let mainWindow;
let giphyWindow;
// menus
const menuTemplate = [{
label: 'File',
submenu: [{
label: 'Quit',
accelerator: process.platform === 'darwin' ? 'command+Q' : 'ctrl+Q',
click() {
app.exit();
}
},
{
type: 'separator'
},
{
label: 'reload',
accelerator: 'ctrl+R',
click() {
mainWindow.reload()
}
},
]
}];
// context menu
const ctxMenu = [{
label: "New Folder"
},
{
label: "Select All"
}
];
// main stuff
app.on('ready', () => {
const mainWindow = new BrowserWindow({
webPreferences: {
nodeIntegration: true
}
});
// mainWindow.webContents.openDevTools();
mainWindow.setFullScreen(true);
mainWindow.loadURL(url.format({
pathname: path.join(__dirname, 'src/index.html'),
protocol: 'file:',
slashes: true
})).then();
const context = Menu.buildFromTemplate(ctxMenu);
const mainMenu = Menu.buildFromTemplate(menuTemplate);
Menu.setApplicationMenu(mainMenu);
mainWindow.webContents.on('context-menu', (e, params) => {
context.popup(mainWindow, params.x, params.y);
});
});
// giphy app
const openGiphy = () => {
giphyWindow = new BrowserWindow({
width: 3000,
height: 1000,
title: 'Get a GIF'
});
giphyWindow.loadURL(url.format({
pathname: path.join(__dirname, 'src/app/giphy/gag.html'),
protocol: 'file:',
slashes: true
})).then();
}
const openNotepad = () => {
giphyWindow = new BrowserWindow({
width: 1000,
height: 700,
title: 'NOTEPAD'
});
giphyWindow.loadURL(url.format({
pathname: path.join(__dirname, 'src/app/notepad/np.html'),
protocol: 'file:',
slashes: true
})).then();
}
// opening apps
ipcMain.on('open', (event, arg) => {
if (arg == 'giphy') {
openGiphy();
console.log('giphy opened')
} else if (arg == 'notepad') {
openNotepad();
console.log('Notepad opened')
}
})