import useAuthStore from '@/stores/AuthStore' import useConversationStore from '@/stores/ConversationStore' import { useThemeContext } from '@/stores/ThemeContext' import { DownOutlined } from '@ant-design/icons' import { Avatar, Col, Dropdown, Layout, Menu, Row, Space, Typography, theme, Badge, } from 'antd' import 'dayjs/locale/zh-cn' import { useEffect, useState } from 'react' import { Link, NavLink, Outlet, useHref } from 'react-router-dom' import '@/assets/App.css' import AppLogo from '@/assets/highlights_travel_300_300.png' import 'react-chat-elements/dist/main.css' import ReloadPrompt from './ReloadPrompt' import ClearCache from './ClearCache' import { BUILD_VERSION, BUILD_DATE } from '@/config' const { Header, Footer, Content } = Layout const { Title } = Typography function DesktopApp() { const { colorPrimary } = useThemeContext() const loginUser = useAuthStore((state) => state.loginUser) const href = useHref() const totalNotify = useConversationStore((state) => state.totalNotify) let defaultPath = '/order/follow' if (href !== '/') { const splitPath = href.split('/') if (splitPath.length > 2) { defaultPath = '/' + splitPath[1] + '/' + splitPath[2] } } const { token: { colorBgContainer }, } = theme.useToken() /** * 标签页标题闪烁 */ const [isTitleVisible, setIsTitleVisible] = useState(true) useEffect(() => { let interval if (totalNotify > 0) { if ('setAppBadge' in navigator) { navigator.setAppBadge(totalNotify).catch(() => {}) } interval = setInterval(() => { document.title = isTitleVisible ? `🔔🔥💬【${totalNotify}条新消息】` : '______________' setIsTitleVisible(!isTitleVisible) }, 500) } else { document.title = '销售平台' if ('clearAppBadge' in navigator) { navigator.clearAppBadge().catch(() => {}) } } return () => clearInterval(interval) }, [totalNotify, isTitleVisible]) return (
App logo 销售平台 订单跟踪, }, { key: '/order/chat', label: ( 在线聊天 0 ? totalNotify : undefined} style={{ backgroundColor: '#52c41a', }} /> ), }, { key: '/callcenter/call', label: 语音通话, }, { key: '/chat/history', label: 聊天记录, }, ]} /> 个人资料, key: '1', }, { type: 'divider' }, { label: , key: 'reload' }, { type: 'divider' }, { label: , key: 'clearcache' }, { type: 'divider' }, { label: 退出, key: '3', }, ], }} trigger={['click']} > e.preventDefault()} style={{ color: colorPrimary }} > {loginUser?.username?.substring(1)} {loginUser.username}
) } export default DesktopApp