LoginTab.js 676 Bytes
Newer Older
ddcat1115's avatar
ddcat1115 committed
1 2 3 4 5 6 7 8
import React, { Component } from 'react';
import PropTypes from 'prop-types';
import { Tabs } from 'antd';

const { TabPane } = Tabs;

const generateId = (() => {
  let i = 0;
afc163's avatar
afc163 committed
9
  return (prefix = '') => {
ddcat1115's avatar
ddcat1115 committed
10 11 12 13 14 15 16
    i += 1;
    return `${prefix}${i}`;
  };
})();

export default class LoginTab extends Component {
  static __ANT_PRO_LOGIN_TAB = true;
陈帅's avatar
陈帅 committed
17

ddcat1115's avatar
ddcat1115 committed
18 19 20
  static contextTypes = {
    tabUtil: PropTypes.object,
  };
陈帅's avatar
陈帅 committed
21

ddcat1115's avatar
ddcat1115 committed
22 23 24 25
  constructor(props) {
    super(props);
    this.uniqueId = generateId('login-tab-');
  }
陈帅's avatar
陈帅 committed
26

ddcat1115's avatar
ddcat1115 committed
27 28 29 30 31
  componentWillMount() {
    if (this.context.tabUtil) {
      this.context.tabUtil.addTab(this.uniqueId);
    }
  }
陈帅's avatar
陈帅 committed
32

ddcat1115's avatar
ddcat1115 committed
33 34 35 36
  render() {
    return <TabPane {...this.props} />;
  }
}