feat: 截图前执行JS修复table标签display属性
This commit is contained in:
parent
9239a0a3d9
commit
574b68f053
@ -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,
|
||||
|
||||
@ -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)) {
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user