import { Component } from 'react';
import { browserHistory } from 'amos-react-router';
import { Store, LocationParam } from 'amos-tool';
import { AmosAlert } from 'amos-framework';
import { cacheConsts } from './../../../utils/cacheUtils';

const lsTool = Store.lsTool;

/**
 * 自动登录，无界面
 *  BaseAutoLogin： props => `tip: string` `hideTip: boolean`
 * @class AutoLogin
 * @extends {Component}
 */
class AutoLogin extends Component {

  componentWillMount() {
    let token = LocationParam.getLocationParamByName('token');
    if (token) {
      lsTool.remove(cacheConsts.CURRENT_REGION);
      // browserHistory.push('/region');
    } else {
      AmosAlert.error('警告', '无法打开该系统，请重新尝试!');
    }
  }

  render() {
    return null;
  }
}

export default AutoLogin;
