Add curated env config UI with Chinese labels and deploy secret bootstrap

Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
dekun
2026-07-08 21:03:00 +08:00
parent 0b91d26f71
commit 0d2ce9c126
11 changed files with 767 additions and 23 deletions
+12 -11
View File
@@ -8,12 +8,12 @@ from typing import Any, Callable
from flask import jsonify, request, session
from lib.env.env_file_lib import apply_env_updates, env_get, read_env_lines
from lib.env.env_schema import (
build_env_payload,
parse_env_example_schema,
updates_need_restart,
validate_env_updates,
from lib.env.env_ui_manifest import (
build_env_ui_payload,
filter_updates_for_ui,
validate_env_ui_updates,
)
from lib.env.env_schema import parse_env_example_schema
from lib.instance.instance_display_prefs_lib import (
display_meta_for_ui,
get_display_prefs,
@@ -85,26 +85,27 @@ def register_instance_settings_routes(
@app.route("/api/settings/env/meta", methods=["GET"])
@api_auth
def api_env_meta():
payload = build_env_payload(example_path, env_path)
return jsonify({"ok": True, **payload})
groups = build_env_ui_payload(exchange_key, example_path, env_path)
return jsonify({"ok": True, "groups": groups})
@app.route("/api/settings/env", methods=["GET", "POST"])
@api_auth
def api_settings_env():
if request.method == "GET":
payload = build_env_payload(example_path, env_path)
return jsonify({"ok": True, **payload})
groups = build_env_ui_payload(exchange_key, example_path, env_path)
return jsonify({"ok": True, "groups": groups})
body = request.get_json(silent=True) or {}
updates = body.get("values") if isinstance(body.get("values"), dict) else body
if not isinstance(updates, dict):
return jsonify({"ok": False, "msg": "无效请求体"}), 400
groups = parse_env_example_schema(example_path)
clean, errors = validate_env_updates(groups, updates)
updates = filter_updates_for_ui(exchange_key, updates)
clean, errors = validate_env_ui_updates(exchange_key, example_path, updates)
if errors:
return jsonify({"ok": False, "msg": "; ".join(errors)}), 400
if not clean:
return jsonify({"ok": True, "changed_keys": [], "restart_required": False})
changed = apply_env_updates(env_path, clean)
groups = parse_env_example_schema(example_path)
reload_info = apply_env_reload(env_path, get_db, changed, groups)
return jsonify(
{