feat(remote): 文件传输改用Electron IPC通道
- 主进程新增4个IPC handler处理远程文件操作 - 前端通过IPC调用而非浏览器fetch访问远程API - Remote服务新增3003端口专门处理文件传输 - 上传使用文件路径方案,下载使用保存对话框方案
This commit is contained in:
@@ -1,6 +1,6 @@
|
||||
import React, { useState, useCallback, useRef, useEffect } from 'react'
|
||||
import type { FileItem } from '@/lib/api'
|
||||
import { type RemoteFileItem, uploadFileToRemote, downloadFileFromRemote, fetchSystemFileContent } from '../../api'
|
||||
import { type RemoteFileItem, uploadFileToRemote, downloadFileFromRemote } from '../../api'
|
||||
import { type TransferItem } from '../../types'
|
||||
import { LocalFilePanel } from './LocalFilePanel'
|
||||
import { RemoteFilePanel } from './RemoteFilePanel'
|
||||
@@ -40,10 +40,7 @@ export const FileTransferPage: React.FC<FileTransferPageProps> = ({ serverHost,
|
||||
setTransfers((prev) => [...prev, newTransfer])
|
||||
|
||||
try {
|
||||
const blob = await fetchSystemFileContent(localSelected.path)
|
||||
const file = new File([blob], localSelected.name, { type: blob.type })
|
||||
|
||||
await uploadFileToRemote(serverHost, port, file, remotePath, password, (progress) => {
|
||||
await uploadFileToRemote(serverHost, port, localSelected.path, remotePath, password, (progress) => {
|
||||
setTransfers((prev) =>
|
||||
prev.map((t) => (t.id === transferId ? { ...t, progress } : t))
|
||||
)
|
||||
@@ -67,7 +64,7 @@ export const FileTransferPage: React.FC<FileTransferPageProps> = ({ serverHost,
|
||||
} finally {
|
||||
setTransferring(false)
|
||||
}
|
||||
}, [localSelected, serverHost, port])
|
||||
}, [localSelected, serverHost, port, remotePath, password])
|
||||
|
||||
const handleDownload = useCallback(async () => {
|
||||
if (!remoteSelected) return
|
||||
|
||||
Reference in New Issue
Block a user