Download center: copy code, online/offline status; remove client offline mode.
Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
+24
-3
@@ -3,6 +3,7 @@ from __future__ import annotations
|
||||
|
||||
import json
|
||||
import secrets
|
||||
from datetime import datetime
|
||||
from functools import wraps
|
||||
|
||||
from flask import (
|
||||
@@ -323,7 +324,8 @@ def register_routes(app: Flask) -> None:
|
||||
if u["role"] == "admin":
|
||||
acts = conn.execute(
|
||||
"""
|
||||
SELECT act.*, a.name AS account_name, m.name AS machine_name
|
||||
SELECT act.*, a.name AS account_name, m.name AS machine_name,
|
||||
m.last_seen_at AS machine_last_seen
|
||||
FROM activations act
|
||||
LEFT JOIN accounts a ON a.id = act.account_id
|
||||
LEFT JOIN machines m ON m.id = act.machine_id
|
||||
@@ -333,7 +335,8 @@ def register_routes(app: Flask) -> None:
|
||||
else:
|
||||
acts = conn.execute(
|
||||
"""
|
||||
SELECT act.*, a.name AS account_name, m.name AS machine_name
|
||||
SELECT act.*, a.name AS account_name, m.name AS machine_name,
|
||||
m.last_seen_at AS machine_last_seen
|
||||
FROM activations act
|
||||
LEFT JOIN accounts a ON a.id = act.account_id
|
||||
LEFT JOIN machines m ON m.id = act.machine_id
|
||||
@@ -342,7 +345,25 @@ def register_routes(app: Flask) -> None:
|
||||
""",
|
||||
(u.get("account_id"),),
|
||||
).fetchall()
|
||||
activations = [database.row_to_dict(r) for r in acts]
|
||||
activations = []
|
||||
now_ts = database.now()
|
||||
online_sec = 180 # 3 分钟内有心跳视为在线
|
||||
for r in acts:
|
||||
item = database.row_to_dict(r)
|
||||
last = item.get("machine_last_seen")
|
||||
if item.get("status") == "active" and last and (now_ts - float(last)) <= online_sec:
|
||||
item["online_label"] = "在线"
|
||||
item["online"] = True
|
||||
else:
|
||||
item["online_label"] = "离线"
|
||||
item["online"] = False
|
||||
try:
|
||||
item["created_at_fmt"] = datetime.fromtimestamp(float(item["created_at"])).strftime(
|
||||
"%Y-%m-%d %H:%M"
|
||||
)
|
||||
except (TypeError, ValueError, OSError):
|
||||
item["created_at_fmt"] = str(item.get("created_at") or "—")
|
||||
activations.append(item)
|
||||
exe_name = "黄金市价辅助.exe"
|
||||
exe_path = RELEASES_DIR / exe_name
|
||||
return render_template(
|
||||
|
||||
Reference in New Issue
Block a user