-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmain.js
More file actions
103 lines (91 loc) · 2.15 KB
/
main.js
File metadata and controls
103 lines (91 loc) · 2.15 KB
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
const { app, BrowserWindow, ipcMain, dialog } = require("electron");
const path = require("path");
const url = require("url");
let mainWindow;
let dev = false;
if (
process.defaultApp ||
/[\\/]electron-prebuilt[\\/]/.test(process.execPath) ||
/[\\/]electron[\\/]/.test(process.execPath)
) {
dev = true;
}
function createWindow() {
mainWindow = new BrowserWindow({
width: 800,
height: 700,
frame: false,
show: false,
minHeight: 200,
minWidth: 350,
resizable: false
});
let indexPath;
if (dev && process.argv.indexOf("--noDevServer") === -1) {
indexPath = url.format({
protocol: "http:",
host: "localhost:4001",
pathname: "index.html",
slashes: true
});
} else {
indexPath = url.format({
protocol: "file:",
pathname: path.join(__dirname, "dist", "index.html"),
slashes: true
});
}
mainWindow.loadURL(indexPath);
mainWindow.once("ready-to-show", () => {
mainWindow.show();
if (dev) {
mainWindow.webContents.openDevTools();
}
});
mainWindow.on("closed", function() {
mainWindow = null;
});
}
app.on("ready", createWindow);
app.on("window-all-closed", () => {
if (process.platform !== "darwin") {
app.quit();
}
});
app.on("activate", () => {
if (mainWindow === null) {
createWindow();
}
});
ipcMain.on("open-file-dialog", function(event) {
dialog.showOpenDialog(
{ properties: ["openFile"], filters: [{ name: "Important Fixes", extensions: ["txt"] }] },
openPath => {
if (openPath) event.sender.send("selected-file", openPath);
}
);
});
ipcMain.on("open-html-dialog", function(event) {
dialog.showMessageBox(
mainWindow,
{
buttons: ["Find HTML File", "Start Over"],
type: "warning",
message:
"The html file was not found. Make sure fixes are in the same directory as the html file otherwise you will have to manually search for it below.",
title: "HTML NOT FOUND"
},
res => {
if (res == 0) {
dialog.showOpenDialog(
{ properties: ["openFile"], filters: [{ name: "Htlm File", extensions: ["htm", "html"] }] },
openPath => {
if (openPath) event.sender.send("html-file", openPath);
}
);
} else {
event.sender.send("go-back");
}
}
);
});