CloudFunction.jsx 1.8 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758
  1. import React, {Component} from 'react';
  2. import {Layout, Menu } from 'antd';
  3. import Deploy from '../common/deploy/Deploy';
  4. import Api from "./api/Api";
  5. const { Content } = Layout;
  6. class CloudFunction extends Component {
  7. constructor() {
  8. super();
  9. this.state = {
  10. menuLevel2: "deploy",
  11. }
  12. }
  13. switchMenu = (menuName, e) => {
  14. // console.log('menuName', menuName, 'e', e);
  15. this.setState({
  16. [menuName]: e.key,
  17. });
  18. };
  19. render() {
  20. return (
  21. <div>
  22. <Menu
  23. mode="horizontal"
  24. defaultSelectedKeys={['deploy']}
  25. style={{padding: '0 24px', position: 'fixed', width: '100%', zIndex: '1'}}
  26. onClick={(e) => this.switchMenu('menuLevel2', e)}
  27. selectedKeys={[this.state.menuLevel2]}
  28. >
  29. <Menu.Item key="deploy">deploy</Menu.Item>
  30. <Menu.Item key="api">API</Menu.Item>
  31. </Menu>
  32. <Layout style={{ padding: '24px', zIndex: '0'}}>
  33. <Content style={{ padding: '24px', minHeight: 280, background: '#fff',marginTop: '48px' }}>
  34. {(() => {
  35. switch (this.state.menuLevel2) {
  36. case 'deploy':
  37. return <Deploy />;
  38. case 'api':
  39. return <Api />;
  40. default:
  41. return <Deploy />
  42. }
  43. })()}
  44. </Content>
  45. </Layout>
  46. </div>
  47. )
  48. }
  49. }
  50. export default CloudFunction;