|
@@ -33,7 +33,7 @@ async function createPDFOfURL (url, config = {}) {
|
|
|
config = Object.assign( {
|
|
|
filename: '',
|
|
|
dir: '',
|
|
|
- cache: true,
|
|
|
+ nocache: false,
|
|
|
width: '950px',
|
|
|
height: '1360px',
|
|
|
margin: {
|
|
@@ -49,7 +49,7 @@ async function createPDFOfURL (url, config = {}) {
|
|
|
const outConfig = Object.assign({path: `${config.filename}.pdf`, width: config.width, height: config.height,printBackground: true }, config)
|
|
|
outConfig.path = path.join(outPath, outConfig.path)
|
|
|
// 检查缓存
|
|
|
- if (config.cache) {
|
|
|
+ if (!config.nocache) {
|
|
|
const result = checkCache(outConfig.path)
|
|
|
if (result) {
|
|
|
logger.log.debug('命中缓存文件')
|
|
@@ -65,7 +65,7 @@ async function createPDFOfURL (url, config = {}) {
|
|
|
const page = await browser.newPage();
|
|
|
await page.setDefaultNavigationTimeout(0)
|
|
|
await page.goto(url, {waitUntil: 'networkidle2'});
|
|
|
- await wait(1000)
|
|
|
+ await wait(config.delay || 1000)
|
|
|
logger.log.debug('等待生成', new Date().toLocaleString())
|
|
|
|
|
|
await page.pdf(outConfig);
|