@@ -14,6 +14,7 @@ export default class Graph {
1414 private readonly cachedDocList : DocDetail [ ] = [ ] ;
1515 constructor ( options : ElogConfig ) {
1616 this . elogConfig = options ;
17+ this . elogConfig . cacheFilePath = this . elogConfig . cacheFilePath || 'elog.cache.json' ;
1718 this . cachedDocList = this . initCache ( options ) ;
1819 this . pluginDriver = new PluginDriver ( options , this . cachedDocList ) ;
1920 }
@@ -27,8 +28,8 @@ export default class Graph {
2728 return [ ] ;
2829 } else {
2930 try {
30- const cacheJson = require ( path . join ( process . cwd ( ) , baseConfig . cacheFilePath ) ) ;
31- const { cachedDocList } = cacheJson ;
31+ const cacheJson = require ( path . join ( process . cwd ( ) , baseConfig . cacheFilePath ! ) ) ;
32+ const { cachedDocList = [ ] } = cacheJson ;
3233 // 获取缓存文章
3334 return cachedDocList as ( DocDetail & DocExt ) [ ] ;
3435 } catch ( error ) {
@@ -46,17 +47,17 @@ export default class Graph {
4647 writeCache < T > ( sortedDocList : SortedDoc < T > [ ] = [ ] ) {
4748 try {
4849 const { cacheFilePath } = this . elogConfig ;
49- // 判断cachedDocList列表中对象是否有 body 属性
50- const hasBody = this . cachedDocList ?. some ( ( doc ) => ! ! doc . body ) ;
51- if ( hasBody ) {
52- out . debug (
53- '警告' ,
54- '缓存信息存在 body(文档内容)信息,可能会导致缓存文件过大,如无必要用途建议删除 body 属性' ,
55- ) ;
56- }
50+ // // 判断cachedDocList列表中对象是否有 body 属性
51+ // const hasBody = this.cachedDocList?.some((doc) => !!doc.body);
52+ // if (hasBody) {
53+ // out.debug(
54+ // '警告',
55+ // '缓存信息存在 body(文档内容)信息,可能会导致缓存文件过大,如无必要用途建议删除 body 属性',
56+ // );
57+ // }
5758 // 写入缓存
5859 const cacheJson = {
59- cachedDocList : this . cachedDocList ,
60+ cachedDocList : this . cachedDocList . map ( ( item ) => ( { ... item , body : undefined } ) ) ,
6061 sortedDocList : sortedDocList ,
6162 } ;
6263 fs . writeFileSync ( cacheFilePath ! , JSON . stringify ( cacheJson , null , 2 ) , {
@@ -73,7 +74,9 @@ export default class Graph {
7374 * @param docStatusMap
7475 */
7576 updateCache ( docList : DocDetail [ ] , docStatusMap : any ) {
77+ console . log ( 'docStatusMap' , docStatusMap ) ;
7678 for ( const doc of docList ) {
79+ console . log ( 'doc.id' , doc . id ) ;
7780 const { _updateIndex, _status } = docStatusMap [ doc . id ] ;
7881 if ( _status === DocStatus . NEW ) {
7982 // 新增文档
0 commit comments