diff --git a/src/components/NotificationPanel.tsx b/src/components/NotificationPanel.tsx index c6da965..578bdc2 100644 --- a/src/components/NotificationPanel.tsx +++ b/src/components/NotificationPanel.tsx @@ -2,7 +2,7 @@ 'use client'; -import { Bell, Check, Trash2, X } from 'lucide-react'; +import { Bell, Check, Settings, Trash2, X } from 'lucide-react'; import { useRouter } from 'next/navigation'; import { useEffect, useState } from 'react'; @@ -12,11 +12,13 @@ import { Notification } from '@/lib/types'; interface NotificationPanelProps { isOpen: boolean; onClose: () => void; + onOpenNotificationSettings?: () => void; } export const NotificationPanel: React.FC = ({ isOpen, onClose, + onOpenNotificationSettings, }) => { const router = useRouter(); const [notifications, setNotifications] = useState([]); @@ -144,6 +146,10 @@ export const NotificationPanel: React.FC = ({ } }; + const handleOpenNotificationSettings = () => { + onOpenNotificationSettings?.(); + }; + // 打开面板时加载通知 useEffect(() => { if (isOpen) { @@ -160,7 +166,7 @@ export const NotificationPanel: React.FC = ({ /> {/* 通知面板 */} -
+
{/* 标题栏 */}
@@ -194,13 +200,31 @@ export const NotificationPanel: React.FC = ({
{/* 通知列表 */} -
+
+ {onOpenNotificationSettings && ( + + )} + {loading ? (
) : notifications.length === 0 ? ( -
+

暂无通知

diff --git a/src/components/UserMenu.tsx b/src/components/UserMenu.tsx index bee6746..24592e6 100644 --- a/src/components/UserMenu.tsx +++ b/src/components/UserMenu.tsx @@ -995,13 +995,12 @@ export const UserMenu: React.FC = () => { if (!enabled) { setPushNotificationsBusy(true); try { - let endpoint: string | undefined; const registration = 'serviceWorker' in navigator ? await navigator.serviceWorker.getRegistration() : undefined; const subscription = await registration?.pushManager.getSubscription(); - endpoint = subscription?.endpoint; + const endpoint = subscription?.endpoint; await subscription?.unsubscribe(); await fetch('/api/notifications/push', { method: 'DELETE', @@ -5187,6 +5186,11 @@ export const UserMenu: React.FC = () => { createPortal( { + setIsNotificationPanelOpen(false); + setIsEmailSettingsOpen(true); + void loadEmailSettings(); + }} onClose={() => { setIsNotificationPanelOpen(false); // 不需要在这里刷新,NotificationPanel 内部会触发事件