2023-08-28 11:23:10 +00:00
|
|
|
const { app, BrowserWindow, ipcMain, dialog } = require('electron/main')
|
2023-07-17 08:30:53 +00:00
|
|
|
const path = require('node:path')
|
2022-02-09 16:00:05 +00:00
|
|
|
|
2023-04-05 13:42:20 +00:00
|
|
|
async function handleFileOpen () {
|
2022-02-09 16:00:05 +00:00
|
|
|
const { canceled, filePaths } = await dialog.showOpenDialog()
|
2023-05-15 07:58:35 +00:00
|
|
|
if (!canceled) {
|
2022-02-09 16:00:05 +00:00
|
|
|
return filePaths[0]
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
function createWindow () {
|
|
|
|
const mainWindow = new BrowserWindow({
|
|
|
|
webPreferences: {
|
|
|
|
preload: path.join(__dirname, 'preload.js')
|
|
|
|
}
|
|
|
|
})
|
|
|
|
mainWindow.loadFile('index.html')
|
|
|
|
}
|
|
|
|
|
|
|
|
app.whenReady().then(() => {
|
|
|
|
ipcMain.handle('dialog:openFile', handleFileOpen)
|
|
|
|
createWindow()
|
|
|
|
app.on('activate', function () {
|
|
|
|
if (BrowserWindow.getAllWindows().length === 0) createWindow()
|
|
|
|
})
|
|
|
|
})
|
|
|
|
|
|
|
|
app.on('window-all-closed', function () {
|
|
|
|
if (process.platform !== 'darwin') app.quit()
|
|
|
|
})
|