MyDeploy.jsx 2.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990
  1. import React, {Component} from 'react';
  2. import {FormattedMessage} from 'react-intl';
  3. import {Card, Layout} from 'antd';
  4. import TencentDeploy from './TencentDeploy';
  5. import AliyunDeploy from './AliyunDeploy';
  6. import AmazonDeploy from './AmazonDeploy';
  7. import {getCookie} from "../../../cookie";
  8. const {Content} = Layout;
  9. const tabListNoTitle =
  10. [{
  11. key: 'tencent',
  12. tab: <FormattedMessage id='Tencent'/>,
  13. }, {
  14. key: 'aliyun',
  15. tab: <FormattedMessage id='Aliyun'/>,
  16. }, {
  17. key: 'amazon',
  18. tab: <FormattedMessage id='AWS'/>,
  19. }];
  20. class MyDeploy extends Component {
  21. constructor(props) {
  22. super(props);
  23. this.state = {
  24. cloud: 'tencent',
  25. userID: '',
  26. url: ''
  27. };
  28. }
  29. componentWillMount() {
  30. let userID = getCookie('user_id') || this.state.userID;
  31. if (userID !== undefined && userID !== '') {
  32. this.setState({
  33. userID
  34. });
  35. }
  36. if(this.props.location && this.props.location.state) {
  37. this.setState({
  38. url: this.props.location.state.url
  39. })
  40. }
  41. }
  42. render() {
  43. let {url, userID} = this.state;
  44. const contentListNoTitle = {
  45. tencent: <TencentDeploy userID={userID} url={url}/>,
  46. aliyun: <AliyunDeploy userID={userID} url={url}/>,
  47. amazon: <AmazonDeploy userID={userID} url={url}/>,
  48. };
  49. return (
  50. <div>
  51. <Layout style={{ padding: '24px',minHeight:'300px' }}>
  52. <Content style={{ background: '#fff' }}>
  53. {
  54. // 登录用户与非登录用户区别对待
  55. this.state.userID === ''?
  56. <TencentDeploy userID={userID} url={url}/>
  57. :
  58. <Card
  59. style={{width: '100%'}}
  60. tabList={tabListNoTitle}
  61. activeTabKey={this.state.cloud}
  62. onTabChange={(cloud) => {
  63. this.setState({
  64. cloud
  65. })
  66. }}
  67. >
  68. {contentListNoTitle[this.state.cloud]}
  69. </Card>
  70. }
  71. </Content>
  72. </Layout>
  73. </div>
  74. )
  75. }
  76. }
  77. export default MyDeploy;