diff --git a/license_server/api.py b/license_server/api.py
index efc67bd..9d1f9ed 100644
--- a/license_server/api.py
+++ b/license_server/api.py
@@ -80,9 +80,42 @@ def _admin_forbidden() -> HTMLResponse:
return HTMLResponse("
403
需要管理员 token。
", status_code=403)
-def _admin_page(token: str, message: str = "", cards: list[str] | None = None) -> HTMLResponse:
+def _admin_page(
+ service: LicenseService,
+ token: str,
+ message: str = "",
+ cards: list[str] | None = None,
+) -> HTMLResponse:
token_attr = escape(token, quote=True)
- rows = "".join(f"{escape(card)}" for card in (cards or []))
+ stats = service.stats()
+ card_rows = service.list_cards(limit=50)
+ audit_rows = service.audit_logs(limit=30)
+ created_rows = "".join(
+ f"{escape(card)}" for card in (cards or [])
+ )
+ table_rows = "".join(
+ ""
+ f"| #{row.id} | "
+ f"{escape(row.code_hint)} | "
+ f"{escape(row.status)} | "
+ f"{row.days} | "
+ f"{row.activation_count}/{row.max_devices} | "
+ f"{escape(row.customer)} | "
+ f"{escape(row.created_at)} | "
+ f"{escape(row.last_seen_at)} | "
+ "
"
+ for row in card_rows
+ )
+ audit_html = "".join(
+ ""
+ f"| {escape(row.created_at)} | "
+ f"{escape(row.action)} | "
+ f"{escape(row.code_hint)} | "
+ f"{escape(row.machine_fingerprint[:16])} | "
+ f"{escape(row.reason)} | "
+ "
"
+ for row in audit_rows
+ )
message_html = f"{escape(message)}
" if message else ""
html = f"""
@@ -90,43 +123,91 @@ def _admin_page(token: str, message: str = "", cards: list[str] | None = None) -
卡密管理
- 卡密管理
+
+
+
+
卡密管理
+
生成、禁用、解绑设备,并查看最近激活日志。
+
+
+
+
总卡密 {stats["total"]}
+
活跃卡密 {stats["active"]}
+
已禁用 {stats["revoked"]}
+
已绑定设备 {stats["activations"]}
+
{message_html}
+
+
+
+
+
+ 最近卡密
+
+ | ID | 卡密 | 状态 | 天数 | 设备 | 客户 | 创建时间 | 最后在线 |
+ {table_rows}
+
-
- 解绑设备
-
+ 最近审计日志
+
+ | 时间 | 动作 | 卡密 | 机器 | 结果 |
+ {audit_html}
+
+