History.js 592 B

12345678910111213141516171819202122232425262728293031323334
  1. import { createBrowserHistory as createHistory } from 'history';
  2. export const History = createHistory({ basename: __BASE_NAME__ });
  3. export const linkTo = link => {
  4. /**
  5. * 跳转页面
  6. */
  7. History.push(link);
  8. };
  9. export const replaceLink = link => {
  10. /**
  11. * 刷新当前页
  12. */
  13. History.replace(link);
  14. };
  15. export const goBack = () => {
  16. /**
  17. * 返回上一页
  18. */
  19. History.goBack();
  20. };
  21. export const toLink = link => {
  22. /**
  23. * 跳转页面
  24. */
  25. window.location.href = link;
  26. };
  27. export const openLink = link => {
  28. /**
  29. * 打开新页面
  30. */
  31. window.open(link);
  32. };