diff --git a/src/components/FileTree.tsx b/src/components/FileTree.tsx index 5f5c205..4d04a52 100644 --- a/src/components/FileTree.tsx +++ b/src/components/FileTree.tsx @@ -7,7 +7,7 @@ import { useNavigate } from "@solidjs/router"; */ function isPathInDir(currentPath: string, dirPath: string): boolean { // 确保 dirPath 以 / 结尾,用于前缀匹配 - const dirPathPrefix = dirPath.endsWith('/') ? dirPath : dirPath + '/'; + const dirPathPrefix = dirPath.endsWith("/") ? dirPath : dirPath + "/"; return currentPath.startsWith(dirPathPrefix); } @@ -25,7 +25,9 @@ export const FileTreeNode: Component<{ const isDir = !!props.node.children; const isActive = createMemo(() => props.currentPath === props.node.path); // 默认收起,除非当前文件在该文件夹内 - const [isExpanded, setIsExpanded] = createSignal(isDir && isPathInDir(props.currentPath, props.node.path)); + const [isExpanded, setIsExpanded] = createSignal( + isDir && isPathInDir(props.currentPath, props.node.path), + ); const handleClick = () => { if (isDir) { @@ -112,16 +114,21 @@ export const HeadingNode: Component<{ return (