修改文件监控逻辑

This commit is contained in:
2025-08-13 21:25:41 +08:00
parent 3b04f0d9b9
commit 2faf07827d
4 changed files with 317 additions and 5 deletions

View File

@@ -2451,5 +2451,36 @@ export const api = {
console.error("Failed to get PackyCode user quota:", error);
throw error;
}
},
// ============= File System Watching =============
/**
* Starts watching a directory for file system changes
* @param directoryPath - The directory path to watch
* @param recursive - Whether to watch subdirectories recursively
* @returns Promise resolving when watching starts
*/
async watchDirectory(directoryPath: string, recursive: boolean = true): Promise<void> {
try {
return await invoke<void>("watch_directory", { path: directoryPath, recursive });
} catch (error) {
console.error("Failed to watch directory:", error);
throw error;
}
},
/**
* Stops watching a directory for file system changes
* @param directoryPath - The directory path to stop watching
* @returns Promise resolving when watching stops
*/
async unwatchDirectory(directoryPath: string): Promise<void> {
try {
return await invoke<void>("unwatch_directory", { path: directoryPath });
} catch (error) {
console.error("Failed to unwatch directory:", error);
throw error;
}
}
};