From 3b5d4982b52e5df093f4236aa0b2ca951af46710 Mon Sep 17 00:00:00 2001 From: jxxghp Date: Tue, 9 Sep 2025 13:50:11 +0800 Subject: [PATCH] add wizard flag --- app/api/endpoints/login.py | 6 ++++++ app/core/config.py | 2 ++ app/schemas/token.py | 2 ++ app/schemas/types.py | 6 ++++-- 4 files changed, 14 insertions(+), 2 deletions(-) diff --git a/app/api/endpoints/login.py b/app/api/endpoints/login.py index d5a961bc..a6b0e77e 100644 --- a/app/api/endpoints/login.py +++ b/app/api/endpoints/login.py @@ -8,8 +8,10 @@ from app import schemas from app.chain.user import UserChain from app.core import security from app.core.config import settings +from app.db.systemconfig_oper import SystemConfigOper from app.helper.sites import SitesHelper # noqa from app.helper.wallpaper import WallpaperHelper +from app.schemas.types import SystemConfigKey router = APIRouter() @@ -29,7 +31,10 @@ def login_access_token( if not success: raise HTTPException(status_code=401, detail=user_or_message) + # 用户等级 level = SitesHelper().auth_level + # 是否显示配置向导 + show_wizard = not SystemConfigOper().get(SystemConfigKey.SetupWizardState) and not settings.ADVANCED_MODE return schemas.Token( access_token=security.create_access_token( userid=user_or_message.id, @@ -45,6 +50,7 @@ def login_access_token( avatar=user_or_message.avatar, level=level, permissions=user_or_message.permissions or {}, + widzard=show_wizard ) diff --git a/app/core/config.py b/app/core/config.py index 313e059e..a1624101 100644 --- a/app/core/config.py +++ b/app/core/config.py @@ -75,6 +75,8 @@ class ConfigModel(BaseModel): DEBUG: bool = False # 是否开发模式 DEV: bool = False + # 高级设置模式 + ADVANCED_MODE: bool = True # ==================== 安全认证配置 ==================== # 密钥 diff --git a/app/schemas/token.py b/app/schemas/token.py index 5b0528d4..5493f880 100644 --- a/app/schemas/token.py +++ b/app/schemas/token.py @@ -20,6 +20,8 @@ class Token(BaseModel): level: int = 1 # 详细权限 permissions: Optional[dict] = Field(default_factory=dict) + # 是否显示配置向导 + widzard: Optional[bool] = None class TokenPayload(BaseModel): diff --git a/app/schemas/types.py b/app/schemas/types.py index 121c9d37..2196f432 100644 --- a/app/schemas/types.py +++ b/app/schemas/types.py @@ -175,8 +175,6 @@ class SystemConfigKey(Enum): UserCustomCSS = "UserCustomCSS" # 用户已安装的插件 UserInstalledPlugins = "UserInstalledPlugins" - # 插件安装统计 - PluginInstallReport = "PluginInstallReport" # 插件文件夹分组配置 PluginFolders = "PluginFolders" # 默认电影订阅规则 @@ -193,6 +191,10 @@ class SystemConfigKey(Enum): NotificationTemplates = "NotificationTemplates" # 刮削开关设置 ScrapingSwitchs = "ScrapingSwitchs" + # 插件安装统计 + PluginInstallReport = "PluginInstallReport" + # 配置向导状态 + SetupWizardState = "SetupWizardState" # 处理进度Key字典