import { useState, useEffect } from 'react'; import PropTypes from 'prop-types'; import { Tabs, Tab, Box, Card } from '@mui/material'; import { IconSettings2, IconActivity, IconSettings } from '@tabler/icons-react'; import OperationSetting from './component/OperationSetting'; import SystemSetting from './component/SystemSetting'; import OtherSetting from './component/OtherSetting'; import AdminContainer from 'ui-component/AdminContainer'; import { useLocation, useNavigate } from 'react-router-dom'; function CustomTabPanel(props) { const { children, value, index, ...other } = props; return ( ); } CustomTabPanel.propTypes = { children: PropTypes.node, index: PropTypes.number.isRequired, value: PropTypes.number.isRequired }; function a11yProps(index) { return { id: `setting-tab-${index}`, 'aria-controls': `setting-tabpanel-${index}` }; } const Setting = () => { const location = useLocation(); const navigate = useNavigate(); const hash = location.hash.replace('#', ''); const tabMap = { operation: 0, system: 1, other: 2 }; const [value, setValue] = useState(tabMap[hash] || 0); const handleChange = (event, newValue) => { setValue(newValue); const hashArray = Object.keys(tabMap); navigate(`#${hashArray[newValue]}`); }; useEffect(() => { const handleHashChange = () => { const hash = location.hash.replace('#', ''); setValue(tabMap[hash] || 0); }; window.addEventListener('hashchange', handleHashChange); return () => { window.removeEventListener('hashchange', handleHashChange); }; }, [location, tabMap]); return ( <> } iconPosition="start" /> } iconPosition="start" /> } iconPosition="start" /> ); }; export default Setting;