feat: 增加个数限制,减少等待时间

main
lichaojun 1 year ago
parent 23acd1cd59
commit b62274d084

@ -12,6 +12,8 @@ const config = {
* 则直接使用inputDir作为工作目录 * 则直接使用inputDir作为工作目录
*/ */
inputDir: '', inputDir: '',
// 要转换的文件个数, 0表示全部转换
rangeNum: 15,
}, },
// 裁剪商品封面图 // 裁剪商品封面图
cover: { cover: {

@ -2,7 +2,7 @@ const { execSync } = require('child_process');
const fs = require('fs'); const fs = require('fs');
const path = require('path'); const path = require('path');
const { getInputDir } = require('../utils/index'); const { getInputDir } = require('../utils/index');
const { ppt } = require('../config/index'); const { base, ppt } = require('../config/index');
//工作目录文件夹路径 //工作目录文件夹路径
const inputDir = getInputDir(); const inputDir = getInputDir();
@ -54,7 +54,10 @@ fs.readdirSync(inputDir).forEach((file) => {
}); });
// 读取输入目录下所有pdf文件下所有pdf文件 => 转换为image // 读取输入目录下所有pdf文件下所有pdf文件 => 转换为image
fs.readdirSync(pdfDir).forEach((file) => { fs.readdirSync(pdfDir).forEach((file, index) => {
if (base.rangeNum && base.rangeNum > index + 1) {
return;
}
const ext = file.split('.').pop().toLowerCase(); const ext = file.split('.').pop().toLowerCase();
if (ppt.pdfFormat.has(ext)) { if (ppt.pdfFormat.has(ext)) {
const inputPath = path.join(pdfDir, file); const inputPath = path.join(pdfDir, file);

Loading…
Cancel
Save