更新 playwright_automation 和 screenshots 服务
This commit is contained in:
@@ -1375,18 +1375,7 @@ class PlaywrightAutomation:
|
|||||||
# 先保存到临时文件
|
# 先保存到临时文件
|
||||||
temp_filepath = filepath + '.tmp'
|
temp_filepath = filepath + '.tmp'
|
||||||
|
|
||||||
# 获取iframe并截取其完整内容
|
# 截图:默认截取主页面(包含左侧菜单/顶部栏等整体界面)
|
||||||
iframe = self.get_iframe_safe()
|
|
||||||
if iframe:
|
|
||||||
# 对iframe内容进行全页截图
|
|
||||||
iframe.screenshot(
|
|
||||||
path=temp_filepath,
|
|
||||||
type='jpeg',
|
|
||||||
full_page=True,
|
|
||||||
quality=100
|
|
||||||
)
|
|
||||||
else:
|
|
||||||
# 回退到主页面截图
|
|
||||||
self.main_page.screenshot(
|
self.main_page.screenshot(
|
||||||
path=temp_filepath,
|
path=temp_filepath,
|
||||||
type='jpeg',
|
type='jpeg',
|
||||||
|
|||||||
@@ -117,6 +117,28 @@ def take_screenshot_for_account(
|
|||||||
else:
|
else:
|
||||||
bz = 2 # 应读
|
bz = 2 # 应读
|
||||||
target_url = f"{base}/admin/center.aspx?bz={bz}"
|
target_url = f"{base}/admin/center.aspx?bz={bz}"
|
||||||
|
# 目标:保留外层框架(左侧菜单/顶部栏),仅在 mainframe 内部导航到目标内容页
|
||||||
|
iframe = None
|
||||||
|
try:
|
||||||
|
iframe = automation.get_iframe_safe(retry=True, max_retries=5)
|
||||||
|
except Exception:
|
||||||
|
iframe = None
|
||||||
|
|
||||||
|
if iframe:
|
||||||
|
iframe.goto(target_url, timeout=60000)
|
||||||
|
current_url = getattr(iframe, "url", "") or ""
|
||||||
|
if "center.aspx" not in current_url:
|
||||||
|
raise RuntimeError(f"unexpected_iframe_url:{current_url}")
|
||||||
|
try:
|
||||||
|
iframe.wait_for_load_state("networkidle", timeout=30000)
|
||||||
|
except Exception:
|
||||||
|
pass
|
||||||
|
try:
|
||||||
|
iframe.wait_for_selector("table.ltable", timeout=20000)
|
||||||
|
except Exception:
|
||||||
|
pass
|
||||||
|
else:
|
||||||
|
# 兜底:若获取不到 iframe,则退回到主页面直达
|
||||||
automation.main_page.goto(target_url, timeout=60000)
|
automation.main_page.goto(target_url, timeout=60000)
|
||||||
current_url = getattr(automation.main_page, "url", "") or ""
|
current_url = getattr(automation.main_page, "url", "") or ""
|
||||||
if "center.aspx" not in current_url:
|
if "center.aspx" not in current_url:
|
||||||
@@ -269,4 +291,3 @@ def take_screenshot_for_account(
|
|||||||
)
|
)
|
||||||
if not submitted:
|
if not submitted:
|
||||||
screenshot_callback(None, "截图队列已满,请稍后重试")
|
screenshot_callback(None, "截图队列已满,请稍后重试")
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user