history.ts 791 B

12345678910111213141516171819202122
  1. // createBrowserHistory 和 createHashHistory。
  2. // 这里我们简单说一下 createBrowserHistory地址栏不带#; createHashHistory 带#
  3. // 根据公司要求自己选择,createBrowserHistory在项目上线的时候需要服务器映射等处理。
  4. import { createHashHistory } from 'history'
  5. const history = createHashHistory()
  6. export default history
  7. export const urlParameter = (data: string) => {
  8. if (data) {
  9. const query = data.substring(data.indexOf("?") + 1);
  10. const arr = query.split("&");
  11. const params = {} as any;
  12. arr.forEach((v) => {
  13. const key = v.substring(0, v.indexOf("="));
  14. const val = v.substring(v.indexOf("=") + 1);
  15. params[key] = val;
  16. });
  17. return params;
  18. } else return {};
  19. };
  20. export const envUrl = window.location.origin