From d53a114dbaa71162c406c68c1419a9b468549ddd Mon Sep 17 00:00:00 2001 From: zhinianboke <115088296+zhinianboke@users.noreply.github.com> Date: Tue, 5 Aug 2025 15:03:38 +0800 Subject: [PATCH] =?UTF-8?q?=E6=B7=BB=E5=8A=A0=E6=98=AF=E5=90=A6=E5=BC=80?= =?UTF-8?q?=E5=90=AF=E6=B3=A8=E5=86=8C=E5=BC=80=E5=85=B3?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- db_manager.py | 3 +- reply_server.py | 113 ++++++++++++++++++++++++++++++++++++++++++++-- static/index.html | 35 ++++++++++++++ static/js/app.js | 113 +++++++++++++++++++++++++++++++++++++++++++++- static/login.html | 30 +++++++++++- 5 files changed, 287 insertions(+), 7 deletions(-) diff --git a/db_manager.py b/db_manager.py index 85b45f4..5e648f4 100644 --- a/db_manager.py +++ b/db_manager.py @@ -342,7 +342,8 @@ class DBManager: # 插入默认系统设置(不包括管理员密码,由reply_server.py初始化) cursor.execute(''' INSERT OR IGNORE INTO system_settings (key, value, description) VALUES - ('theme_color', 'blue', '主题颜色') + ('theme_color', 'blue', '主题颜色'), + ('registration_enabled', 'true', '是否开启用户注册') ''') # 检查并升级数据库 diff --git a/reply_server.py b/reply_server.py index b6b64b6..eac4295 100644 --- a/reply_server.py +++ b/reply_server.py @@ -85,6 +85,8 @@ class LoginResponse(BaseModel): token: Optional[str] = None message: str user_id: Optional[int] = None + username: Optional[str] = None + is_admin: Optional[bool] = None class ChangePasswordRequest(BaseModel): @@ -397,6 +399,33 @@ async def login_page(): # 注册页面路由 @app.get('/register.html', response_class=HTMLResponse) async def register_page(): + # 检查注册是否开启 + from db_manager import db_manager + registration_enabled = db_manager.get_system_setting('registration_enabled') + if registration_enabled != 'true': + return HTMLResponse(''' + + +
+