import React, { ReactNode, useEffect, useState } from 'react'; import { Breadcrumb, Layout, Menu } from '@arco-design/web-react'; import { IconRobot, IconDashboard, IconIdcard, } from '@arco-design/web-react/icon'; import './Home.css'; import { Link, Navigate, Outlet, useLocation, useNavigate, } from 'react-router-dom'; import { useAppSelector } from '../app/hooks'; import { selectIsLogin } from '../features/auth/authSlice'; export default function Home() { const location = useLocation(); const navigate = useNavigate(); const isLogin = useAppSelector(selectIsLogin); const path = location.pathname; useEffect(() => { if (path === '/home') { navigate('/home/groups'); } if (path !== '/home/groups' && !path.startsWith('/home/groups/') && path !== '/home/weight') { navigate('/home/groups'); } if (path === '/home/cookie') { navigate('/home/cookie'); } if (path.startsWith('/home/cookie/')) { navigate(path); } }, [path]); let currentKey = ''; if (path === '/home/groups') { currentKey = 'groups'; } else if (path.startsWith('/home/groups/')) { currentKey = 'subs'; } else if (path.startsWith('/home/cookie/')) { currentKey = 'cookie'; } const [selectedTab, changeSelectTab] = useState(currentKey); const handleTabSelect = (tab: string) => { changeSelectTab(tab); if (tab === 'groups') { navigate('/home/groups'); } else if (tab === 'weight') { navigate('/home/weight'); } else if (tab === 'cookie') { navigate('/home/cookie'); } }; if (!isLogin) { return ; } let breadcrumbContent: ReactNode; if (path === '/home/groups') { breadcrumbContent = ( 订阅管理 ); } else if (path.startsWith('/home/groups/')) { breadcrumbContent = ( 订阅管理 群管理 ); } else if (path === '/home/weight') { breadcrumbContent = ( 调度权重 ); } else if (path.startsWith('/home/cookie')) { breadcrumbContent = ( Cookie 管理 ); } return ( Nonebot Bison { handleTabSelect(key); }} > 订阅管理 Cookie 管理 调度权重 {breadcrumbContent} ); }