ztxkutils 20.0.5 → 20.0.6

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,8 +1,10 @@
1
1
  /**
2
2
  * @author 陈亚雄
3
3
  * @description 代理路由的push方法,可以用window.open的方式跳转页面
4
+ * routeBasename: 微前端的路由前缀
5
+ * routePrefix: 这个是单体应用所需要的路由前缀,只有再通过window.open打开的页面才会添加这个前缀
4
6
  */
5
- export declare function useHistory(routeBasename?: string): any;
7
+ export declare function useHistory(routeBasename?: string, routePrefix?: string): any;
6
8
  /**
7
9
  * @author 陈亚雄
8
10
  * @description 设置浏览器标题信息
@@ -20,8 +20,10 @@ var _pushTarget = [
20
20
  /**
21
21
  * @author 陈亚雄
22
22
  * @description 代理路由的push方法,可以用window.open的方式跳转页面
23
+ * routeBasename: 微前端的路由前缀
24
+ * routePrefix: 这个是单体应用所需要的路由前缀,只有再通过window.open打开的页面才会添加这个前缀
23
25
  */
24
- function useHistory(routeBasename) {
26
+ function useHistory(routeBasename, routePrefix) {
25
27
  var history = useHistory$1();
26
28
  var historyPush = history.push;
27
29
  history.push = function (path, state, target) {
@@ -83,6 +85,14 @@ function useHistory(routeBasename) {
83
85
  ? "" + routeBasename + _path
84
86
  : _path;
85
87
  }
88
+ // 如果是在非微前端的环境下,属于单体应用的跳转,如果ng配置了前缀,这里要手动补上
89
+ if (!isQiankun() && routePrefix) {
90
+ _path = _path.startsWith('http')
91
+ ? _path
92
+ : routePrefix
93
+ ? "" + routePrefix + _path
94
+ : _path;
95
+ }
86
96
  window.open(_path);
87
97
  }
88
98
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "ztxkutils",
3
- "version": "20.0.5",
3
+ "version": "20.0.6",
4
4
  "description": "",
5
5
  "main": "./dist/index.js",
6
6
  "module": "./dist/index.js",