feat(remote): 下载改成本地面板选择目录
This commit is contained in:
@@ -17,6 +17,7 @@ export const FileTransferPage: React.FC<FileTransferPageProps> = ({ serverHost,
|
||||
const [localSelected, setLocalSelected] = useState<FileItem | null>(null)
|
||||
const [remoteSelected, setRemoteSelected] = useState<RemoteFileItem | null>(null)
|
||||
const [remotePath, setRemotePath] = useState('')
|
||||
const [localPath, setLocalPath] = useState('')
|
||||
const [transfers, setTransfers] = useState<TransferItem[]>([])
|
||||
const [transferring, setTransferring] = useState(false)
|
||||
const [transferQueueHeight, setTransferQueueHeight] = useState(128)
|
||||
@@ -67,7 +68,7 @@ export const FileTransferPage: React.FC<FileTransferPageProps> = ({ serverHost,
|
||||
}, [localSelected, serverHost, port, remotePath, password])
|
||||
|
||||
const handleDownload = useCallback(async () => {
|
||||
if (!remoteSelected) return
|
||||
if (!remoteSelected || !localPath) return
|
||||
|
||||
setTransferring(true)
|
||||
const transferId = Date.now().toString()
|
||||
@@ -82,7 +83,7 @@ export const FileTransferPage: React.FC<FileTransferPageProps> = ({ serverHost,
|
||||
setTransfers((prev) => [...prev, newTransfer])
|
||||
|
||||
try {
|
||||
await downloadFileFromRemote(serverHost, port, remoteSelected.name, remotePath, password, (progress) => {
|
||||
await downloadFileFromRemote(serverHost, port, remoteSelected.name, remotePath, localPath, password, (progress) => {
|
||||
setTransfers((prev) =>
|
||||
prev.map((t) => (t.id === transferId ? { ...t, progress } : t))
|
||||
)
|
||||
@@ -106,7 +107,7 @@ export const FileTransferPage: React.FC<FileTransferPageProps> = ({ serverHost,
|
||||
} finally {
|
||||
setTransferring(false)
|
||||
}
|
||||
}, [remoteSelected, serverHost, port])
|
||||
}, [remoteSelected, serverHost, port, remotePath, localPath, password])
|
||||
|
||||
const handleClearTransfers = () => {
|
||||
setTransfers((prev) => prev.filter((t) => t.status === 'transferring'))
|
||||
@@ -153,6 +154,7 @@ export const FileTransferPage: React.FC<FileTransferPageProps> = ({ serverHost,
|
||||
selectedFile={localSelected}
|
||||
onSelect={setLocalSelected}
|
||||
onUpload={handleUpload}
|
||||
onPathChange={setLocalPath}
|
||||
disabled={transferring}
|
||||
/>
|
||||
</div>
|
||||
|
||||
@@ -8,6 +8,7 @@ interface LocalFilePanelProps {
|
||||
selectedFile: FileItem | null
|
||||
onSelect: (file: FileItem | null) => void
|
||||
onUpload: () => void
|
||||
onPathChange?: (path: string) => void
|
||||
disabled?: boolean
|
||||
}
|
||||
|
||||
@@ -15,6 +16,7 @@ export const LocalFilePanel: React.FC<LocalFilePanelProps> = ({
|
||||
selectedFile,
|
||||
onSelect,
|
||||
onUpload,
|
||||
onPathChange,
|
||||
disabled,
|
||||
}) => {
|
||||
const [currentPath, setCurrentPath] = useState('')
|
||||
@@ -50,6 +52,7 @@ export const LocalFilePanel: React.FC<LocalFilePanelProps> = ({
|
||||
useEffect(() => {
|
||||
if (isAtDrives) {
|
||||
loadDrives()
|
||||
onPathChange?.('')
|
||||
} else {
|
||||
loadFiles(currentPath)
|
||||
}
|
||||
@@ -64,6 +67,9 @@ export const LocalFilePanel: React.FC<LocalFilePanelProps> = ({
|
||||
setCurrentPath(prevPath)
|
||||
if (prevPath === '') {
|
||||
setIsAtDrives(true)
|
||||
onPathChange?.('')
|
||||
} else {
|
||||
onPathChange?.(prevPath)
|
||||
}
|
||||
onSelect(null)
|
||||
}
|
||||
@@ -74,6 +80,7 @@ export const LocalFilePanel: React.FC<LocalFilePanelProps> = ({
|
||||
setPathHistory([...pathHistory, file.path])
|
||||
setCurrentPath(file.path)
|
||||
onSelect(null)
|
||||
onPathChange?.(file.path)
|
||||
}
|
||||
|
||||
const handleRefresh = () => {
|
||||
|
||||
Reference in New Issue
Block a user