Private
Public Access
1
0
Files
u-desk/frontend/src/api/transport.ts

80 lines
2.4 KiB
TypeScript
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
/**
* 文件系统传输层接口
* 本地模式走 Wails IPC远程模式走 HTTP REST API
* Composable 和组件不感知底层差异
*/
export type FileItem = {
name: string
path: string
size: number
size_str?: string
is_dir: boolean
mod_time?: string
mode?: string
}
export type FileOperationResult = {
path: string
name: string
size: number
size_str?: string
is_dir: boolean
mod_time?: string
mode?: string
old_path?: string
deleted?: boolean
}
export type DetectTypeResult = {
extension: string
category: string
mime_type: string
confidence: number
}
export interface FsTransport {
// 文件列表与信息
listDir(path: string): Promise<FileItem[]>
getFileInfo(path: string): Promise<Record<string, any>>
// 文件读写
readFile(path: string): Promise<string>
writeFile(path: string, content: string): Promise<void>
saveBase64File(path: string, content: string): Promise<void>
// 文件操作
createFile(dirPath: string, filename: string): Promise<FileOperationResult>
createDir(parentPath: string, dirname: string): Promise<FileOperationResult>
deletePath(path: string): Promise<FileOperationResult>
renamePath(oldPath: string, newPath: string): Promise<FileOperationResult>
// ZIP 操作Wave 3
listZipContents(zipPath: string): Promise<FileItem[]>
extractFileFromZip(zipPath: string, filePath: string): Promise<string>
extractFileFromZipToTemp(zipPath: string, filePath: string): Promise<string>
getZipFileInfo(zipPath: string, filePath: string): Promise<FileItem>
// 系统操作
openPath(path: string): Promise<void>
getFileServerURL(): Promise<string>
getPreviewToken(): string
resolveShortcut(lnkPath: string): Promise<any>
detectFileTypeByContent(path: string): Promise<DetectTypeResult>
getCommonPaths(): Promise<Record<string, string>>
// 回收站Wave 3
getRecycleBinEntries(): Promise<any[]>
restoreFromRecycleBin(path: string): Promise<void>
deletePermanently(path: string): Promise<void>
emptyRecycleBin(): Promise<void>
// 预览辅助
/** 下载远程文件到本地临时目录,本地/HTTP 直接返回原路径 */
downloadForPreview(path: string): Promise<string>
/** 下载 HTML 及其引用的资源到临时目录OSS 实现) */
downloadSiteForPreview?(path: string): Promise<string>
/** 获取预签名 URL仅 OSS 实现,其他返回空串) */
getSignedUrl?(path: string): Promise<string>
}