From b62274d084c2700dcbb5e9647936d8e6b5a418c3 Mon Sep 17 00:00:00 2001 From: lichaojun Date: Tue, 1 Oct 2024 18:10:34 +0800 Subject: [PATCH] =?UTF-8?q?feat:=20=E5=A2=9E=E5=8A=A0=E4=B8=AA=E6=95=B0?= =?UTF-8?q?=E9=99=90=E5=88=B6=EF=BC=8C=E5=87=8F=E5=B0=91=E7=AD=89=E5=BE=85?= =?UTF-8?q?=E6=97=B6=E9=97=B4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- config/index.js | 2 ++ src/ppt_to_img.js | 7 +++++-- 2 files changed, 7 insertions(+), 2 deletions(-) diff --git a/config/index.js b/config/index.js index 5b28234..8f53729 100644 --- a/config/index.js +++ b/config/index.js @@ -12,6 +12,8 @@ const config = { * 则直接使用inputDir作为工作目录 */ inputDir: '', + // 要转换的文件个数, 0表示全部转换 + rangeNum: 15, }, // 裁剪商品封面图 cover: { diff --git a/src/ppt_to_img.js b/src/ppt_to_img.js index 5028088..144721e 100644 --- a/src/ppt_to_img.js +++ b/src/ppt_to_img.js @@ -2,7 +2,7 @@ const { execSync } = require('child_process'); const fs = require('fs'); const path = require('path'); const { getInputDir } = require('../utils/index'); -const { ppt } = require('../config/index'); +const { base, ppt } = require('../config/index'); //工作目录文件夹路径 const inputDir = getInputDir(); @@ -54,7 +54,10 @@ fs.readdirSync(inputDir).forEach((file) => { }); // 读取输入目录下所有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(); if (ppt.pdfFormat.has(ext)) { const inputPath = path.join(pdfDir, file);