diff --git a/backend/main.py b/backend/main.py index d6721ba..5a66f54 100644 --- a/backend/main.py +++ b/backend/main.py @@ -197,5 +197,20 @@ async def api_download(path: str): return FileResponse(file_path, filename=file_path.name) +import shutil + +@app.delete("/api/folders/{folder_name}") +async def api_delete_folder(folder_name: str): + """Удаляет папку с обработанными файлами.""" + folder_path = PROCESSED_DIR / folder_name + if not folder_path.exists(): + return {"error": "Folder not found"} + try: + shutil.rmtree(folder_path) + return {"deleted": folder_name} + except Exception as e: + return {"error": str(e)} + + # Статические файлы app.mount("/static", StaticFiles(directory="backend/static"), name="static") diff --git a/backend/static/app.js b/backend/static/app.js index cbcdac7..036c44b 100644 --- a/backend/static/app.js +++ b/backend/static/app.js @@ -240,12 +240,13 @@ class TranscriptionApp { }).join(''); return ` -
Нет обработанных файлов
'; + } + } + } catch (error) { + this.showToast(`Ошибка удаления: ${error.message}`, 'error'); + } + } + // ===== Viewer ===== async loadFileContent(path, ext) { const viewer = document.getElementById('viewer'); diff --git a/backend/static/styles.css b/backend/static/styles.css index afd7f1b..72005c9 100644 --- a/backend/static/styles.css +++ b/backend/static/styles.css @@ -254,6 +254,21 @@ header h1 { color: var(--text-secondary); } +.folder-delete { + font-size: 1rem; + cursor: pointer; + padding: 2px 6px; + border-radius: 4px; + transition: background 0.2s; + margin-left: 8px; + opacity: 0.6; +} + +.folder-delete:hover { + background: rgba(248, 113, 113, 0.2); + opacity: 1; +} + .folder-files { margin-left: 24px; padding-left: 8px;