Soundboard: Drag & Drop mit Rename-Modal

- MP3/WAV per Drag & Drop ablegen öffnet jetzt ein Rename-Modal
- Jede Datei einzeln benennen vor dem Upload (sequentiell bei mehreren)
- Server-Upload-Endpoint unterstützt optionalen customName Parameter
- Reuse der bestehenden dl-modal CSS-Klassen für konsistentes Design
- Überspringen-Option bei mehreren Dateien

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
Daniel 2026-03-08 19:11:16 +01:00
parent 86874daf57
commit 2c570febd1
2 changed files with 194 additions and 35 deletions

View file

@ -1223,6 +1223,22 @@ const soundboardPlugin: Plugin = {
if (err) { res.status(400).json({ error: err?.message ?? 'Upload fehlgeschlagen' }); return; }
const files = (req as any).files as any[] | undefined;
if (!files?.length) { res.status(400).json({ error: 'Keine gültigen Dateien' }); return; }
// If a customName was provided, rename the first file
const customName = req.body?.customName?.trim();
if (customName && files.length === 1) {
const sanitized = customName.replace(/[<>:"/\\|?*\x00-\x1f]/g, '_');
const newFilename = sanitized.endsWith('.mp3') || sanitized.endsWith('.wav')
? sanitized : `${sanitized}.mp3`;
const oldPath = files[0].path;
const newPath = path.join(path.dirname(oldPath), newFilename);
if (!fs.existsSync(newPath)) {
fs.renameSync(oldPath, newPath);
files[0].filename = newFilename;
files[0].path = newPath;
}
}
if (NORMALIZE_ENABLE) { for (const f of files) normalizeToCache(f.path).catch(() => {}); }
res.json({ ok: true, files: files.map(f => ({ name: f.filename, size: f.size })) });
});