fix(remote): 上传下载现在使用文件面板当前选择的路径
This commit is contained in:
@@ -16,6 +16,7 @@ interface FileTransferPageProps {
|
||||
export const FileTransferPage: React.FC<FileTransferPageProps> = ({ serverHost, port, password, onClose }) => {
|
||||
const [localSelected, setLocalSelected] = useState<FileItem | null>(null)
|
||||
const [remoteSelected, setRemoteSelected] = useState<RemoteFileItem | null>(null)
|
||||
const [remotePath, setRemotePath] = useState('')
|
||||
const [transfers, setTransfers] = useState<TransferItem[]>([])
|
||||
const [transferring, setTransferring] = useState(false)
|
||||
const [transferQueueHeight, setTransferQueueHeight] = useState(128)
|
||||
@@ -42,7 +43,7 @@ export const FileTransferPage: React.FC<FileTransferPageProps> = ({ serverHost,
|
||||
const blob = await fetchSystemFileContent(localSelected.path)
|
||||
const file = new File([blob], localSelected.name, { type: blob.type })
|
||||
|
||||
await uploadFileToRemote(serverHost, port, file, '', password, (progress) => {
|
||||
await uploadFileToRemote(serverHost, port, file, remotePath, password, (progress) => {
|
||||
setTransfers((prev) =>
|
||||
prev.map((t) => (t.id === transferId ? { ...t, progress } : t))
|
||||
)
|
||||
@@ -84,7 +85,7 @@ export const FileTransferPage: React.FC<FileTransferPageProps> = ({ serverHost,
|
||||
setTransfers((prev) => [...prev, newTransfer])
|
||||
|
||||
try {
|
||||
await downloadFileFromRemote(serverHost, port, remoteSelected.name, '', password, (progress) => {
|
||||
await downloadFileFromRemote(serverHost, port, remoteSelected.name, remotePath, password, (progress) => {
|
||||
setTransfers((prev) =>
|
||||
prev.map((t) => (t.id === transferId ? { ...t, progress } : t))
|
||||
)
|
||||
@@ -166,6 +167,7 @@ export const FileTransferPage: React.FC<FileTransferPageProps> = ({ serverHost,
|
||||
selectedFile={remoteSelected}
|
||||
onSelect={setRemoteSelected}
|
||||
onDownload={handleDownload}
|
||||
onPathChange={setRemotePath}
|
||||
disabled={transferring}
|
||||
/>
|
||||
</div>
|
||||
|
||||
@@ -10,6 +10,7 @@ interface RemoteFilePanelProps {
|
||||
selectedFile: RemoteFileItem | null
|
||||
onSelect: (file: RemoteFileItem | null) => void
|
||||
onDownload: () => void
|
||||
onPathChange?: (path: string) => void
|
||||
disabled?: boolean
|
||||
}
|
||||
|
||||
@@ -20,6 +21,7 @@ export const RemoteFilePanel: React.FC<RemoteFilePanelProps> = ({
|
||||
selectedFile,
|
||||
onSelect,
|
||||
onDownload,
|
||||
onPathChange,
|
||||
disabled,
|
||||
}) => {
|
||||
const [currentPath, setCurrentPath] = useState('')
|
||||
@@ -71,6 +73,7 @@ export const RemoteFilePanel: React.FC<RemoteFilePanelProps> = ({
|
||||
setPathHistory(newHistory)
|
||||
setCurrentPath(prevPath)
|
||||
onSelect(null)
|
||||
onPathChange?.(prevPath)
|
||||
} else {
|
||||
loadDrives()
|
||||
}
|
||||
@@ -82,11 +85,13 @@ export const RemoteFilePanel: React.FC<RemoteFilePanelProps> = ({
|
||||
setPathHistory(['', newPath])
|
||||
setCurrentPath(newPath)
|
||||
loadFiles(newPath)
|
||||
onPathChange?.(newPath)
|
||||
} else {
|
||||
const newPath = currentPath ? `${currentPath}\\${file.name}` : file.name
|
||||
setPathHistory([...pathHistory, newPath])
|
||||
setCurrentPath(newPath)
|
||||
loadFiles(newPath)
|
||||
onPathChange?.(newPath)
|
||||
}
|
||||
onSelect(null)
|
||||
}
|
||||
@@ -104,6 +109,7 @@ export const RemoteFilePanel: React.FC<RemoteFilePanelProps> = ({
|
||||
setCurrentPath('')
|
||||
loadDrives()
|
||||
onSelect(null)
|
||||
onPathChange?.('')
|
||||
}
|
||||
|
||||
const getDisplayPath = () => {
|
||||
|
||||
Reference in New Issue
Block a user