(path: string)
| 269 | }, [searchQuery, tree, showFiles]); |
| 270 | |
| 271 | const loadRootDirectory = async (path: string) => { |
| 272 | setLoading(true); |
| 273 | try { |
| 274 | const entries = await TauriAPI.listDirectory(path); |
| 275 | const children = entriesToNodes(entries); |
| 276 | |
| 277 | // 创建根节点 |
| 278 | const rootName = path.split(/[/\\]/).filter((p) => p).pop() || 'Project'; |
| 279 | const rootNode: TreeNode = { |
| 280 | name: rootName, |
| 281 | path: path, |
| 282 | type: 'folder', |
| 283 | children: children, |
| 284 | expanded: true, |
| 285 | loaded: true |
| 286 | }; |
| 287 | |
| 288 | setTree([rootNode]); |
| 289 | } catch (error) { |
| 290 | console.error('Failed to load directory:', error); |
| 291 | setTree([]); |
| 292 | } finally { |
| 293 | setLoading(false); |
| 294 | } |
| 295 | }; |
| 296 | |
| 297 | const entriesToNodes = (entries: DirectoryEntry[]): TreeNode[] => { |
| 298 | return entries |
no test coverage detected