韵达音频授权提示弹窗清理(含重试重载后)+ 服务模式读取 debug 配置

- 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 <noreply@anthropic.com>
This commit is contained in:
Misaka
2026-07-18 10:54:10 +08:00
parent 6d45a9f5e5
commit ed6d403451
2 changed files with 35 additions and 2 deletions

View File

@@ -242,7 +242,17 @@ def launch_and_prepare(debug_mode=False, debug_target=""):
state_store.init_db() state_store.init_db()
seed_legacy_config() seed_legacy_config()
# 1. 安能 Electron 应用路径state.db前端站点配置;seed 已灌入) # 1. 读 debug 配置config.yaml服务模式也生效+ 安能路径state.dbseed 已灌入)
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") anneng_app_path = state_store.get_setting("安能", "app_path")
# 2. 确定要挂载的网页站点 + 安能标记 # 2. 确定要挂载的网页站点 + 安能标记
@@ -366,7 +376,7 @@ def launch_and_prepare(debug_mode=False, debug_target=""):
def _dismiss_initial_popups(pages_map): def _dismiss_initial_popups(pages_map):
"""顺心 / 百世 初始弹窗清理。""" """顺心 / 百世 / 韵达 初始弹窗清理。"""
if "顺心" in pages_map: if "顺心" in pages_map:
for acct, sx_page in enumerate(pages_map["顺心"], start=1): for acct, sx_page in enumerate(pages_map["顺心"], start=1):
try: try:
@@ -410,6 +420,14 @@ def _dismiss_initial_popups(pages_map):
print(" ✅ 【百世】初始弹窗处理完成。") print(" ✅ 【百世】初始弹窗处理完成。")
except Exception: except Exception:
pass 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
# ============================ 任务派发 ============================ # ============================ 任务派发 ============================

View File

@@ -45,10 +45,25 @@ def with_retry(site_name, label, flow, reset, max_attempts=3):
HOME_URL = "https://ky-sso.yunda56.com" 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): def yunda_reset(page):
"""异常兜底:重置韵达到初始态(跳首页 URL丢弃当前页面状态登录态保留""" """异常兜底:重置韵达到初始态(跳首页 URL丢弃当前页面状态登录态保留"""
page.goto(HOME_URL) page.goto(HOME_URL)
page.wait_for_timeout(1500) page.wait_for_timeout(1500)
dismiss_audio_prompt(page) # 主页重载后音频授权提示会复现,清理之
def _remove_if_exists(path): def _remove_if_exists(path):