import { PageContainer } from '@ant-design/pro-layout'; import { useEffect, useState } from 'react'; import Comprehensive from './comprehensive'; import Device from './device'; import Init from './init'; import Ops from './ops'; import Service from './service'; export const service = new Service(); const Home = () => { type ViewType = keyof typeof ViewMap; const [current, setCurrent] = useState('comprehensive'); const ViewMap = { init: setCurrent(value)} />, device: , ops: , comprehensive: , }; useEffect(() => { service.queryView().then((resp) => { if (resp.status === 200) { if (resp.result.length == 0) { setCurrent('init'); } else { setCurrent(resp.result[0]?.content); } } }); }, []); return {ViewMap[current]}; }; export default Home;