feat(electron-shell): 启动链路修复与执行/配置收口插件侧

- 启动链路 P1-P7 修复:预算对齐、完成事件推送、端口占用提示、前端阶段文案接管
- 静态缓存按 IS_FROZEN 区分开发/打包态,bootPhaseOwned 竞态修复
- 一键执行与参数配置统一收口到插件界面,定时任务引用 config_id
- 环境包迁移到 %LOCALAPPDATA%\37duAutomation\python-env,重装零解压
- shell-updater:缓存包 sha256 校验、静默升级后自动拉起新版、自动清理旧安装包
- after-pack 钩子生成 shell.version 修复打包态版本识别
- 插件 xq0031/xq0045 迁移至 plugins/XQ0001-0100/ 号段分桶中文目录
This commit is contained in:
2026-09-28 14:20:35 +08:00
parent 3214305dea
commit 87f995ca47
55 changed files with 1426 additions and 4280 deletions
-102
View File
@@ -1,102 +0,0 @@
# -*- coding: utf-8 -*-
"""xq0045_xq0046 金色印象通联数据导出 插件 - 配置常量与全局钩子。
插件自包含:本包只依赖 Python 标准库 / 第三方库 / 底座注入的 RunContext。
业务模块统一经 config.log() 输出日志(转发到 ctx.log,无 ctx 时回落到 print)。
"""
import os
# ==================== 通联平台 ====================
LOGIN_URL = 'https://cus.allinpay.com/login'
MAIN_URL = 'https://cus.allinpay.com/main.dsr' # 已登录首页(预热/Referer 来源)
SEARCH_URL = 'https://cus.allinpay.com/tranx25/search'
STATUS_URL = 'https://cus.allinpay.com/export/statusdownload'
DOWNLOAD_INFO_URL = 'https://cus.allinpay.com/export/downloadexport/'
BILL_URL = 'https://cus.allinpay.com/checkacct25/download'
TRXCODE_URL = 'https://cus.allinpay.com/unauth/queryInterCode'
TRXSTATE_URL = 'https://cus.allinpay.com/unauth/queryRecordState'
# 服务端有 Referer 外链校验:直接访问会被重定向回 /main.dsr
SEARCH_HEADERS = {'Referer': MAIN_URL}
# ==================== 导出参数 ====================
EXPORT_CURRENT = 'onebtnexpt' # 导出当前页
EXPORT_ALL = 'all' # 导出全部(默认用这个)
# 异步导出状态轮询:每 6 秒一次,最多 12 次(服务端超时上限约 10 次/60 秒)
STATUS_POLL_INTERVAL = 6
STATUS_POLL_MAX = 12
# 登录/验证码 —— 风控敏感:每次提交都计入服务端登录尝试次数,从严控制重试,
# 避免连续多次提交触发平台「登录失败次数已达上限」锁定(曾实测踩雷,账号被锁 2 小时)
RETRY_MAX = 1 # 浏览器兜底登录轮数(失败即停,不反复登录)
CAPTCHA_RETRY = 3 # 浏览器每轮验证码重试次数
API_CAPTCHA_RETRY = 3 # 接口登录验证码重试次数
LOGIN_FAIL_BACKOFF = 8 # 登录提交失败后的退避秒数(让风控计数沉降)
TIMEOUT = 10 # 元素等待超时(秒)
# ==================== 默认保存目录 ====================
_DESKTOP = os.path.join(os.path.expanduser('~'), 'Desktop')
def get_desktop():
return _DESKTOP
# ==================== 浏览器用户目录 ====================
def get_browser_profile_dir():
"""独立固定浏览器用户目录:登录态跨次保留(免验证码),且不占用用户日常 Chrome 配置。
放 %LOCALAPPDATA% 下而非系统临时目录,避免被磁盘清理工具清掉导致登录态丢失。
"""
base = os.environ.get('LOCALAPPDATA') or os.path.expanduser('~')
return os.path.join(base, '37duAutomation', 'browser_sessions', 'xq0045_xq0046')
# ==================== 登录会话复用 ====================
def get_session_file():
"""已登录会话 cookies 落盘路径:跨 run 复用通联登录,避免每次执行都重新登录。"""
base = os.environ.get('LOCALAPPDATA') or os.path.expanduser('~')
d = os.path.join(base, '37duAutomation', 'sessions')
os.makedirs(d, exist_ok=True)
return os.path.join(d, 'allinpay_xq0045_xq0046.json')
# ==================== 全局钩子(run() 启动时注入) ====================
_log = None
def set_log(fn):
"""注入 ctx.log(RunContext.log),各模块经 log()/logger 输出。"""
global _log
_log = fn
def log(msg, level="INFO"):
if _log:
_log(str(msg), level)
else:
print(f"[{level}] {msg}")
class _ModuleLogger:
"""模块级 logger 适配:统一转发到 config.log。"""
@staticmethod
def debug(msg, *args):
log(msg % args if args else msg, "DEBUG")
@staticmethod
def info(msg, *args):
log(msg % args if args else msg, "INFO")
@staticmethod
def warning(msg, *args):
log(msg % args if args else msg, "WARN")
@staticmethod
def error(msg, *args):
log(msg % args if args else msg, "ERROR")
logger = _ModuleLogger()