-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathmain.js
74 lines (66 loc) · 1.63 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
const electron = require("electron");
const path = require("path");
const fs = require("fs");
const { app, BrowserWindow, Menu, ipcMain } = electron;
let win;
// ============Blank Menu==================
let template = [];
let menu = Menu.buildFromTemplate(template);
// ===========Window Creation==============
const createWindow = () => {
win = new BrowserWindow({
title: "Shōjiki",
show: false,
frame: false,
resizable: false,
movable: false,
minimizable: false,
alwaysOnTop: true,
kiosk: true,
webPreferences: {
nodeIntegration: true,
contextIsolation: false,
enableRemoteModule: true,
},
});
win.loadFile("src/index.html");
win.webContents.on("before-input-event", (event, input) => {
if (input.control && input.key.toLowerCase() === "v") {
event.preventDefault();
win.webContents.send("copy");
}
if (input.control && input.key.toLowerCase() === "c") {
event.preventDefault();
win.webContents.send("copy");
}
});
Menu.setApplicationMenu(menu);
// win.toggleDevTools();
win.on("ready-to-show", () => {
win.show();
});
win.on("closed", () => {
win = null;
});
};
// ==========IPC Events============
ipcMain.on("close", () => {
app.quit();
});
// ipcMain.on('image', (event, data)=>{
// fs.writeFile('image.png', data.photoData, 'base64', () => {
// console.log('saved')
// })
// })
// ===========App Events===========
app.on("ready", createWindow);
app.on("window-all-closed", () => {
if (process.platform !== "darwin") {
app.quit();
}
});
app.on("activate", () => {
if (win === null) {
createWindow();
}
});