-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.js
49 lines (41 loc) · 1.21 KB
/
index.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
"use strict";
const { app, BrowserWindow, ipcMain } = require("electron"),
Read = require("./Read.js");
function createWindow() {
const win = new BrowserWindow({ width: 800, height: 600, frame:false });
let actualReader=null;
win.loadFile("./src/views/index.html");
win.openDevTools();
ipcMain.on("loadFile", async (event, path) => {
actualReader=new Read(path,event);
await actualReader.loadPDF();
event.sender.send("getFile",actualReader.text,actualReader.wordIndex);
});
ipcMain.on("reloadFile", async (event, path) => {
if(actualReader!==null){
await actualReader.loadPDF(true);
event.sender.send("getFile",actualReader.text,actualReader.wordIndex);
}
});
ipcMain.on("saveData", (event, wordIndex) => {
if(actualReader!==null){
actualReader.saveData();
}
});
ipcMain.on("onSpeedChange", (event, speed) => {
if(actualReader!==null){
actualReader.speed=speed;
}
});
ipcMain.on("updateWordIndex", (event, wordIndex) => {
if(actualReader!==null){
actualReader.wordIndex=wordIndex;
}
});
win.on("close", function() {
if(actualReader!==null){
actualReader.saveData();
}
});
}
app.on("ready", createWindow);