完善 /api/site/config 路由,修复数据库无法二次启动

This commit is contained in:
2025-07-02 00:42:54 +08:00
parent e84b3a7dee
commit e011a1ea0e
4 changed files with 65 additions and 12 deletions

View File

@@ -42,11 +42,40 @@ def router_site_captcha():
description='Get the configuration file.',
response_model=ResponseModel,
)
def router_site_config():
async def router_site_config():
"""
Get the configuration file.
Returns:
dict: The site configuration.
"""
...
from models.setting import Setting
return ResponseModel(
data={
"title": await Setting.get(type='basic', name='siteName'),
"loginCaptcha": await Setting.get(type='login', name='login_captcha', format='bool'),
"regCaptcha": await Setting.get(type='login', name='reg_captcha', format='bool'),
"forgetCaptcha": await Setting.get(type='login', name='forget_captcha', format='bool'),
"emailActive": await Setting.get(type='login', name='email_active', format='bool'),
"QQLogin": None,
"themes": await Setting.get(type='basic', name='themes'),
"defaultTheme": await Setting.get(type='basic', name='defaultTheme'),
"score_enabled": None,
"share_score_rate": None,
"home_view_method": await Setting.get(type='view', name='home_view_method'),
"share_view_method": await Setting.get(type='view', name='share_view_method'),
"authn": await Setting.get(type='authn', name='authn_enabled', format='bool'),
"user": {},
"captcha_type": None,
"captcha_ReCaptchaKey": await Setting.get(type='captcha', name='captcha_ReCaptchaKey'),
"captcha_CloudflareKey": await Setting.get(type='captcha', name='captcha_CloudflareKey'),
"captcha_tcaptcha_appid": None,
"site_notice": None,
"registerEnabled": await Setting.get(type='register', name='register_enabled', format='bool'),
"app_promotion": None,
"wopi_exts": None,
"app_feedback": None,
"app_forum": None,
}
)