1
0

Refactor drag-and-drop functionality in main.js and renderer.js

This commit is contained in:
2025-05-25 06:12:40 +02:00
parent 4b9545d780
commit 967e27d1b9
2 changed files with 23 additions and 30 deletions

View File

@@ -71,6 +71,29 @@ window.addEventListener('DOMContentLoaded', async () => {
return folders.find(f => f.path === path) || null;
}
document.body.addEventListener('dragover', e => {
e.preventDefault();
e.dataTransfer.dropEffect = 'copy';
});
document.body.addEventListener('drop', async e => {
e.preventDefault();
const files = [...e.dataTransfer.files];
if (!files.length) return;
// Prüfe, ob Ordner:
for (let f of files) {
// f ist File, hat .path und .type, aber bei Folders oft type="" (leerer String)
if (f.type === "" /* = Ordner (bei DnD) */) {
await window.electronAPI.addFolderByPath(f.path);
await renderSidebar();
const sel = await window.electronAPI.getSelected();
if (sel) await renderContent(sel);
}
}
});
async function renderSidebar() {
const folders = await window.electronAPI.getFolders();
console.log("Renderer-Folders:", folders);