From ed6d403451bc925030fd01943a3afecbc8bb98f4 Mon Sep 17 00:00:00 2001 From: Misaka Date: Sat, 18 Jul 2026 10:54:10 +0800 Subject: [PATCH] =?UTF-8?q?=E9=9F=B5=E8=BE=BE=E9=9F=B3=E9=A2=91=E6=8E=88?= =?UTF-8?q?=E6=9D=83=E6=8F=90=E7=A4=BA=E5=BC=B9=E7=AA=97=E6=B8=85=E7=90=86?= =?UTF-8?q?=EF=BC=88=E5=90=AB=E9=87=8D=E8=AF=95=E9=87=8D=E8=BD=BD=E5=90=8E?= =?UTF-8?q?=EF=BC=89+=20=E6=9C=8D=E5=8A=A1=E6=A8=A1=E5=BC=8F=E8=AF=BB?= =?UTF-8?q?=E5=8F=96=20debug=20=E9=85=8D=E7=BD=AE?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - site_yunda:抽 dismiss_audio_prompt 助手(点「确定」);yunda_reset 重载主页后调用(解决重试重载后弹窗复现) - runtime:_dismiss_initial_popups 韵达分支改用 dismiss_audio_prompt;launch_and_prepare 自己读 config.yaml 的 debug 段(服务模式也生效,之前仅 main_router 传参) Co-Authored-By: Claude --- runtime.py | 22 ++++++++++++++++++++-- site_yunda.py | 15 +++++++++++++++ 2 files changed, 35 insertions(+), 2 deletions(-) diff --git a/runtime.py b/runtime.py index 50b471f..a664d4d 100644 --- a/runtime.py +++ b/runtime.py @@ -242,7 +242,17 @@ def launch_and_prepare(debug_mode=False, debug_target=""): state_store.init_db() seed_legacy_config() - # 1. 安能 Electron 应用路径(state.db,前端站点配置;seed 已灌入) + # 1. 读 debug 配置(config.yaml;服务模式也生效)+ 安能路径(state.db,seed 已灌入) + if os.path.exists(CONFIG_PATH): + try: + with open(CONFIG_PATH, "r", encoding="utf-8") as f: + _cfg = yaml.safe_load(f) or {} + _dbg = _cfg.get("debug", {}) or {} + if _dbg.get("enabled"): + debug_mode = True + debug_target = str(_dbg.get("target_site", "") or "") + except Exception as e: + print(f"⚠️ 读取 config.yaml(debug) 失败: {e}") anneng_app_path = state_store.get_setting("安能", "app_path") # 2. 确定要挂载的网页站点 + 安能标记 @@ -366,7 +376,7 @@ def launch_and_prepare(debug_mode=False, debug_target=""): def _dismiss_initial_popups(pages_map): - """顺心 / 百世 初始弹窗清理。""" + """顺心 / 百世 / 韵达 初始弹窗清理。""" if "顺心" in pages_map: for acct, sx_page in enumerate(pages_map["顺心"], start=1): try: @@ -410,6 +420,14 @@ def _dismiss_initial_popups(pages_map): print(" ✅ 【百世】初始弹窗处理完成。") except Exception: pass + if "韵达" in pages_map: + try: + yd_page = pages_map["韵达"] + yd_page.bring_to_front() + print(">> 正在检查【韵达】音频设备授权提示...") + site_yunda.dismiss_audio_prompt(yd_page) + except Exception: + pass # ============================ 任务派发 ============================ diff --git a/site_yunda.py b/site_yunda.py index 8ba848b..5d451d7 100644 --- a/site_yunda.py +++ b/site_yunda.py @@ -45,10 +45,25 @@ def with_retry(site_name, label, flow, reset, max_attempts=3): HOME_URL = "https://ky-sso.yunda56.com" +def dismiss_audio_prompt(page): + """关闭韵达「音频设备未授权」提示弹窗(点确定);未出现则跳过。 + + 该弹窗在主页(含重试重载后)会重复出现,故需在每次主页加载后清理。""" + try: + modal = page.locator(".ivu-modal-confirm", has_text="音频设备未授权").first + modal.wait_for(state="visible", timeout=2000) + modal.locator(".ivu-modal-confirm-footer button.ivu-btn-primary").click() + print(" ✅ 【韵达】已关闭音频设备授权提示。") + return True + except Exception: + return False + + def yunda_reset(page): """异常兜底:重置韵达到初始态(跳首页 URL,丢弃当前页面状态,登录态保留)。""" page.goto(HOME_URL) page.wait_for_timeout(1500) + dismiss_audio_prompt(page) # 主页重载后音频授权提示会复现,清理之 def _remove_if_exists(path):