refactor: 前端登录/权限/界面状态迁移至 zustand
This commit is contained in:
@@ -4,6 +4,7 @@ import { BellOutlined } from '@ant-design/icons';
|
||||
import { useNavigate } from 'react-router-dom';
|
||||
import api from '../api';
|
||||
import { formatNotificationText, notificationTypeLabels } from '../utils/notification-display';
|
||||
import { useUserStore } from '../store/user/userStore';
|
||||
|
||||
interface NotificationItem {
|
||||
id: number;
|
||||
@@ -56,7 +57,7 @@ const NotificationBell: React.FC = () => {
|
||||
// SSE connection — decoupled from popover open state
|
||||
useEffect(() => {
|
||||
fetchUnread();
|
||||
const token = localStorage.getItem('token');
|
||||
const token = useUserStore.getState().token;
|
||||
if (!token) return;
|
||||
const es = new EventSource(`/api/notifications/stream?token=${encodeURIComponent(token)}`);
|
||||
es.onmessage = (event) => {
|
||||
|
||||
Reference in New Issue
Block a user