// 兼容 react-router-dom v5&v6，拿到真正的 history
import { useEffect } from 'react';
// import path from 'path';
import { useHistory } from 'react-router-dom';
var path = require('path');
var useRealHistory = function useRealHistory() {
  var history;
  if (useHistory) {
    history = useHistory();
  }
  useEffect(function () {
    if (window.HistoryLibrary) {
      history = window.HistoryLibrary.createBrowserHistory();
      var oldPush = history.push;
      history.push = function (p) {
        var _window$ICESTARK;
        oldPush(path.join(((_window$ICESTARK = window.ICESTARK) === null || _window$ICESTARK === void 0 ? void 0 : _window$ICESTARK.basename) || '/', p));
      };
    }
  }, []);
  return history;
};
export default useRealHistory;