-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.js
56 lines (51 loc) · 1.03 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
// @ts-check
// Electron entry point
const { BrowserWindow, app, ipcMain, dialog } = require('electron')
const { join } = require('path')
const electronOpenDb = require('./src/controllers/db/electronOpenDb')
const { selectImage } = require('./src/controllers/electronBridges/bridgesNames')
const createInitialWindow = () => {
const win = new BrowserWindow({
webPreferences: {
nodeIntegration: true,
preload: join(
__dirname,
'preload.js'
)
}
})
win.maximize()
win.loadURL('http://localhost:3000')
win.on(
'closed',
() => {
const db = electronOpenDb()
db.close()
}
)
}
ipcMain.handle(
selectImage,
async (ev) => {
const image = await dialog.showOpenDialog({
filters: [
{
extensions: [
'jpg',
'png',
'gif',
'jpeg',
'webp'
],
name: 'Images'
}
],
properties: ['openFile']
})
return image
}
)
app.on(
'ready',
createInitialWindow
)