Skip to content

Commit 29079b5

Browse files
committed
first commit
0 parents  commit 29079b5

File tree

11 files changed

+3856
-0
lines changed

11 files changed

+3856
-0
lines changed

build/icon.ico

5.58 KB
Binary file not shown.

build/icon.png

39.1 KB
Loading

main.js

Lines changed: 65 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,65 @@
1+
const { app, BrowserWindow, ipcMain } = require("electron");
2+
const windowStateKeeper = require("electron-window-state");
3+
const readItem = require("./readItem");
4+
5+
let mainWindow;
6+
7+
// Listen for new item request
8+
ipcMain.on("new-item", (e, itemUrl) => {
9+
console.log(itemUrl);
10+
11+
// Get new item and send back to renderer
12+
readItem(itemUrl, (item) => {
13+
e.sender.send("new-item-success", item);
14+
});
15+
});
16+
17+
const createWindow = function () {
18+
// Win state keeper
19+
let state = windowStateKeeper({
20+
defaultWidth: 500,
21+
defaultHeight: 650,
22+
});
23+
24+
mainWindow = new BrowserWindow({
25+
x: state.x,
26+
y: state.y,
27+
width: state.width,
28+
height: state.height,
29+
minWidth: 350,
30+
maxWidth: 650,
31+
minHeight: 300,
32+
webPreferences: { nodeIntegration: true, contextIsolation: false },
33+
});
34+
35+
mainWindow.loadFile("./renderer/main.html");
36+
37+
state.manage(mainWindow);
38+
39+
// mainWindow.webContents.openDevTools();
40+
41+
mainWindow.webContents.setWindowOpenHandler(({ url }) => {
42+
return {
43+
action: "allow",
44+
overrideBrowserWindowOptions: {
45+
webPreferences: {
46+
preload: `${__dirname}/renderer/reader.js`,
47+
},
48+
},
49+
};
50+
});
51+
52+
mainWindow.on("closed", () => {
53+
mainWindow = null;
54+
});
55+
};
56+
57+
app.on("ready", createWindow);
58+
59+
app.on("window-all-closed", () => {
60+
if (process.platform !== "darwin") app.quit();
61+
});
62+
63+
app.on("activate", () => {
64+
if (mainWindow === null) createWindow();
65+
});

0 commit comments

Comments
 (0)