Skip to content

Commit

Permalink
Merge pull request #7 from BUPTlhuanyu/restructure
Browse files Browse the repository at this point in the history
fix(只展现md文件): 只展现md文件
  • Loading branch information
BUPTlhuanyu authored Jul 1, 2021
2 parents f2df680 + 98c09e6 commit 879048a
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 4 deletions.
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -27,9 +27,9 @@


## 代理工具
- [] ...
- [ ] ...
## 照片美化
- [] ...
- [ ] ...

# 开发
- 安装依赖
Expand Down
6 changes: 5 additions & 1 deletion packages/services/files/fileService.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ export const FS_SAVE = 'fs:save';

import {directoryTree, IOnEachFile, IOnEachDirectory} from 'shared/utils/file';

// TODO: 封装成常用的文件服务
export class FileService implements IFileService {
private readonly onEachFile: IOnEachFile = (item: Record<string, any>) => {
item.key = item.path;
Expand All @@ -32,7 +33,10 @@ export class FileService implements IFileService {
if (dirPath) {
const files = directoryTree(
dirPath,
{excludeHidden: true},
{
excludeHidden: true,
extensions: /\.md$/
},
this.onEachFile,
this.onEachDirectory
);
Expand Down
3 changes: 2 additions & 1 deletion packages/shared/utils/file.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
// TODO: 范型
// TODO:
// 1. extensions 应该是个数组,用于匹配多个类型/多个匹配成功的文件
import FS from 'fs';
import PATH from 'path';

Expand Down

0 comments on commit 879048a

Please sign in to comment.