From c9c41f0183867f379d0f44bf1cf4897d4cc5aa98 Mon Sep 17 00:00:00 2001 From: wwwwwwwww <526125649@qq.com> Date: Tue, 16 Jun 2026 10:29:42 +0800 Subject: [PATCH] 1 --- video-gen-api/app/api/v1/admin.py | 11 ++++++++--- video-gen-app/src/components/NotificationPopup.tsx | 7 +++---- 2 files changed, 11 insertions(+), 7 deletions(-) diff --git a/video-gen-api/app/api/v1/admin.py b/video-gen-api/app/api/v1/admin.py index 4672cadb..12961243 100644 --- a/video-gen-api/app/api/v1/admin.py +++ b/video-gen-api/app/api/v1/admin.py @@ -317,16 +317,21 @@ async def list_admin_notifications( page: int = Query(1, ge=1), page_size: int = Query(20, ge=1, le=500), user_id: str | None = Query(None), + is_read: bool = Query(None), admin: User = Depends(get_admin_user), db: AsyncSession = Depends(get_db), ): - """List unread notifications with optional user_id filter.""" - query = select(Notification).where(Notification.is_read == False).order_by(Notification.created_at.desc()) - count_query = select(func.count(Notification.id)).where(Notification.is_read == False) + """List all notifications with optional filters.""" + query = select(Notification).order_by(Notification.created_at.desc()) + count_query = select(func.count(Notification.id)) if user_id: query = query.where(Notification.user_id == user_id) count_query = count_query.where(Notification.user_id == user_id) + + if is_read is not None: + query = query.where(Notification.is_read == is_read) + count_query = count_query.where(Notification.is_read == is_read) total = (await db.execute(count_query)).scalar() or 0 result = await db.execute(query.offset((page - 1) * page_size).limit(page_size)) diff --git a/video-gen-app/src/components/NotificationPopup.tsx b/video-gen-app/src/components/NotificationPopup.tsx index 2a29d15a..6c198f2a 100644 --- a/video-gen-app/src/components/NotificationPopup.tsx +++ b/video-gen-app/src/components/NotificationPopup.tsx @@ -27,11 +27,10 @@ const NotificationPopup: React.FC = () => { const fetchNotifications = useCallback(async () => { try { - const result = await getNotifications(); + const result = await getNotifications(1, 20, false); const data = result.items || []; - const unread = data.filter((n: Notification) => !n.isRead); - setNotifications(unread); - if (unread.length > 0 && !visible) { + setNotifications(data); + if (data.length > 0 && !visible) { setVisible(true); setCurrentIndex(0); }