feat: 截图前执行JS修复table标签display属性

This commit is contained in:
ghr 2026-04-13 18:47:14 +08:00
parent 9239a0a3d9
commit 574b68f053
2 changed files with 16 additions and 0 deletions

View File

@ -76,6 +76,14 @@ async function main() {
// 额外等待3秒确保动态内容加载
await page.waitForTimeout(3000);
// 执行JS将所有 table 标签的 display 改为 table
await page.evaluate(() => {
const tables = document.querySelectorAll('table');
tables.forEach(table => {
table.style.display = 'table';
});
});
// 截图
await page.screenshot({
path: picPath,

View File

@ -57,6 +57,14 @@ async function screenshot(url, outputPath) {
// 额外等待3秒确保动态内容加载
await page.waitForTimeout(3000);
// 执行JS将所有 table 标签的 display 改为 table
await page.evaluate(() => {
const tables = document.querySelectorAll('table');
tables.forEach(table => {
table.style.display = 'table';
});
});
// 确保输出目录存在
const outputDir = path.dirname(outputPath);
if (!fs.existsSync(outputDir)) {