feat: 新增多插件 UI 支持及运行日志集中回传功能

本次提交包含多项功能更新:
1. 为多个插件(xq0002/0003/0004/0008/0010/0011/0020/0031_xq0032/0033/0035/0037/0045_xq0046/0047/0048)新增 UI 界面及配置支持
2. 新增运行日志集中回传功能,客户端自动上传运行日志到中心机集中存储
3. 新增插件分类字段支持,用于场景库分组管理
4. 优化 xq0034/0037/0048 等插件的功能及描述
5. 修复控制面响应兼容问题,支持新旧版本数据格式
6. 新增 xq0033 插件的状态存储模块,用于历史记录管理
7. 优化 CRM 登录窗口模式,支持全屏置顶
This commit is contained in:
2026-10-26 15:42:50 +08:00
parent 9fd687ada8
commit 843ff244a6
453 changed files with 243002 additions and 4493 deletions
@@ -45,6 +45,57 @@ def get_browser_profile_dir():
return os.path.join(_app_data_dir(), 'browser_sessions', 'xq0048')
# ==================== 浏览器窗口(全屏 + 置顶) ====================
def apply_window_mode(page):
"""把浏览器窗口设为全屏并置顶。
窗口被其它窗口遮挡或最小化时,渲染进程可能一直不出帧,Page.captureScreenshot
会等到超时(DrissionPage 默认 30s)。全屏 + 置顶用于规避这种遮挡型超时;
失败仅告警,不影响后续流程。"""
try:
page.set.window.full()
except Exception as e:
log(f"设置窗口全屏失败(忽略):{e}", "WARN")
if os.name == 'nt':
try:
_set_topmost(page.process_id)
except Exception as e:
log(f"设置窗口置顶失败(忽略):{e}", "WARN")
def _set_topmost(pid):
"""把指定进程的主窗口设为 HWND_TOPMOST(Win32 SetWindowPos,仅 Windows)。"""
if not pid:
return
import ctypes
from ctypes import wintypes
user32 = ctypes.windll.user32
user32.IsWindowVisible.argtypes = [wintypes.HWND]
user32.GetWindowTextLengthW.argtypes = [wintypes.HWND]
user32.GetWindowThreadProcessId.argtypes = [wintypes.HWND, ctypes.POINTER(wintypes.DWORD)]
hwnds = []
@ctypes.WINFUNCTYPE(wintypes.BOOL, wintypes.HWND, wintypes.LPARAM)
def _collect(hwnd, _lparam):
if user32.IsWindowVisible(hwnd) and user32.GetWindowTextLengthW(hwnd) > 0:
proc = wintypes.DWORD()
user32.GetWindowThreadProcessId(hwnd, ctypes.byref(proc))
if proc.value == pid:
hwnds.append(hwnd)
return True
user32.EnumWindows.argtypes = [ctypes.WINFUNCTYPE(wintypes.BOOL, wintypes.HWND, wintypes.LPARAM),
wintypes.LPARAM]
user32.EnumWindows(_collect, 0)
user32.SetWindowPos.argtypes = [wintypes.HWND, wintypes.HWND, ctypes.c_int,
ctypes.c_int, ctypes.c_int, ctypes.c_int, ctypes.c_uint]
for hwnd in hwnds:
user32.SetWindowPos(hwnd, wintypes.HWND(-1), 0, 0, 0, 0, 0x0001 | 0x0002) # NOSIZE | NOMOVE
# ==================== 运行参数(项目规范:全局重试 3 次) ====================
RETRY_MAX = 3 # 截图/单报表重试
PAGE_SIZE = 13 # 与页面一致;实测服务端导出不受分页影响
@@ -64,7 +115,8 @@ UA = ("Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 "
# 规则:prev=前一天单日;prev_today=昨日~今日;month_to_today=本月1日~今日;
# prev_prev=昨日~昨日;month1_to_prev=本月1日~前一天;last_month=上月完整;
# last3_months=近 3 个自然月按月拆分(止日不超过前一天)
# 日期参数字段:报表统计类为 reportDate;开卡订单/会员退卡为 period;
# 日期参数字段:报表统计类为 reportDate;淘宝订单为 createTimePeriod(页面「购买时间」);
# 微盟核销为 validateDatePeriod;开卡订单/会员退卡为 period;
# 礼品卡订单为 receiveTimePeriod(接口限制跨度 ≤31 天,故按月拆分)
REPORTS = [
('团购支付数据', 'report/groupPay/export', 'prev', None, 'reportDate'),
@@ -72,9 +124,9 @@ REPORTS = [
('第三方支付(门店)', 'report/thirdPayShop/export', 'prev', None, 'reportDate'),
('支付数据', 'report/unionPay/export', 'prev', None, 'reportDate'),
('团购数据', 'report/groupData/export', 'prev_today', None, 'reportDate'),
('淘宝订单数据', 'report/taobaoTicket/export', 'prev_today', None, 'reportDate'),
('淘宝订单数据', 'report/taobaoTicket/export', 'prev_today', None, 'createTimePeriod'),
('技师综合业绩', 'report/comprehensivePerformance/export', 'month_to_today', None, 'reportDate'),
('微盟核销统计', 'report/weimeng/exportValidate', 'prev_prev', None, 'reportDate'),
('微盟核销统计', 'report/weimeng/exportValidate', 'prev_prev', None, 'validateDatePeriod'), # 该页日期字段是 validateDatePeriod("起 止")
('小程序订单', 'report/miniProgramOrder/export', 'last_month', None, 'reportDate'),
('小程序订单', 'report/miniProgramOrder/export', 'month_to_today', None, 'reportDate'),
('储值卡消费', 'report/debitCardConsume/export', 'month1_to_prev', None, 'reportDate'),
@@ -87,6 +139,30 @@ REPORTS = [
('礼品卡订单', 'giftcard/order/export', 'last3_months', None, 'receiveTimePeriod'),
]
# ==================== 导出内容选择(UI 勾选) ====================
SCREENSHOT_KEY = '__screenshot__' # 储值卡余额整页截图的勾选键
def report_key(entry):
"""报表稳定勾选键:导出接口#日期规则(与 UI 清单一一对应,跨版本稳定)。"""
_title, path, rule, _extra, _date_key = entry
return f'{path}#{rule}'
def filter_reports(keys):
"""按 UI 勾选键筛选导出内容。
keys 为 None(旧配置/未传)→ 全部导出;否则按勾选键过滤。
返回 (报表列表, 是否含储值卡余额截图)。
"""
if keys is None:
return list(REPORTS), True
wanted = {str(k) for k in keys}
include_shot = SCREENSHOT_KEY in wanted
reports = [e for e in REPORTS if report_key(e) in wanted]
return reports, include_shot
# ==================== 全局钩子(run() 启动时注入) ====================
_log = None
_progress = None