diff --git a/frontend/src/components/file-browser/FileTree.tsx b/frontend/src/components/file-browser/FileTree.tsx
index 2c98daa5..cb103d58 100644
--- a/frontend/src/components/file-browser/FileTree.tsx
+++ b/frontend/src/components/file-browser/FileTree.tsx
@@ -1,7 +1,9 @@
import { useState, memo } from 'react'
+import { useMobile } from '@/hooks/useMobile'
import { Button } from '@/components/ui/button'
import { Input } from '@/components/ui/input'
import { DeleteDialog } from '@/components/ui/delete-dialog'
+import { API_BASE_URL } from '@/config'
import {
File,
Folder,
@@ -10,7 +12,8 @@ import {
ChevronDown,
MoreHorizontal,
Trash2,
- Edit3
+ Edit3,
+ Download
} from 'lucide-react'
import {
DropdownMenu,
@@ -42,6 +45,7 @@ interface TreeNodeProps {
}
function TreeNode({ file, level, onFileSelect, onDirectoryClick, selectedFile, onDelete, onRename }: TreeNodeProps) {
+ const isMobile = useMobile()
const [expanded, setExpanded] = useState(false)
const [editing, setEditing] = useState(false)
const [editName, setEditName] = useState(file.name)
@@ -86,6 +90,18 @@ function TreeNode({ file, level, onFileSelect, onDirectoryClick, selectedFile, o
setEditName(file.name)
}
+ const handleDownload = () => {
+ if (file.isDirectory) return
+
+ const downloadUrl = `${API_BASE_URL}/api/files/${file.path}?download=true`
+ const link = document.createElement('a')
+ link.href = downloadUrl
+ link.download = file.name
+ document.body.appendChild(link)
+ link.click()
+ document.body.removeChild(link)
+ }
+
const getFileIcon = () => {
if (file.isDirectory) {
return expanded ? :
@@ -167,12 +183,18 @@ function TreeNode({ file, level, onFileSelect, onDirectoryClick, selectedFile, o
+ {!file.isDirectory && (
+
+
+ Download
+
+ )}
Rename