From e9c34a3710c9b047ef6ebdc889f7c48a4e07a837 Mon Sep 17 00:00:00 2001 From: lan Date: Thu, 29 Dec 2022 16:51:19 +0800 Subject: [PATCH] fix:issues/26 --- main.py | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/main.py b/main.py index c6ec9338..4ca89917 100644 --- a/main.py +++ b/main.py @@ -98,7 +98,7 @@ async def admin_delete(code: str, s: AsyncSession = Depends(get_session)): async def config(s: AsyncSession = Depends(get_session)): # 从数据库获取系统配置 data = (await s.execute(select(Values).filter(Values.key == 'config'))).scalar_one_or_none() - return {'detail': '获取成功', 'data': data.value if data else {}} + return {'detail': '获取成功', 'data': data.value if data else {'banners': []}} @app.get('/') @@ -114,7 +114,8 @@ async def banner(request: Request, s: AsyncSession = Depends(get_session)): if config and config.value.get('banners'): return { 'detail': '查询成功', - 'data': config.value['banners'] + 'data': config.value['banners'], + 'enable': request.headers.get('pwd', '') == settings.ADMIN_PASSWORD or settings.ENABLE_UPLOAD, } # 如果不存在config,就返回默认的banner return {