diff --git a/.env b/.env new file mode 100644 index 0000000..5e63bb6 --- /dev/null +++ b/.env @@ -0,0 +1 @@ +SM_ADMIN_PASSWORD=test123 diff --git a/auth.py b/auth.py index 5f38690..840328c 100644 --- a/auth.py +++ b/auth.py @@ -7,10 +7,23 @@ bp = Blueprint("auth", __name__) def _get_admin_creds(): - return ( - os.environ.get("SM_ADMIN_USER", "admin"), - os.environ.get("SM_ADMIN_PASSWORD", ""), - ) + import os + _ENV = "/root/socks-manager/.env" + pwd = os.environ.get("SM_ADMIN_PASSWORD") + user = os.environ.get("SM_ADMIN_USER", "admin") + if not pwd and os.path.exists(_ENV): + try: + for line in open(_ENV): + line = line.strip() + if line and not line.startswith("#"): + k, _, v = line.partition("=") + if k.strip() == "SM_ADMIN_PASSWORD": + pwd = v.strip() + elif k.strip() == "SM_ADMIN_USER": + user = v.strip() + except Exception: + pass + return (user, pwd or "") def login_required(f): diff --git a/engine/instances.py b/engine/instances.py index e31475a..e2162ff 100644 --- a/engine/instances.py +++ b/engine/instances.py @@ -141,6 +141,8 @@ class InstanceManager: def sync_instances(self): """根据数据库配置同步实例运行状态。""" + from models import Instance + from database import db self.reload_config() current_names = set(self._config_cache.keys()) diff --git a/templates/base.html b/templates/base.html index dff7422..949c432 100644 --- a/templates/base.html +++ b/templates/base.html @@ -11,7 +11,7 @@ /* ── 全局 ─────────────────────────────────────────────────────── */ :root { --bg-primary:#0b0e14; --bg-secondary:#161922; --bg-tertiary:#1e2235; - --border:#1f2335; --text:#e2e8f0; --text-muted:#94a3b8; + --border:#1f2335; --text:#e2e8f0; --text-muted:#c8d6e5; --accent:#818cf8; --accent-hover:#6366f1; --green:#10b981; --red:#ef4444; --yellow:#f59e0b; --gray:#6b7280; --card-bg:#161922; --input-bg:#0b0e14; @@ -19,7 +19,7 @@ * { box-sizing:border-box; } body { background:var(--bg-primary); color:var(--text); font-family:-apple-system,BlinkMacSystemFont,"Segoe UI",Roboto,"Helvetica Neue",Arial,sans-serif; - font-size:14px; line-height:1.6; } + font-size:16px; line-height:1.7; } a { color:var(--accent); text-decoration:none; } a:hover { color:var(--accent-hover); }