-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathindex.ts
76 lines (59 loc) · 1.6 KB
/
index.ts
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
import { app, BrowserWindow, ipcMain } from 'electron';
import * as path from 'path';
import * as url from 'url';
import * as Knex from 'knex';
let win;
let knex = Knex({
client: "sqlite3",
connection: {
filename: "./database.sqlite",
},
});
function createWindow(): BrowserWindow {
win = new BrowserWindow({
width: 1280,
height: 800,
icon: 'src/assets/minBlogger-grey.ico',
// frame: false,
webPreferences: {
nodeIntegration: true,
allowRunningInsecureContent: false
}
});
// require('electron-reload')(__dirname, {
// electron: require(`${__dirname}/node_modules/electron`)
// });
win.loadURL(`http://localhost:4200`);
win.on('closed', () => {
win = null;
});
// ipcMain.on("mainWindowLoaded", function () {
// let result = knex.select("FirstName").from("User");
// result.then(function (rows) {
// console.log(rows);
// win.webContents.send("resultSent", rows);
// });
// });
knex.select("*").from("User").then((rows) => {
console.log("Testing sqlite in electron with * Users => ", rows);
});
// win.webContents.on('did-finish-load', () => {
// ipcMain.on('ping', (event, arg) => {
// console.log(arg); // prints "ping by Welcome"
// event.returnValue = 'pong by Electron';
// });
// });
return win;
}
try {
app.allowRendererProcessReuse = true;
app.on('ready', createWindow);
app.on('window-all-closed', () => {
if (process.platform !== 'darwin') { app.quit(); }
});
app.on('activate', () => {
if (win == null) { createWindow(); }
});
} catch (error) {
throw error;
}