From c6a025e35dce38a1d8d3bbef2215448a9cb84363 Mon Sep 17 00:00:00 2001 From: LetTTGACO <1225751694@qq.com> Date: Sat, 15 Jun 2024 23:27:05 +0800 Subject: [PATCH] feat: img limit --- packages/elog/src/utils/context/ImageContext.ts | 5 +++-- playground/plugin-from-feishu-space/src/FeiShuClient.ts | 2 +- playground/plugin-from-feishu-wiki/src/FeiShuClient.ts | 2 +- playground/plugin-from-flowus/src/FlowUsClient.ts | 2 +- playground/plugin-from-notion/src/NotionClient.ts | 2 +- playground/plugin-from-wolai/src/WolaiClient.ts | 2 +- playground/plugin-from-yuque-pwd/src/YuqueClient.ts | 2 +- playground/plugin-from-yuque-token/src/YuqueClient.ts | 2 +- playground/plugin-image-github/src/ImageClient.ts | 2 +- 9 files changed, 11 insertions(+), 10 deletions(-) diff --git a/packages/elog/src/utils/context/ImageContext.ts b/packages/elog/src/utils/context/ImageContext.ts index 25d69f07..1bd2d24e 100644 --- a/packages/elog/src/utils/context/ImageContext.ts +++ b/packages/elog/src/utils/context/ImageContext.ts @@ -19,12 +19,13 @@ export class ElogImageContext extends ElogBaseContext { * 替换图片 * @param docDetailList * @param uploader + * @param limit */ - async replaceImages(docDetailList: DocDetail[], uploader: ImageUploader) { + async replaceImages(docDetailList: DocDetail[], uploader: ImageUploader, limit?: number) { if (this.imageBaseConfig.disable) { this.ctx.info('图片替换已禁用'); return docDetailList; } - return replaceImagesFunc(docDetailList, uploader, this.imageBaseConfig.limit || 10); + return replaceImagesFunc(docDetailList, uploader, limit || this.imageBaseConfig.limit || 10); } } diff --git a/playground/plugin-from-feishu-space/src/FeiShuClient.ts b/playground/plugin-from-feishu-space/src/FeiShuClient.ts index 542d746a..599dead6 100644 --- a/playground/plugin-from-feishu-space/src/FeiShuClient.ts +++ b/playground/plugin-from-feishu-space/src/FeiShuClient.ts @@ -31,7 +31,7 @@ export default class FeiShuClient extends ElogFromContext { this.ctx.info(`下载文档 ${doc._index}/${needUpdateDocList.length} `, doc.title); return this.api.getDocDetail(doc); }; - const docDetailList = await this.asyncPool(this.config.limit || 3, needUpdateDocList, promise); + const docDetailList = await this.asyncPool(this.config.limit || 10, needUpdateDocList, promise); this.ctx.info('已下载数', String(needUpdateDocList.length)); return { docDetailList, diff --git a/playground/plugin-from-feishu-wiki/src/FeiShuClient.ts b/playground/plugin-from-feishu-wiki/src/FeiShuClient.ts index b3195576..148ce541 100644 --- a/playground/plugin-from-feishu-wiki/src/FeiShuClient.ts +++ b/playground/plugin-from-feishu-wiki/src/FeiShuClient.ts @@ -31,7 +31,7 @@ export default class FeiShuClient extends ElogFromContext { this.ctx.info(`下载文档 ${doc._index}/${needUpdateDocList.length} `, doc.title); return this.api.getDocDetail(doc); }; - const docDetailList = await this.asyncPool(this.config.limit || 3, needUpdateDocList, promise); + const docDetailList = await this.asyncPool(this.config.limit || 10, needUpdateDocList, promise); this.ctx.info('已下载数', String(needUpdateDocList.length)); return { docDetailList, diff --git a/playground/plugin-from-flowus/src/FlowUsClient.ts b/playground/plugin-from-flowus/src/FlowUsClient.ts index d95e2dd7..f27292dd 100644 --- a/playground/plugin-from-flowus/src/FlowUsClient.ts +++ b/playground/plugin-from-flowus/src/FlowUsClient.ts @@ -31,7 +31,7 @@ export default class FlowUsClient extends ElogFromContext { this.ctx.info(`下载文档 ${doc._index}/${needUpdateDocList.length} `, doc.title); return this.api.getDocDetail(doc); }; - const docDetailList = await this.asyncPool(this.config.limit || 3, needUpdateDocList, promise); + const docDetailList = await this.asyncPool(this.config.limit || 10, needUpdateDocList, promise); this.ctx.info('已下载数', String(needUpdateDocList.length)); return { docDetailList, diff --git a/playground/plugin-from-notion/src/NotionClient.ts b/playground/plugin-from-notion/src/NotionClient.ts index a2a6bfae..4b8de326 100644 --- a/playground/plugin-from-notion/src/NotionClient.ts +++ b/playground/plugin-from-notion/src/NotionClient.ts @@ -57,7 +57,7 @@ export default class NotionClient extends ElogFromContext { this.ctx.info(`下载文档 ${doc._index}/${needUpdateDocList.length} `, doc.properties.title); return this.api.getDocDetail(doc); }; - const docDetailList = await this.asyncPool(this.config.limit || 3, needUpdateDocList, promise); + const docDetailList = await this.asyncPool(this.config.limit || 10, needUpdateDocList, promise); this.ctx.info('已下载数', String(needUpdateDocList.length)); return { docDetailList, diff --git a/playground/plugin-from-wolai/src/WolaiClient.ts b/playground/plugin-from-wolai/src/WolaiClient.ts index e13dcb5c..d0b42720 100644 --- a/playground/plugin-from-wolai/src/WolaiClient.ts +++ b/playground/plugin-from-wolai/src/WolaiClient.ts @@ -31,7 +31,7 @@ export default class WolaiClient extends ElogFromContext { this.ctx.info(`下载文档 ${doc._index}/${needUpdateDocList.length} `, doc.properties.title); return this.api.getDocDetail(doc); }; - const docDetailList = await this.asyncPool(this.config.limit || 3, needUpdateDocList, promise); + const docDetailList = await this.asyncPool(this.config.limit || 10, needUpdateDocList, promise); this.ctx.info('已下载数', String(needUpdateDocList.length)); return { docDetailList, diff --git a/playground/plugin-from-yuque-pwd/src/YuqueClient.ts b/playground/plugin-from-yuque-pwd/src/YuqueClient.ts index c4b641e7..eb0d3ddc 100644 --- a/playground/plugin-from-yuque-pwd/src/YuqueClient.ts +++ b/playground/plugin-from-yuque-pwd/src/YuqueClient.ts @@ -92,7 +92,7 @@ export default class YuqueClient extends ElogFromContext { }; return docDetail; }; - const docDetailList = await this.asyncPool(this.config.limit || 3, needUpdateDocList, promise); + const docDetailList = await this.asyncPool(this.config.limit || 10, needUpdateDocList, promise); this.ctx.info('已下载数', String(needUpdateDocList.length)); return { docDetailList, diff --git a/playground/plugin-from-yuque-token/src/YuqueClient.ts b/playground/plugin-from-yuque-token/src/YuqueClient.ts index aee16cc8..0c3e9af4 100644 --- a/playground/plugin-from-yuque-token/src/YuqueClient.ts +++ b/playground/plugin-from-yuque-token/src/YuqueClient.ts @@ -90,7 +90,7 @@ export default class YuqueClient extends ElogFromContext { }; return docDetail; }; - const docDetailList = await this.asyncPool(this.config.limit || 3, needUpdateDocList, promise); + const docDetailList = await this.asyncPool(this.config.limit || 10, needUpdateDocList, promise); this.ctx.info('已下载数', String(needUpdateDocList.length)); return { docDetailList, diff --git a/playground/plugin-image-github/src/ImageClient.ts b/playground/plugin-image-github/src/ImageClient.ts index a8f0bba2..9a27d309 100644 --- a/playground/plugin-image-github/src/ImageClient.ts +++ b/playground/plugin-image-github/src/ImageClient.ts @@ -15,6 +15,6 @@ export default class ImageClient extends ElogImageContext { * @param docDetailList */ async processImages(docDetailList: DocDetail[]) { - return this.replaceImages(docDetailList, this.api); + return this.replaceImages(docDetailList, this.api, 3); } }