add pause resume controls to ui

This commit is contained in:
Your Name committed 2026-06-23 02:38:08 +08:00
1 parent 3c7cb45bec
commit d81e00ddbc
13 files changed
+367 -12

No files matched your search

+46 -4
View File
@@ -182,7 +182,12 @@ def handle_get(handler, u, runner, csrf_token: str) -> None:
qlow = q.lower()
filtered = [l for l in cand if qlow in (l or "").lower()]
return handler._send_json(
{"next": total, "lines": filtered, "running": runner.is_running()}
{
"next": total,
"lines": filtered,
"running": runner.is_running(),
"paused": runner.is_paused(),
}
)
except Exception as e:
import traceback
@@ -192,7 +197,12 @@ def handle_get(handler, u, runner, csrf_token: str) -> None:
level="ERROR",
)
return handler._send_json(
{"next": 0, "lines": [], "running": runner.is_running()}
{
"next": 0,
"lines": [],
"running": runner.is_running(),
"paused": runner.is_paused(),
}
)
since = 0
try:
@@ -202,7 +212,12 @@ def handle_get(handler, u, runner, csrf_token: str) -> None:
try:
next_idx, lines = runner.get_logs_since(since)
return handler._send_json(
{"next": next_idx, "lines": lines, "running": runner.is_running()}
{
"next": next_idx,
"lines": lines,
"running": runner.is_running(),
"paused": runner.is_paused(),
}
)
except Exception as e:
import traceback
@@ -212,7 +227,12 @@ def handle_get(handler, u, runner, csrf_token: str) -> None:
level="ERROR",
)
return handler._send_json(
{"next": 0, "lines": [], "running": runner.is_running()}
{
"next": 0,
"lines": [],
"running": runner.is_running(),
"paused": runner.is_paused(),
}
)
if u.path == "/api/logfile-tail":
qs = parse_qs(u.query)
@@ -657,6 +677,28 @@ def handle_post(handler, u, runner, csrf_token: str) -> None:
if u.path == "/api/force-stop":
runner.force_stop()
return handler._send_json({"ok": True, "message": "已执行强制停止"})
if u.path == "/api/pause":
ok = runner.pause()
return handler._send_json(
{
"ok": bool(ok),
"running": runner.is_running(),
"paused": runner.is_paused(),
"message": "已暂停" if ok else "暂停失败",
},
status=200 if ok else 409,
)
if u.path == "/api/resume":
ok = runner.resume()
return handler._send_json(
{
"ok": bool(ok),
"running": runner.is_running(),
"paused": runner.is_paused(),
"message": "已继续" if ok else "继续失败",
},
status=200 if ok else 409,
)
if u.path == "/api/back-key":
body = handler._read_json()
requested_device_id = str(body.get("device_id") or "").strip()