ztxkutils 2.8.12 → 2.8.15

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.
@@ -11,4 +11,4 @@ export declare function useDocumentTitle(title: string): void;
11
11
  export declare function setFilterAuth(): void;
12
12
  export declare function isFilterAuth(): boolean;
13
13
  export declare function setSession(name: any, value: any): void;
14
- export declare function getSession(name: any): any;
14
+ export declare function getSession(name: any): string;
@@ -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,61 +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
- var _a, _b;
23
- // 代理react router dom 的push方法
24
- if (typeof state === 'string' && _pushTarget.includes(state)) {
25
- 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;
26
42
  }
27
- // 如果没有传入target,那么还是使用原生的push方法
28
- if (!target) {
29
- 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;
30
47
  }
31
- else {
32
- // 如果是需要在无框架下,外链打开
33
- if (target === '_blank_noframe' &&
34
- ((_a = window.location.href) === null || _a === void 0 ? void 0 : _a.indexOf(WORKFLOW_HIDEFRAME_KEY)) !== -1) {
35
- // 如果不是在隐藏框架内跳转,那么直接内部打开
36
- history.push(path, state);
37
- return;
38
- }
39
- if (target === '_blank_close' &&
40
- ((_b = window.location.href) === null || _b === void 0 ? void 0 : _b.indexOf(WORKFLOW_HIDEFRAME_KEY)) !== -1) {
41
- window.close();
42
- return;
43
- }
44
- if (target === '_blank_close') {
45
- history.push(path, state);
46
- return;
47
- }
48
- if (target === '_blank' ||
49
- target === '_blank_noframe' ||
50
- target === '_blank_nopre') {
51
- // state 没法处理,请不要传递state,可以拼接再地址栏参数后面
52
- // 新窗口打开的页面 都不需要菜单
53
- var _path = path.indexOf('?') === -1
54
- ? path + "?" + WORKFLOW_HIDEFRAME_KEY + "=1"
55
- : path.indexOf(WORKFLOW_HIDEFRAME_KEY) === -1
56
- ? path + "&" + WORKFLOW_HIDEFRAME_KEY + "=1"
57
- : path;
58
- // 是否是全路径
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') {
59
70
  _path = _path.startsWith('http')
60
71
  ? _path
61
- : _path.startsWith('/')
62
- ? _path
63
- : "/" + _path;
64
- // 如果在微前端里面,需要添加前缀
65
- if (isQiankun() && target !== '_blank_nopre') {
66
- _path = _path.startsWith('http')
67
- ? _path
68
- : routeBasename
69
- ? "" + routeBasename + _path
70
- : _path;
71
- }
72
- window.open(_path);
72
+ : routeBasename
73
+ ? "" + routeBasename + _path
74
+ : _path;
73
75
  }
76
+ window.open(_path);
74
77
  }
75
- } });
78
+ }
79
+ };
80
+ return history;
76
81
  }
77
82
  /**
78
83
  * @author 陈亚雄
@@ -108,7 +113,15 @@ function setSession(name, value) {
108
113
  }
109
114
  function getSession(name) {
110
115
  if (window.opener && Object.getOwnPropertyNames(window.opener).length > 0) {
111
- return window.opener.sessionStorage.getItem(name);
116
+ var v = ROUTER_FILTER_RULES_VALUE;
117
+ try {
118
+ v = window.opener.sessionStorage.getItem(name);
119
+ }
120
+ catch (err) {
121
+ console.log(err, '=========');
122
+ v = ROUTER_FILTER_RULES_VALUE;
123
+ }
124
+ return v;
112
125
  }
113
126
  else {
114
127
  return sessionStorage.getItem(name);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "ztxkutils",
3
- "version": "2.8.12",
3
+ "version": "2.8.15",
4
4
  "description": "",
5
5
  "main": "./dist/index.js",
6
6
  "module": "./dist/index.js",