mirror of
https://github.com/A-Minos/nonebot-plugin-tetris-stats.git
synced 2026-03-05 05:36:54 +08:00
🐛 优化等待逻辑,修复截图爆炸
This commit is contained in:
@@ -16,6 +16,7 @@ async def screenshot(url: str) -> bytes:
|
||||
context = await BrowserManager.get_context('screenshot', factory=context_factory)
|
||||
async with await context.new_page() as page:
|
||||
await page.goto(url)
|
||||
await page.wait_for_selector('#content')
|
||||
size: ViewportSize = await page.evaluate("""
|
||||
() => {
|
||||
const element = document.querySelector('#content');
|
||||
@@ -26,5 +27,4 @@ async def screenshot(url: str) -> bytes:
|
||||
};
|
||||
""")
|
||||
await page.set_viewport_size(size)
|
||||
await page.wait_for_load_state('networkidle')
|
||||
return await page.locator('id=content').screenshot(animations='disabled', timeout=5000, type='png')
|
||||
|
||||
Reference in New Issue
Block a user