feat: add super admin v2 debug console

This commit is contained in:
Codex Agent 2025-11-24 15:18:49 +08:00
parent 9aa6fabfb1
commit 9a392f62b0
2 changed files with 1027 additions and 2 deletions

View File

@ -6,7 +6,7 @@ import time
from io import BytesIO from io import BytesIO
from flask import Blueprint, jsonify, request, send_file from flask import Blueprint, jsonify, request, send_file
from concurrent.futures import ThreadPoolExecutor from concurrent.futures import ThreadPoolExecutor
from typing import Any, Dict, Optional from typing import Any, Dict, Iterable, Optional
from lawrisk.api.auth import login_required, get_current_user, ensure_admin_access from lawrisk.api.auth import login_required, get_current_user, ensure_admin_access
from lawrisk.services.lawrisk_v2_service import search_v2, list_regions, suggest_related_questions from lawrisk.services.lawrisk_v2_service import search_v2, list_regions, suggest_related_questions
@ -235,6 +235,18 @@ def super_admin_page():
return send_file(html_path, mimetype='text/html') return send_file(html_path, mimetype='text/html')
@v2_bp.route('/admin/v2-debug', methods=['GET'])
def super_admin_v2_debug_page():
"""Serve the V2 debugging console for super administrators."""
_, error = _admin_guard(roles=("admin",))
if error:
return error
html_path = os.path.join(_project_root(), 'static', 'v2_admin_debug.html')
if not os.path.exists(html_path):
return jsonify({"success": False, "message": "调试页面不存在"}), 404
return send_file(html_path, mimetype='text/html')
@v2_bp.route('/admin/users', methods=['GET']) @v2_bp.route('/admin/users', methods=['GET'])
def admin_list_users(): def admin_list_users():
"""List users for the super admin console.""" """List users for the super admin console."""
@ -1479,4 +1491,3 @@ def admin_permits_filter_options():
except Exception as exc: except Exception as exc:
print(f"admin_permits_filter_options error: {exc}") print(f"admin_permits_filter_options error: {exc}")
return jsonify({"success": False, "message": str(exc)}), 500 return jsonify({"success": False, "message": str(exc)}), 500

1014
static/v2_admin_debug.html Normal file

File diff suppressed because it is too large Load Diff