Skip to content

Commit

Permalink
fix: block file tree (#3336)
Browse files Browse the repository at this point in the history
  • Loading branch information
Yu authored Sep 29, 2019
1 parent bcf1d45 commit fb4fa14
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 16 deletions.
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
export interface Block {
url?: string;
url: string;
name?: string;
description?: string;
img?: string;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,8 @@ import fs from 'fs';
import chalk from 'chalk';
import { join } from 'path';
import { winPath } from 'umi-utils';
import { getBlockListFromGit } from '../../../util';
import { fetchBlockList } from '../../util';
import { BlockData, Resource } from '../../../data.d';
import { Resource } from '../../../data.d';

export interface TreeData {
title: string;
Expand Down Expand Up @@ -61,7 +60,7 @@ export const getFilesTreeData = (
.map((fileName: string) => {
const status = fs.statSync(join(path, fileName));
const isDirectory = status.isDirectory();
// 是文件夹 并且不已 . 开头, 且最深三层
// 是文件夹 并且不已 . 开头, 且最深五层
if (fileName.indexOf('.') !== 0 && depth < 5) {
if (
!isDirectory &&
Expand All @@ -75,15 +74,13 @@ export const getFilesTreeData = (
const absPath = winPath(join(path, fileName));
const absPagePath = winPath(join(parentPath, fileName));
const children = isDirectory ? getFilesTreeData(absPath, absPagePath, depth + 1) : [];
if (children && children.length > 0) {
return {
key: absPagePath,
title: fileName,
value: absPagePath,
children,
};
}
return { title: fileName, value: absPagePath, key: absPagePath };
return {
selectable: !isDirectory,
key: absPagePath,
title: fileName,
value: absPagePath,
children,
};
}
return undefined;
})
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,9 +34,6 @@ const CustomTreeSelect: React.FC<CustomTreeSelectProps> = props => {
label: realValue,
}}
onSelect={(_, node) => {
if (onlySelectLeaf && node.children && (node.children as any[]).length > 0) {
return;
}
if (onlySelectLeaf) {
propOnChange(node.value as string);
return;
Expand Down

0 comments on commit fb4fa14

Please sign in to comment.