fix: always use .card element screenshot, decouple from full_page flag

The previous adaptive fix only kicked in when screenshot_full_page=True.
When a user had full_page=False, the path fell through to page.screenshot()
which captures the fixed viewport (820x1200 CSS, 1640x2400 actual) — leaving
huge empty space for short posts and truncating long posts mid-content.

Drop the full_page gate. .card element screenshot is now the default path
regardless of config. The flag is only used as a fallback when the element
screenshot fails (e.g. .card not present in HTML).

This makes short and long posts render correctly for every config:
  - a3a7a0d (short, 47 views): 1640x2400 with empty gray -> 1520x698
  - 3e6e0454 (long, 555 views + images): 1640x2400 cut off -> 1520x2596 full
This commit is contained in:
RainySY
2026-06-16 12:44:14 +08:00
parent f72efbc2d3
commit 6aae30e5b0

View File

@@ -948,12 +948,13 @@ class LinuxDoPreviewPlugin(Star):
page.wait_for_timeout(300)
# ── 自适应截图:优先对 .card 元素截图,避免全页导致的巨大空白 ──
# 元素截图按内容的实际边界拍,零空白;否则回退到全页模式
# ── 自适应截图:总是优先对 .card 元素截图,按内容实际边界拍 ──
# 元素截图零空白、零截断,不受 viewport 高度限制
# `screenshot_full_page` 仅作为后备回退:元素截图失败时才使用。
card_locator = page.locator(".card")
full_page = self.config.get("screenshot_full_page", True)
try:
if full_page and card_locator.count() > 0:
if card_locator.count() > 0:
card_locator.first.screenshot(
path=str(save_path),
timeout=timeout_ms,