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.
This commit is contained in:
Your Name committed 2025-12-19 03:31:08 +08:00
1 parent b0bd7c72c8
commit 836a31d817
59 files changed
+17232 -6965

No files matched your search

+55 -3
View File
@@ -624,9 +624,9 @@ class ProcRunner:
if idx < 0:
idx = 0
log_len = len(self._log)
# 如果索引越界,说明日志可能被截断了(比如内存日志被清理)
# 返回所有日志,让前端能够检测到并重置索引
if idx > log_len:
# 如果索引越界或等于日志长度(说明日志可能被截断了),返回所有日志
# 让前端能够检测到并重置索引
if idx >= log_len:
idx = 0
lines = self._log[idx:]
return log_len, lines
@@ -690,6 +690,20 @@ class ProcRunner:
needswitch = bool(_pick("needswitch", False))
reset_after_swipes_enabled = bool(_pick("reset_after_swipes_enabled", False))
wait_minutes = int(_pick("wait_minutes", 5) or 5)
# 启动时自动截图
if device_id:
try:
from Underlying_Operations import underlying_operations
ops = underlying_operations()
self._append_log(f"[启动] 自动截图: device={device_id}")
result = ops.get_screenshot(device_id)
if result:
self._append_log("[启动] 截图成功,已保存到 pic/screenshot.png")
else:
self._append_log("[启动] 截图失败")
except Exception as e:
self._append_log(f"[启动] 截图异常: {e}")
# 这些运行参数与 run_cli.py --help 对齐
min_prize_value_yuan = float(_pick("min_prize_value_yuan", 0) or 0)
@@ -998,6 +1012,29 @@ class Handler(BaseHTTPRequestHandler):
except Exception:
out_lines = ["<failed to read logfile>"]
return self._send_json({"ok": True, "path": path, "lines": out_lines})
if u.path == "/api/actions":
# 返回精简行为日志(logs/actions.log)的尾部若干行,便于在 Web GUI 中单独查看点击/识别耗时
qs = parse_qs(u.query)
try:
n = int((qs.get("lines") or [200])[0])
except Exception:
n = 200
path = os.path.join(BASE_DIR, "logs", "actions.log")
out_lines: list[str] = []
try:
if os.path.exists(path):
size = os.path.getsize(path)
read_bytes = min(size, 65536)
with open(path, "rb") as f:
if read_bytes < size:
f.seek(-read_bytes, os.SEEK_END)
data = f.read().decode("utf-8", errors="replace")
parts = data.splitlines()
out_lines = parts[-n:]
except Exception:
out_lines = ["<failed to read actions.log>"]
return self._send_json({"ok": True, "path": path, "lines": out_lines})
self.send_error(HTTPStatus.NOT_FOUND)
return
@@ -1159,6 +1196,21 @@ class Handler(BaseHTTPRequestHandler):
if u.path == "/api/stop":
RUNNER.stop()
return self._send_json({"ok": True})
if u.path == "/api/screenshot":
# 手动截图接口
body = self._read_json()
device_id = str(body.get("device_id") or "").strip()
try:
from Underlying_Operations import underlying_operations
ops = underlying_operations()
result = ops.get_screenshot(device_id)
if result:
return self._send_json({"ok": True, "message": "截图成功"})
else:
return self._send_json({"ok": False, "error": "截图失败"}, status=500)
except Exception as e:
return self._send_json({"ok": False, "error": str(e)}, status=500)
self.send_error(HTTPStatus.NOT_FOUND)