Revert "支持复用色花堂常驻浏览器会话"

This reverts commit a8070a7214.
This commit is contained in:
liuwei
2026-04-27 15:44:55 +08:00
parent a8070a7214
commit 9a84b6b313
3 changed files with 43 additions and 151 deletions
+2 -23
View File
@@ -46,23 +46,6 @@ class SehuatangPushPlugin(MessagePluginInterface):
super().__init__()
self.feature = self.register_feature()
def _build_browser_config(self, payload: Dict[str, Any]) -> Dict[str, Any]:
"""整理浏览器配置,优先读取插件配置,再允许任务 payload 做局部覆盖。"""
# 这里把浏览器连接参数集中整理出来,
# 目的是让调度入口不需要关心太多细节,同时兼容后续从后台任务动态覆盖端口。
browser_cfg = dict(self._config.get("browser", {}) or {})
if "reuse_existing_browser" in payload:
browser_cfg["reuse_existing_browser"] = payload.get("reuse_existing_browser")
if "debugger_host" in payload:
browser_cfg["debugger_host"] = payload.get("debugger_host")
if "debugger_port" in payload:
browser_cfg["debugger_port"] = payload.get("debugger_port")
if "allow_launch_fallback" in payload:
browser_cfg["allow_launch_fallback"] = payload.get("allow_launch_fallback")
return browser_cfg
def initialize(self, context: Dict[str, Any]) -> bool:
return True
@@ -111,15 +94,11 @@ class SehuatangPushPlugin(MessagePluginInterface):
payload = context.get("payload") or {}
at_user = str(payload.get("at_user", "Jyunere") or "Jyunere").strip()
browser_config = self._build_browser_config(payload)
strict_reuse_existing_browser = bool(browser_config.get("reuse_existing_browser")) and not bool(
browser_config.get("allow_launch_fallback", True)
)
# 兼容历史逻辑:优先使用 undetected 方案,失败后回退普通抓取。
try:
ok, path = await asyncio.to_thread(pdf_file_path_undetected, browser_config)
if not ok and not strict_reuse_existing_browser:
ok, path = await asyncio.to_thread(pdf_file_path_undetected)
if not ok:
ok, path = await asyncio.to_thread(pdf_file_path)
if not ok:
return {"success": False, "summary": "PDF 生成失败", "detail": {}}