-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmain.js
46 lines (33 loc) · 1.08 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
const { app, BrowserWindow, ipcMain, dialog } = require('electron');
let mainWindow;
app.on('ready', () => {
mainWindow = new BrowserWindow({
webPreferences: {
preload: __dirname + '/preload.js', // Adjust the path if necessary
contextIsolation: true,
enableRemoteModule: false,
nodeIntegration: false,
},
width: 1800,
height: 1000
})
mainWindow.webContents.openDevTools({ mode: 'bottom' }); // Dock it at the bottom
mainWindow.loadFile('index.html')
});
ipcMain.handle('select-image', async () => {
const result = await dialog.showOpenDialog(mainWindow, {
title: 'Select an Image',
filters: [
{ name: 'Images', extensions: ['jpg', 'png', 'gif', 'jpeg', 'bmp'] }
],
properties: ['openFile']
});
// Return the file path if one is selected
return result.canceled ? null : result.filePaths[0];
});
app.whenReady().then(() => {
createWindow()
})
app.on('window-all-closed', () => {
if (process.platform !== 'darwin') app.quit()
})