修复bug
This commit is contained in:
@@ -8,6 +8,10 @@ import asyncio
|
||||
import os
|
||||
from pathlib import Path
|
||||
|
||||
from env_load import load_hub_dotenv
|
||||
|
||||
load_hub_dotenv()
|
||||
|
||||
import httpx
|
||||
from fastapi import Body, FastAPI, HTTPException, Request
|
||||
from fastapi.responses import FileResponse, JSONResponse
|
||||
@@ -39,7 +43,7 @@ HUB_BRIDGE_TOKEN = (os.getenv("HUB_BRIDGE_TOKEN") or os.getenv("CONTROL_TOKEN")
|
||||
_trust_raw = (os.getenv("HUB_TRUST_LAN", "true") or "").strip().lower()
|
||||
HUB_TRUST_LAN = _trust_raw not in ("0", "false", "no", "off")
|
||||
DIR = Path(__file__).resolve().parent
|
||||
HUB_BUILD = "20260521-no-trade-ui"
|
||||
HUB_BUILD = "20260522-settings-fix"
|
||||
|
||||
|
||||
def _is_local(host: str | None) -> bool:
|
||||
@@ -224,9 +228,17 @@ class SettingsBody(BaseModel):
|
||||
|
||||
@app.post("/api/settings")
|
||||
def api_save_settings(body: SettingsBody):
|
||||
data = {"version": 1, "exchanges": body.exchanges}
|
||||
save_settings(data)
|
||||
return {"ok": True}
|
||||
force_off = env_force_disabled_ids()
|
||||
to_save = []
|
||||
for ex in body.exchanges:
|
||||
row = dict(ex)
|
||||
eid = str(row.get("id", "")).strip()
|
||||
if eid in force_off:
|
||||
row["enabled"] = False
|
||||
row.pop("env_disabled", None)
|
||||
to_save.append(row)
|
||||
save_settings({"version": 1, "exchanges": to_save})
|
||||
return {"ok": True, "settings": load_settings()}
|
||||
|
||||
|
||||
@app.get("/api/settings/meta")
|
||||
@@ -438,6 +450,8 @@ def api_ping():
|
||||
"trade_ui": False,
|
||||
"features": ["monitor", "settings", "auth"],
|
||||
"password_required": password_required(),
|
||||
"env_disabled_ids": sorted(env_force_disabled_ids()),
|
||||
"hub_disabled_ids_raw": (os.getenv("HUB_DISABLED_IDS") or ""),
|
||||
}
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user