feat(remote): 实现文件下载真实进度显示
- 下载改用流式读取,计算真实进度百分比 - 通过 IPC 事件实时推送进度到前端 - 支持 Content-Length 计算下载进度
This commit is contained in:
@@ -19,6 +19,11 @@ contextBridge.exposeInMainWorld('electronAPI', {
|
||||
ipcRenderer.on('remote-clipboard-auto-sync', handler);
|
||||
return () => ipcRenderer.removeListener('remote-clipboard-auto-sync', handler);
|
||||
},
|
||||
onDownloadProgress: (callback: (data: { progress: number; id: string }) => void) => {
|
||||
const handler = (_event: Electron.IpcRendererEvent, data: { progress: number; id: string }) => callback(data);
|
||||
ipcRenderer.on('download-progress', handler);
|
||||
return () => ipcRenderer.removeListener('download-progress', handler);
|
||||
},
|
||||
clipboardReadText: () => ipcRenderer.invoke('clipboard-read-text'),
|
||||
clipboardWriteText: (text: string) => ipcRenderer.invoke('clipboard-write-text', text),
|
||||
remoteFetchDrives: (serverHost: string, port: number, password?: string) =>
|
||||
@@ -27,6 +32,6 @@ contextBridge.exposeInMainWorld('electronAPI', {
|
||||
ipcRenderer.invoke('remote-fetch-files', serverHost, port, filePath, password),
|
||||
remoteUploadFile: (serverHost: string, port: number, filePath: string, remotePath: string, password?: string) =>
|
||||
ipcRenderer.invoke('remote-upload-file', serverHost, port, filePath, remotePath, password),
|
||||
remoteDownloadFile: (serverHost: string, port: number, fileName: string, remotePath: string, localPath: string, password?: string) =>
|
||||
ipcRenderer.invoke('remote-download-file', serverHost, port, fileName, remotePath, localPath, password),
|
||||
remoteDownloadFile: (id: string, serverHost: string, port: number, fileName: string, remotePath: string, localPath: string, password?: string) =>
|
||||
ipcRenderer.invoke('remote-download-file', id, serverHost, port, fileName, remotePath, localPath, password),
|
||||
})
|
||||
|
||||
Reference in New Issue
Block a user