Skip to content

Commit 5ae9f8b

Browse files
authored
Fix the user menu sidebar parsing (#912)
1 parent bef65e1 commit 5ae9f8b

File tree

1 file changed

+6
-3
lines changed

1 file changed

+6
-3
lines changed

backend/app/admin/service/menu_service.py

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@ async def get_sidebar(*, db: AsyncSession, request: Request) -> list[dict[str, A
5454
:param request: FastAPI 请求对象
5555
:return:
5656
"""
57-
57+
menu_data = None
5858
if request.user.is_superuser:
5959
menu_data = await menu_dao.get_sidebar(db, None)
6060
else:
@@ -64,8 +64,11 @@ async def get_sidebar(*, db: AsyncSession, request: Request) -> list[dict[str, A
6464
for role in roles:
6565
menu_ids.update(menu.id for menu in role.menus)
6666
menu_data = await menu_dao.get_sidebar(db, list(menu_ids))
67-
menu_tree = get_vben5_tree_data(menu_data)
68-
return menu_tree
67+
68+
if menu_data:
69+
return get_vben5_tree_data(menu_data)
70+
71+
return []
6972

7073
@staticmethod
7174
async def create(*, db: AsyncSession, obj: CreateMenuParam) -> None:

0 commit comments

Comments
 (0)