Files
douyi_guaji_main/douyin_fudai_flow.py
T
Your Name 836a31d817 refactor: Remove outdated files and enhance Web GUI functionality
- Deleted obsolete markdown files related to follow tab coordinates testing and results.
- Removed outdated batch scripts for launching the Web GUI.
- Updated `config.json` to improve reservation handling and adjust prize value settings.
- Enhanced logging and error handling in `web_gui.py` and `app.js` for better user experience.
- Added automatic screenshot functionality during Web GUI startup for improved monitoring.
2025-12-19 03:31:08 +08:00

84 lines
2.7 KiB
Python

from __future__ import annotations
"""
douyin_fudai_flow 代理模块(WebGUI 根目录)
=========================================
完整的流程辅助函数实现位于:
C:\\Users\\12742\\.cursor\\worktrees\\douyin_guaji-main\\axf\\douyin_fudai_flow.py
本模块的作用:
1. 动态加载上述外部模块;
2. 将其中的公开符号(不以下划线开头的名称)导出到当前命名空间;
3. 确保 `stuck_guard_tick` 一定存在(若外部缺失则提供一个安全的空实现)。
这样,当 `axf/douyin_fudai.py` 执行 `import douyin_fudai_flow` 时,
会优先命中本目录的代理模块,避免由于外部模块导入不完整导致
`AttributeError: module 'douyin_fudai_flow' has no attribute 'stuck_guard_tick'`。
"""
import importlib.util
import os
import sys
from types import ModuleType
from typing import Any, Callable
_EXTERNAL_DIR = r"C:\Users\12742\.cursor\worktrees\douyin_guaji-main\axf"
_EXTERNAL_PATH = os.path.join(_EXTERNAL_DIR, "douyin_fudai_flow.py")
def _load_external_flow_module() -> ModuleType:
if not os.path.isfile(_EXTERNAL_PATH):
raise ImportError(f"外部 douyin_fudai_flow.py 不存在: {_EXTERNAL_PATH}")
mod_name = "douyin_fudai_flow_external"
if mod_name in sys.modules:
return sys.modules[mod_name]
spec = importlib.util.spec_from_file_location(mod_name, _EXTERNAL_PATH)
if spec is None or spec.loader is None:
raise ImportError(f"无法创建外部模块 spec: {_EXTERNAL_PATH}")
module = importlib.util.module_from_spec(spec)
spec.loader.exec_module(module) # type: ignore[arg-type]
sys.modules[mod_name] = module
return module
_ext_mod = _load_external_flow_module()
# 先将外部模块中所有公开符号导出到当前命名空间
for _name, _value in list(vars(_ext_mod).items()): # type: ignore[arg-type]
if _name.startswith("_"):
continue
globals()[_name] = _value # type: ignore[assignment]
def _noop_stuck_guard_tick(
analyser: Any,
stuck_last_hash_ref: list,
stuck_same_since_ref: list,
stuck_last_check_ts_ref: list,
stuck_last_back_ts_ref: list,
read_screen_hash_callback: Callable[[], str],
) -> None:
"""安全的空实现:不做任何操作,仅用于兜底避免 AttributeError。"""
try:
analyser._log_kv("自救", "stuck_guard_tick:当前未启用卡死检测")
except Exception:
pass
# 如果外部模块没有正确导出 stuck_guard_tick,则使用本地兜底实现
if "stuck_guard_tick" not in globals():
stuck_guard_tick = _noop_stuck_guard_tick # type: ignore[assignment]
# 清理局部变量,避免泄漏实现细节
del _name, _value
del _ext_mod
del _load_external_flow_module
del _EXTERNAL_DIR, _EXTERNAL_PATH