import React from 'react';
import styles from './index.less';

import {Button } from 'antd';
import { Link, useIntl, connect, Dispatch, history } from 'umi';

import { URL } from '@/utils/method'

const module2="History"
const BackButton = (props:any) => {

  const { history_url, dispatch } = props
  
  
  const url = props.url;
  const goToReturn = () => {
    // history.back()
    URL({ pathname: history.location.pathname ,status:0}, module2, dispatch)
    console.log("这里的地址为")
    console.log(history.location.pathname)
    history.go(-1)
  }
  const goToReturnByParam = () => { 
    if (url == "none") {
      props.backFunction()
    } else {
      console.log("跳转页面" + url)
      history.push(url)
    }
  }
  return (
    <>     
      {
        url != null ?
          <Button onClick={goToReturnByParam}>Back</Button>:<Button onClick={goToReturn}>Back</Button>        
      }
    </>
    )
    
};
function mapStateToProps(state:any) {
  const { history_url} = state.History;  
  return {
    history_url,
  };
}
export default connect(mapStateToProps)(BackButton);
