ztxkutils 2.8.10 → 2.8.13

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