diff --git a/web/src/components/layout/AgentLayout.tsx b/web/src/components/layout/AgentLayout.tsx index 1e5cc8c..983cee5 100644 --- a/web/src/components/layout/AgentLayout.tsx +++ b/web/src/components/layout/AgentLayout.tsx @@ -1,14 +1,17 @@ import { Outlet } from 'react-router-dom' import AgentSidebar from './AgentSidebar' +import { AgentNotificationProvider } from '@/stores/notifications' const AgentLayout = () => { return ( -
- -
- + +
+ +
+ +
-
+ ) } diff --git a/web/src/components/layout/AgentSidebar.tsx b/web/src/components/layout/AgentSidebar.tsx index 7ba1fb6..65ada8e 100644 --- a/web/src/components/layout/AgentSidebar.tsx +++ b/web/src/components/layout/AgentSidebar.tsx @@ -3,10 +3,11 @@ import { useLocation, useNavigate } from 'react-router-dom' import { AppstoreOutlined, MessageOutlined, HistoryOutlined, TeamOutlined, FileTextOutlined, BarChartOutlined, SettingOutlined, LogoutOutlined, - ThunderboltOutlined, DownOutlined, StopOutlined, SafetyOutlined, + ThunderboltOutlined, DownOutlined, StopOutlined, SafetyOutlined, BellOutlined, BellFilled, } from '@ant-design/icons' -import { Dropdown, message as antMsg } from 'antd' +import { Button, Dropdown, message as antMsg, Popover, Switch } from 'antd' import { useAuth } from '@/stores/auth' +import { useAgentNotifications } from '@/stores/notifications' import type { AgentPresence } from '@/services/api' const menuItems = [ @@ -36,7 +37,15 @@ const AgentSidebar = () => { const location = useLocation() const navigate = useNavigate() const { user, permissions, logout, setPresence } = useAuth() - const [switching, setSwitching] = useState(false) + const { + soundEnabled, + desktopEnabled, + permission, + setSoundEnabled, + setDesktopEnabled, + requestDesktopPermission, + } = useAgentNotifications() + const [switching, setSwitching] = useState(false) const visibleMenuItems = menuItems.filter(item => item.permissions.some(code => permissions.has(code))) @@ -62,7 +71,41 @@ const AgentSidebar = () => { } const initial = (user?.nickname || '客').slice(0, 1) - const current = presenceMeta(user?.status || 'online') + const current = presenceMeta(user?.status || 'online') + + const notificationContent = ( +
+
+
+
声音提醒
+
收到访客消息时播放提示音
+
+ +
+
+
+
浏览器通知
+
+ {permission === 'denied' ? '已被浏览器禁止' : permission === 'unsupported' ? '当前浏览器不支持' : '在后台弹出新消息'} +
+
+ { + if (enabled) void requestDesktopPermission() + else setDesktopEnabled(false) + }} + /> +
+ {permission === 'default' && ( + + )} +
+ ) return (
在线客服 + + +