index.tsx 1.55 KB
Newer Older
DarkForst's avatar
DarkForst committed
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51
import React, {useEffect, useState} from 'react';
import {Card, Tabs} from 'antd'
import Topology from './components/tabs/Topology'
import Site from './components/tabs/Site'
import Group from './components/tabs/Group'
import classNames from "classnames";
import utilsStyles from "@/utils/utils.less";
import {insideAccess} from '@/access'

type SystemTabKey = 'topology' | 'site' | 'group'

const {TabPane} = Tabs

const Index: React.FC = () => {
  const [tabKey, setTabKey] = useState<SystemTabKey>('topology');
  const tabChange = (tabKeys: string) => {
    setTabKey(tabKeys as SystemTabKey)
  }

  useEffect(() => {
    const tab = insideAccess('cxTricOxVtF') ? 'topology' : 'group'
    setTabKey(tab)
  }, [])

  return (
    <div className={ classNames(utilsStyles.disFlexCol, utilsStyles.fullContainer) }>
      <div className={ utilsStyles.subMenus } style={{padding: '0 15px'}}>
        <Tabs onChange={tabChange}>
          {insideAccess('cxTricOxVtF') && (
            <>
              <TabPane tab="系统拓扑" key="topology"/>
              <TabPane tab="站点管理" key="site"/>
            </>
          )}
          <TabPane tab="设备组" key="group"/>
        </Tabs>
      </div>
      <Card size="small" style={{flex: 1}} bodyStyle={{display: 'flex', flexDirection: 'column', height: '100%'}}>
        {insideAccess('cxTricOxVtF') && (
          <>
            {tabKey === 'topology' && <Topology/>}
            {tabKey === 'site' && <Site/>}
          </>
        )}
         {tabKey === 'group' && <Group />}
      </Card>
    </div>
  );
};

export default Index;