From c8230f0d161d45b3d3b914bdea4950ebdda97388 Mon Sep 17 00:00:00 2001 From: Your Name Date: Thu, 16 Jul 2026 18:35:03 +0800 Subject: [PATCH] =?UTF-8?q?fix:=20=E4=BF=AE=E5=A4=8D3=E4=B8=AA=E9=97=AE?= =?UTF-8?q?=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 1. 对比度: --text-muted 从 #94a3b8 改为 #c8d6e5 (文字更亮) 2. 登录: auth.py 从 .env 文件读取密码,解决后台进程环境变量丢失 3. 实例创建: 同步 instances.py 的 db import (之前缺 import db) --- .env | 1 + auth.py | 21 +++++++++++++++++---- engine/instances.py | 2 ++ templates/base.html | 4 ++-- 4 files changed, 22 insertions(+), 6 deletions(-) create mode 100644 .env 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); }