Skip to content

Commit

Permalink
fix:issues/26
Browse files Browse the repository at this point in the history
  • Loading branch information
vastsa committed Dec 29, 2022
1 parent 3344f47 commit e9c34a3
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions main.py
Original file line number Diff line number Diff line change
Expand Up @@ -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('/')
Expand All @@ -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 {
Expand Down

0 comments on commit e9c34a3

Please sign in to comment.