Compare commits
No commits in common. "8b519a85bc3ef1aafd2d9a440db6088d8e570974" and "af7b0d88cfcfbb0286684cf07b1cf12f5923fb96" have entirely different histories.
8b519a85bc
...
af7b0d88cf
55
main.js
55
main.js
|
|
@ -1,55 +1,30 @@
|
||||||
const { app, BrowserWindow, ipcMain, dialog } = require('electron');
|
const { app, BrowserWindow } = require('electron')
|
||||||
const path = require('path');
|
|
||||||
|
|
||||||
let mainWindow;
|
|
||||||
|
|
||||||
function createWindow() {
|
function createWindow() {
|
||||||
mainWindow = new BrowserWindow({
|
const win = new BrowserWindow({
|
||||||
width: 1200,
|
width: 1200,
|
||||||
height: 800,
|
height: 800,
|
||||||
webPreferences: {
|
webPreferences: {
|
||||||
nodeIntegration: true,
|
nodeIntegration: true
|
||||||
contextIsolation: false,
|
|
||||||
webviewTag: true
|
|
||||||
}
|
}
|
||||||
});
|
})
|
||||||
|
|
||||||
mainWindow.loadFile(path.join(__dirname, 'renderer/index.html'));
|
win.loadURL('https://photos.onedrive.com')
|
||||||
mainWindow.setTitle('OneDrive Photos');
|
win.setTitle('OneDrive Photos')
|
||||||
}
|
}
|
||||||
|
|
||||||
app.whenReady().then(createWindow);
|
app.whenReady().then(() => {
|
||||||
|
createWindow()
|
||||||
app.on('window-all-closed', () => {
|
|
||||||
if (process.platform !== 'darwin') {
|
|
||||||
app.quit();
|
|
||||||
}
|
|
||||||
});
|
|
||||||
|
|
||||||
app.on('activate', () => {
|
app.on('activate', () => {
|
||||||
if (BrowserWindow.getAllWindows().length === 0) {
|
if (BrowserWindow.getAllWindows().length === 0) {
|
||||||
createWindow();
|
createWindow()
|
||||||
}
|
}
|
||||||
});
|
})
|
||||||
|
})
|
||||||
|
|
||||||
// Modified IPC handlers
|
app.on('window-all-closed', () => {
|
||||||
ipcMain.on('toggle-config', () => {
|
if (process.platform !== 'darwin') {
|
||||||
mainWindow.webContents.send('toggle-config');
|
app.quit()
|
||||||
});
|
|
||||||
|
|
||||||
ipcMain.on('set-config', (event, config) => {
|
|
||||||
console.log('Destination Folder:', config.destFolder);
|
|
||||||
console.log('OneDrive Source Path:', config.onedriveSource);
|
|
||||||
});
|
|
||||||
|
|
||||||
ipcMain.on('select-folder', (event) => {
|
|
||||||
dialog.showOpenDialog({
|
|
||||||
properties: ['openDirectory']
|
|
||||||
}).then(result => {
|
|
||||||
if (!result.canceled) {
|
|
||||||
event.reply('folder-selected', result.filePaths[0]);
|
|
||||||
}
|
}
|
||||||
}).catch(err => {
|
})
|
||||||
console.log(err);
|
|
||||||
});
|
|
||||||
});
|
|
||||||
|
|
|
||||||
|
|
@ -1,42 +0,0 @@
|
||||||
<!DOCTYPE html>
|
|
||||||
<html lang="en">
|
|
||||||
<head>
|
|
||||||
<meta charset="UTF-8">
|
|
||||||
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
|
||||||
<title>Configuration</title>
|
|
||||||
</head>
|
|
||||||
<body>
|
|
||||||
<h1>Configuration</h1>
|
|
||||||
<form id="config-form">
|
|
||||||
<div>
|
|
||||||
<label for="dest-folder">Destination Folder for Photo Sync:</label>
|
|
||||||
<input type="text" id="dest-folder" name="dest-folder" readonly>
|
|
||||||
<button type="button" id="select-folder">Select Folder</button>
|
|
||||||
</div>
|
|
||||||
<div>
|
|
||||||
<label for="onedrive-source">OneDrive Source Path:</label>
|
|
||||||
<input type="text" id="onedrive-source" name="onedrive-source">
|
|
||||||
</div>
|
|
||||||
<button type="submit">Save</button>
|
|
||||||
</form>
|
|
||||||
|
|
||||||
<script>
|
|
||||||
const { ipcRenderer } = require('electron');
|
|
||||||
|
|
||||||
document.getElementById('select-folder').addEventListener('click', () => {
|
|
||||||
ipcRenderer.send('select-folder');
|
|
||||||
});
|
|
||||||
|
|
||||||
ipcRenderer.on('folder-selected', (event, path) => {
|
|
||||||
document.getElementById('dest-folder').value = path;
|
|
||||||
});
|
|
||||||
|
|
||||||
document.getElementById('config-form').addEventListener('submit', (event) => {
|
|
||||||
event.preventDefault();
|
|
||||||
const destFolder = document.getElementById('dest-folder').value;
|
|
||||||
const onedriveSource = document.getElementById('onedrive-source').value;
|
|
||||||
ipcRenderer.send('set-config', { destFolder, onedriveSource });
|
|
||||||
});
|
|
||||||
</script>
|
|
||||||
</body>
|
|
||||||
</html>
|
|
||||||
|
|
@ -1,149 +0,0 @@
|
||||||
<!DOCTYPE html>
|
|
||||||
<html>
|
|
||||||
<head>
|
|
||||||
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/6.5.1/css/all.min.css">
|
|
||||||
<style>
|
|
||||||
body {
|
|
||||||
margin: 0;
|
|
||||||
overflow-x: hidden;
|
|
||||||
}
|
|
||||||
#config-panel {
|
|
||||||
position: fixed;
|
|
||||||
width: 300px;
|
|
||||||
height: 100vh;
|
|
||||||
right: -300px;
|
|
||||||
top: 0;
|
|
||||||
background: white;
|
|
||||||
border-left: 1px solid #ccc;
|
|
||||||
padding: 20px;
|
|
||||||
box-sizing: border-box;
|
|
||||||
transition: right 0.3s ease-in-out;
|
|
||||||
z-index: 1000;
|
|
||||||
}
|
|
||||||
#config-panel.open {
|
|
||||||
right: 0;
|
|
||||||
}
|
|
||||||
#main-content {
|
|
||||||
width: 100vw;
|
|
||||||
height: 100vh;
|
|
||||||
border: none;
|
|
||||||
}
|
|
||||||
#config-button {
|
|
||||||
position: fixed;
|
|
||||||
top: 10px;
|
|
||||||
right: 180px;
|
|
||||||
z-index: 1000;
|
|
||||||
padding: 8px 16px;
|
|
||||||
background: transparent;
|
|
||||||
color: #0078d4;
|
|
||||||
border: 1px solid #0078d4;
|
|
||||||
border-radius: 4px;
|
|
||||||
cursor: pointer;
|
|
||||||
font-size: 14px;
|
|
||||||
display: flex;
|
|
||||||
align-items: center;
|
|
||||||
gap: 6px;
|
|
||||||
height: 32px;
|
|
||||||
transition: all 0.2s;
|
|
||||||
margin-right: 8px;
|
|
||||||
}
|
|
||||||
#config-button:hover {
|
|
||||||
background: #f0f8ff;
|
|
||||||
}
|
|
||||||
#config-button i {
|
|
||||||
font-size: 14px;
|
|
||||||
}
|
|
||||||
.close-button {
|
|
||||||
position: absolute;
|
|
||||||
top: 10px;
|
|
||||||
right: 10px;
|
|
||||||
background: none;
|
|
||||||
border: none;
|
|
||||||
font-size: 24px;
|
|
||||||
cursor: pointer;
|
|
||||||
padding: 5px 10px;
|
|
||||||
color: #666;
|
|
||||||
transition: color 0.2s;
|
|
||||||
}
|
|
||||||
.close-button:hover {
|
|
||||||
color: #333;
|
|
||||||
}
|
|
||||||
.panel-header {
|
|
||||||
display: flex;
|
|
||||||
justify-content: space-between;
|
|
||||||
align-items: center;
|
|
||||||
margin-bottom: 20px;
|
|
||||||
padding-right: 40px;
|
|
||||||
}
|
|
||||||
.close-button i {
|
|
||||||
font-size: 18px;
|
|
||||||
}
|
|
||||||
</style>
|
|
||||||
</head>
|
|
||||||
<body>
|
|
||||||
<button id="config-button">
|
|
||||||
<i class="fas fa-cog"></i>
|
|
||||||
Configuration
|
|
||||||
</button>
|
|
||||||
<webview id="main-content" src="https://photos.onedrive.com"></webview>
|
|
||||||
<div id="config-panel">
|
|
||||||
<button class="close-button" id="close-config">
|
|
||||||
<i class="fas fa-arrow-right"></i>
|
|
||||||
</button>
|
|
||||||
<div class="panel-header">
|
|
||||||
<h1>Configuration</h1>
|
|
||||||
</div>
|
|
||||||
<form id="config-form">
|
|
||||||
<div>
|
|
||||||
<label for="dest-folder">Destination Folder for Photo Sync:</label>
|
|
||||||
<input type="text" id="dest-folder" name="dest-folder" readonly>
|
|
||||||
<button type="button" id="select-folder">Select Folder</button>
|
|
||||||
</div>
|
|
||||||
<div>
|
|
||||||
<label for="onedrive-source">OneDrive Source Path:</label>
|
|
||||||
<input type="text" id="onedrive-source" name="onedrive-source">
|
|
||||||
</div>
|
|
||||||
<button type="submit">Save</button>
|
|
||||||
</form>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
<script>
|
|
||||||
const { ipcRenderer } = require('electron');
|
|
||||||
|
|
||||||
// Configuration button handler
|
|
||||||
document.getElementById('config-button').addEventListener('click', () => {
|
|
||||||
ipcRenderer.send('toggle-config');
|
|
||||||
});
|
|
||||||
|
|
||||||
// Configuration panel toggle
|
|
||||||
ipcRenderer.on('toggle-config', () => {
|
|
||||||
const panel = document.getElementById('config-panel');
|
|
||||||
panel.classList.toggle('open');
|
|
||||||
});
|
|
||||||
|
|
||||||
// Folder selection
|
|
||||||
document.getElementById('select-folder').addEventListener('click', () => {
|
|
||||||
ipcRenderer.send('select-folder');
|
|
||||||
});
|
|
||||||
|
|
||||||
ipcRenderer.on('folder-selected', (event, path) => {
|
|
||||||
document.getElementById('dest-folder').value = path;
|
|
||||||
});
|
|
||||||
|
|
||||||
// Form submission
|
|
||||||
document.getElementById('config-form').addEventListener('submit', (event) => {
|
|
||||||
event.preventDefault();
|
|
||||||
const destFolder = document.getElementById('dest-folder').value;
|
|
||||||
const onedriveSource = document.getElementById('onedrive-source').value;
|
|
||||||
ipcRenderer.send('set-config', { destFolder, onedriveSource });
|
|
||||||
// Close the panel after saving
|
|
||||||
document.getElementById('config-panel').classList.remove('open');
|
|
||||||
});
|
|
||||||
|
|
||||||
// Add close button handler
|
|
||||||
document.getElementById('close-config').addEventListener('click', () => {
|
|
||||||
document.getElementById('config-panel').classList.remove('open');
|
|
||||||
});
|
|
||||||
</script>
|
|
||||||
</body>
|
|
||||||
</html>
|
|
||||||
Loading…
Reference in New Issue