diff --git a/main.js b/main.js index b7e1e52..46ba270 100644 --- a/main.js +++ b/main.js @@ -2,7 +2,6 @@ const { app, BrowserWindow, ipcMain, dialog } = require('electron'); const path = require('path'); let mainWindow; -let configWindow; function createWindow() { mainWindow = new BrowserWindow({ @@ -11,59 +10,15 @@ function createWindow() { webPreferences: { nodeIntegration: true, contextIsolation: false, + webviewTag: true } }); - mainWindow.loadURL('https://photos.onedrive.com'); + mainWindow.loadFile(path.join(__dirname, 'renderer/index.html')); mainWindow.setTitle('OneDrive Photos'); - - // Open the DevTools. - // mainWindow.webContents.openDevTools(); - - // Add this to the createWindow function - mainWindow.webContents.on('did-finish-load', () => { - mainWindow.webContents.executeJavaScript(` - const button = document.createElement('button'); - button.textContent = 'Open Configuration'; - button.style.position = 'fixed'; - button.style.top = '10px'; - button.style.right = '10px'; - button.style.zIndex = '1000'; - button.addEventListener('click', () => { - require('electron').ipcRenderer.send('open-config-window'); - }); - document.body.appendChild(button); - `); - }); } -function createConfigWindow() { - configWindow = new BrowserWindow({ - width: 600, - height: 400, - webPreferences: { - nodeIntegration: true, - contextIsolation: false, - } - }); - - // Load config.html from the renderer directory - configWindow.loadFile(path.join(__dirname, 'renderer/config.html')); - configWindow.setTitle('Configuration'); - - // Open the DevTools. - // configWindow.webContents.openDevTools(); -} - -app.whenReady().then(() => { - createWindow(); - - app.on('activate', () => { - if (BrowserWindow.getAllWindows().length === 0) { - createWindow(); - } - }); -}); +app.whenReady().then(createWindow); app.on('window-all-closed', () => { if (process.platform !== 'darwin') { @@ -71,25 +26,20 @@ app.on('window-all-closed', () => { } }); -// Handle configuration settings -ipcMain.on('open-config-window', () => { - if (!configWindow) { - createConfigWindow(); - } else { - configWindow.focus(); +app.on('activate', () => { + if (BrowserWindow.getAllWindows().length === 0) { + createWindow(); } }); +// Modified IPC handlers +ipcMain.on('toggle-config', () => { + mainWindow.webContents.send('toggle-config'); +}); + ipcMain.on('set-config', (event, config) => { - // Save the configuration settings (you can use a file or a database) console.log('Destination Folder:', config.destFolder); console.log('OneDrive Source Path:', config.onedriveSource); - - // Close the configuration window - if (configWindow) { - configWindow.close(); - configWindow = null; - } }); ipcMain.on('select-folder', (event) => { diff --git a/renderer/index.html b/renderer/index.html new file mode 100644 index 0000000..6587aaa --- /dev/null +++ b/renderer/index.html @@ -0,0 +1,149 @@ + + + + + + + + + +
+ +
+

Configuration

+
+
+
+ + + +
+
+ + +
+ +
+
+ + + +