feat: 解码 worker 化、Playwright E2E 测试体系与文件夹对比(0.6.0)

This commit is contained in:
2026-08-18 14:40:44 +08:00
parent 2b43b5e676
commit be619c2377
24 changed files with 2030 additions and 151 deletions
+31 -1
View File
@@ -22,6 +22,30 @@ export interface FileOpenError {
/** 打开文件结果:成功数据 / 失败原因 / 用户取消(null) */
export type FileOpenResult = FileData | FileOpenError | null
/** 文件夹对比条目状态(与主进程 folderScan 对齐) */
export type FolderEntryStatus = 'same' | 'different' | 'left-only' | 'right-only'
/** 文件夹对比单个条目 */
export interface FolderEntry {
rel: string
status: FolderEntryStatus
leftSize: number | null
rightSize: number | null
approximate?: boolean
}
/** 文件夹扫描结果 */
export interface FolderScanResult {
entries: FolderEntry[]
truncated: boolean
total: number
}
/** 文件夹扫描失败(目录不存在/不可读) */
export interface FolderScanError {
error: 'scan-failed'
}
/** 主进程暴露给渲染进程的安全 API */
const api = {
openFile: (side?: 'left' | 'right'): Promise<FileOpenResult> =>
@@ -33,7 +57,13 @@ const api = {
showInFolder: (filePath: string): Promise<boolean> =>
ipcRenderer.invoke('file:show-in-folder', filePath),
setClipboard: (text: string): Promise<boolean> =>
ipcRenderer.invoke('clipboard:write', text)
ipcRenderer.invoke('clipboard:write', text),
pickFolder: (): Promise<string | null> =>
ipcRenderer.invoke('folder:pick'),
scanFolder: (leftDir: string, rightDir: string): Promise<FolderScanResult | FolderScanError> =>
ipcRenderer.invoke('folder:scan', leftDir, rightDir),
readByPath: (filePath: string): Promise<FileOpenResult> =>
ipcRenderer.invoke('file:read-by-path', filePath)
}
export type DiffLensApi = typeof api