ztxkutils 2.8.11 → 2.8.14

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.
Files changed (2) hide show
  1. package/dist/useHistory.js +55 -49
  2. package/package.json +1 -1
@@ -1,9 +1,12 @@
1
- import { _ as __assign } from './tslib.es6-f9459658.js';
2
1
  import { useEffect } from 'react';
3
2
  import { useHistory as useHistory$1 } from 'react-router-dom';
4
3
  import { i as isQiankun } from './authority-5bc06c1a.js';
5
4
  import { WORKFLOW_HIDEFRAME_KEY } from './constants.js';
6
5
 
6
+ /**
7
+ * @author 陈亚雄
8
+ * @description 路由跳转方法
9
+ */
7
10
  var ROUTER_FILTER_RULES_KEY = '__symbol__alias__session';
8
11
  var ROUTER_FILTER_RULES_VALUE = 'zQzNDkwNjg2MjYwMjI4MDk3LDEzNDU5Nzg1';
9
12
  var _pushTarget = [
@@ -18,60 +21,63 @@ var _pushTarget = [
18
21
  */
19
22
  function useHistory(routeBasename) {
20
23
  var history = useHistory$1();
21
- return __assign(__assign({}, history), { push: function (path, state, target) {
22
- // 代理react router dom 的push方法
23
- if (typeof state === 'string' && _pushTarget.includes(state)) {
24
- target = state;
24
+ var historyPush = history.push;
25
+ history.push = function (path, state, target) {
26
+ var _a, _b;
27
+ // 代理react router dom 的push方法
28
+ if (typeof state === 'string' && _pushTarget.includes(state)) {
29
+ target = state;
30
+ }
31
+ // 如果没有传入target,那么还是使用原生的push方法
32
+ if (!target) {
33
+ historyPush(path, state);
34
+ }
35
+ else {
36
+ // 如果是需要在无框架下,外链打开
37
+ if (target === '_blank_noframe' &&
38
+ ((_a = window.location.href) === null || _a === void 0 ? void 0 : _a.indexOf(WORKFLOW_HIDEFRAME_KEY)) !== -1) {
39
+ // 如果不是在隐藏框架内跳转,那么直接内部打开
40
+ historyPush(path, state);
41
+ return;
25
42
  }
26
- // 如果没有传入target,那么还是使用原生的push方法
27
- if (!target) {
28
- history.push(path, state);
43
+ if (target === '_blank_close' &&
44
+ ((_b = window.location.href) === null || _b === void 0 ? void 0 : _b.indexOf(WORKFLOW_HIDEFRAME_KEY)) !== -1) {
45
+ window.close();
46
+ return;
29
47
  }
30
- else {
31
- // 如果是需要在无框架下,外链打开
32
- if (target === '_blank_noframe' &&
33
- path.indexOf(WORKFLOW_HIDEFRAME_KEY) !== -1) {
34
- // 如果不是在隐藏框架内跳转,那么直接内部打开
35
- history.push(path, state);
36
- return;
37
- }
38
- if (target === '_blank_close' &&
39
- path.indexOf(WORKFLOW_HIDEFRAME_KEY) !== -1) {
40
- window.close();
41
- return;
42
- }
43
- if (target === '_blank_close') {
44
- history.push(path, state);
45
- return;
46
- }
47
- if (target === '_blank' ||
48
- target === '_blank_noframe' ||
49
- target === '_blank_nopre') {
50
- // state 没法处理,请不要传递state,可以拼接再地址栏参数后面
51
- // 新窗口打开的页面 都不需要菜单
52
- var _path = path.indexOf('?') === -1
53
- ? path + "?" + WORKFLOW_HIDEFRAME_KEY + "=1"
54
- : path.indexOf(WORKFLOW_HIDEFRAME_KEY) === -1
55
- ? path + "&" + WORKFLOW_HIDEFRAME_KEY + "=1"
56
- : path;
57
- // 是否是全路径
48
+ if (target === '_blank_close') {
49
+ historyPush(path, state);
50
+ return;
51
+ }
52
+ if (target === '_blank' ||
53
+ target === '_blank_noframe' ||
54
+ target === '_blank_nopre') {
55
+ // state 没法处理,请不要传递state,可以拼接再地址栏参数后面
56
+ // 新窗口打开的页面 都不需要菜单
57
+ var _path = path.indexOf('?') === -1
58
+ ? path + "?" + WORKFLOW_HIDEFRAME_KEY + "=1"
59
+ : path.indexOf(WORKFLOW_HIDEFRAME_KEY) === -1
60
+ ? path + "&" + WORKFLOW_HIDEFRAME_KEY + "=1"
61
+ : path;
62
+ // 是否是全路径
63
+ _path = _path.startsWith('http')
64
+ ? _path
65
+ : _path.startsWith('/')
66
+ ? _path
67
+ : "/" + _path;
68
+ // 如果在微前端里面,需要添加前缀
69
+ if (isQiankun() && target !== '_blank_nopre') {
58
70
  _path = _path.startsWith('http')
59
71
  ? _path
60
- : _path.startsWith('/')
61
- ? _path
62
- : "/" + _path;
63
- // 如果在微前端里面,需要添加前缀
64
- if (isQiankun() && target !== '_blank_nopre') {
65
- _path = _path.startsWith('http')
66
- ? _path
67
- : routeBasename
68
- ? "" + routeBasename + _path
69
- : _path;
70
- }
71
- window.open(_path);
72
+ : routeBasename
73
+ ? "" + routeBasename + _path
74
+ : _path;
72
75
  }
76
+ window.open(_path);
73
77
  }
74
- } });
78
+ }
79
+ };
80
+ return history;
75
81
  }
76
82
  /**
77
83
  * @author 陈亚雄
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "ztxkutils",
3
- "version": "2.8.11",
3
+ "version": "2.8.14",
4
4
  "description": "",
5
5
  "main": "./dist/index.js",
6
6
  "module": "./dist/index.js",