新增: 文件操作增强与预览扩展
- 文件剪贴板复制剪切粘贴,重名自动副本 - SFTP下载到本机与外部文件拖入,目录递归 - 传输进度浮动面板,transfer-progress事件链 - Drawio预览,Excel工作线程,冻结看门狗 - cmd与bat自写batch语法高亮,psm1等映射补齐
This commit is contained in:
@@ -3,25 +3,20 @@
|
||||
*/
|
||||
|
||||
import type { FsTransport, FileItem, FileOperationResult, DetectTypeResult } from './transport'
|
||||
import { transformFile, transformFileList, joinPath } from './transport'
|
||||
import {
|
||||
ListDir, GetFileInfo, ReadFile, WriteFile, SaveBase64File,
|
||||
CreateFile, CreateDir, DeletePath, RenamePath,
|
||||
CreateFile, CreateDir, DeletePath, RenamePath, CopyPath, MovePath,
|
||||
ListZipContents, ExtractFileFromZip, ExtractFileFromZipToTemp, GetZipFileInfo,
|
||||
OpenPath, GetFileServerURL, ResolveShortcut, DetectFileTypeByContent,
|
||||
GetCommonPaths, GetRecycleBinEntries, RestoreFromRecycleBin,
|
||||
DeletePermanently, EmptyRecycleBin
|
||||
DeletePermanently, EmptyRecycleBin,
|
||||
WatchFile, UnwatchFile
|
||||
} from '../wailsjs/v3-bindings/u-desk/app'
|
||||
|
||||
function transformFile(file: any): FileItem {
|
||||
return { ...file, is_dir: file.is_dir, mod_time: file.mod_time }
|
||||
}
|
||||
|
||||
function transformFileList(files: any[]): FileItem[] {
|
||||
return files.map(transformFile)
|
||||
}
|
||||
|
||||
export class WailsTransport implements FsTransport {
|
||||
async listDir(path: string): Promise<FileItem[]> {
|
||||
// 蛇形→驼峰转换统一由 system.ts 的 toFileItemList 完成,此处仅类型适配
|
||||
return transformFileList(await ListDir(path))
|
||||
}
|
||||
|
||||
@@ -43,13 +38,11 @@ export class WailsTransport implements FsTransport {
|
||||
}
|
||||
|
||||
async createFile(dirPath: string, filename: string): Promise<FileOperationResult> {
|
||||
const fullPath = dirPath.replace(/\/$/, '') + '/' + filename
|
||||
return CreateFile(fullPath)
|
||||
return CreateFile(joinPath(dirPath, filename))
|
||||
}
|
||||
|
||||
async createDir(parentPath: string, dirname: string): Promise<FileOperationResult> {
|
||||
const fullPath = parentPath.replace(/\/$/, '') + '/' + dirname
|
||||
return CreateDir(fullPath)
|
||||
return CreateDir(joinPath(parentPath, dirname))
|
||||
}
|
||||
|
||||
async deletePath(path: string): Promise<FileOperationResult> {
|
||||
@@ -60,6 +53,22 @@ export class WailsTransport implements FsTransport {
|
||||
return RenamePath({ oldPath: String(oldPath), newPath: String(newPath) })
|
||||
}
|
||||
|
||||
async copyPath(src: string, dst: string): Promise<void> {
|
||||
await CopyPath(String(src), String(dst))
|
||||
}
|
||||
|
||||
async movePath(src: string, dst: string): Promise<void> {
|
||||
await MovePath(String(src), String(dst))
|
||||
}
|
||||
|
||||
async downloadToFile(path: string, _localDstDir: string): Promise<string> {
|
||||
return path // 本地文件无需下载
|
||||
}
|
||||
|
||||
async uploadFromFile(_localPath: string, _remoteDir: string): Promise<void> {
|
||||
// 本地面板无上传语义(外部文件拖入走 copyPath)
|
||||
}
|
||||
|
||||
async listZipContents(zipPath: string): Promise<FileItem[]> {
|
||||
return transformFileList(await ListZipContents(zipPath))
|
||||
}
|
||||
@@ -73,7 +82,7 @@ export class WailsTransport implements FsTransport {
|
||||
}
|
||||
|
||||
async getZipFileInfo(zipPath: string, filePath: string): Promise<FileItem> {
|
||||
return transform(await GetZipFileInfo(zipPath, filePath))
|
||||
return transformFile(await GetZipFileInfo(zipPath, filePath))
|
||||
}
|
||||
|
||||
async openPath(path: string): Promise<void> {
|
||||
@@ -120,4 +129,12 @@ export class WailsTransport implements FsTransport {
|
||||
async downloadForPreview(path: string): Promise<string> {
|
||||
return path
|
||||
}
|
||||
|
||||
async watchFile(path: string): Promise<void> {
|
||||
await WatchFile(path)
|
||||
}
|
||||
|
||||
async unwatchFile(): Promise<void> {
|
||||
await UnwatchFile()
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user