antd-management-fast-framework 1.11.16 → 1.11.17
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.
package/License.txt
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2021 luzhitao
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
|
@@ -3,7 +3,7 @@ declare class AuthorizationWrapper extends SupplementWrapper {
|
|
|
3
3
|
componentAuthority: any;
|
|
4
4
|
doDidMountTask: () => void;
|
|
5
5
|
checkAuthority: (auth: any) => boolean;
|
|
6
|
-
checkAuthorities: (auth: any) =>
|
|
6
|
+
checkAuthorities: (auth: any) => any;
|
|
7
7
|
getCurrentOperator: () => any;
|
|
8
8
|
reloadCurrentOperator: (callback?: any) => void;
|
|
9
9
|
}
|
package/es/utils/authority.d.ts
CHANGED
package/es/utils/authority.js
CHANGED
|
@@ -3,10 +3,8 @@
|
|
|
3
3
|
Object.defineProperty(exports, "__esModule", {
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
|
-
exports.checkHasAuthorities = checkHasAuthorities;
|
|
7
6
|
exports.checkHasAuthority = checkHasAuthority;
|
|
8
7
|
exports.checkIsSuper = checkIsSuper;
|
|
9
|
-
exports.getAllAuthority = getAllAuthority;
|
|
10
8
|
exports.setAuthority = setAuthority;
|
|
11
9
|
|
|
12
10
|
var _tools = require("./tools");
|
|
@@ -18,6 +16,7 @@ var _globalStorageAssist = require("./globalStorageAssist");
|
|
|
18
16
|
var _Authorized = require("./Authorized");
|
|
19
17
|
|
|
20
18
|
var authorityCollectionCache = 'authorityCollectionCache';
|
|
19
|
+
var superPermissionCacheKey = 'hasSuperPermission';
|
|
21
20
|
|
|
22
21
|
function getAllAuthorityCore() {
|
|
23
22
|
var result = [];
|
|
@@ -57,23 +56,73 @@ function getAllAuthorityCore() {
|
|
|
57
56
|
return result;
|
|
58
57
|
}
|
|
59
58
|
|
|
59
|
+
function getSuperPermission() {
|
|
60
|
+
var result = '';
|
|
61
|
+
var accessWayCollection = (0, _globalStorageAssist.getAccessWayCollectionCache)();
|
|
62
|
+
|
|
63
|
+
if (!(0, _tools.isObject)(accessWayCollection)) {
|
|
64
|
+
return result;
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
var superPermission = (0, _tools.getValueByKey)({
|
|
68
|
+
data: accessWayCollection,
|
|
69
|
+
key: 'super'
|
|
70
|
+
});
|
|
71
|
+
|
|
72
|
+
if ((0, _tools.isObject)(superPermission)) {
|
|
73
|
+
var _superAuth = (0, _tools.getValueByKey)({
|
|
74
|
+
data: superPermission,
|
|
75
|
+
key: 'permission'
|
|
76
|
+
});
|
|
77
|
+
|
|
78
|
+
if ((0, _tools.isString)(_superAuth)) {
|
|
79
|
+
result = _superAuth;
|
|
80
|
+
}
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
return result;
|
|
84
|
+
}
|
|
85
|
+
|
|
60
86
|
function getAllAuthority() {
|
|
61
87
|
return getAllAuthorityCore();
|
|
62
88
|
}
|
|
63
89
|
|
|
64
90
|
function checkIsSuper() {
|
|
65
|
-
var
|
|
91
|
+
var existCache = (0, _cacheAssist.hasCache)({
|
|
92
|
+
key: superPermissionCacheKey
|
|
93
|
+
});
|
|
66
94
|
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
}) || '';
|
|
95
|
+
if (existCache) {
|
|
96
|
+
result = (0, _cacheAssist.getCache)({
|
|
97
|
+
key: superPermissionCacheKey
|
|
98
|
+
});
|
|
72
99
|
|
|
73
|
-
|
|
74
|
-
|
|
100
|
+
if (result !== undefined) {
|
|
101
|
+
return !!result;
|
|
102
|
+
}
|
|
103
|
+
}
|
|
104
|
+
|
|
105
|
+
var superPermission = getSuperPermission();
|
|
106
|
+
|
|
107
|
+
if (!(0, _tools.stringIsNullOrWhiteSpace)(superPermission)) {
|
|
108
|
+
var list = getAllAuthority();
|
|
109
|
+
var isSuper = (list || []).find(function (o) {
|
|
110
|
+
return o === superPermission;
|
|
111
|
+
}) || '';
|
|
112
|
+
|
|
113
|
+
if (isSuper === superPermission) {
|
|
114
|
+
(0, _cacheAssist.setCache)({
|
|
115
|
+
key: superPermissionCacheKey,
|
|
116
|
+
value: true
|
|
117
|
+
});
|
|
118
|
+
return true;
|
|
119
|
+
}
|
|
75
120
|
}
|
|
76
121
|
|
|
122
|
+
(0, _cacheAssist.setCache)({
|
|
123
|
+
key: superPermissionCacheKey,
|
|
124
|
+
value: false
|
|
125
|
+
});
|
|
77
126
|
return false;
|
|
78
127
|
}
|
|
79
128
|
|
|
@@ -82,7 +131,7 @@ function checkHasAuthorities(authCollection) {
|
|
|
82
131
|
|
|
83
132
|
if ((0, _tools.isArray)(authCollection)) {
|
|
84
133
|
authCollection.forEach(function (auth) {
|
|
85
|
-
result =
|
|
134
|
+
result = checkHasAuthorityCore(auth);
|
|
86
135
|
|
|
87
136
|
if (result) {
|
|
88
137
|
return true;
|
|
@@ -90,7 +139,7 @@ function checkHasAuthorities(authCollection) {
|
|
|
90
139
|
});
|
|
91
140
|
|
|
92
141
|
for (var _auth in authCollection) {
|
|
93
|
-
result =
|
|
142
|
+
result = checkHasAuthorityCore(_auth);
|
|
94
143
|
|
|
95
144
|
if (result) {
|
|
96
145
|
break;
|
|
@@ -101,7 +150,7 @@ function checkHasAuthorities(authCollection) {
|
|
|
101
150
|
}
|
|
102
151
|
|
|
103
152
|
if ((0, _tools.isString)(authCollection)) {
|
|
104
|
-
result =
|
|
153
|
+
result = checkHasAuthorityCore(authCollection);
|
|
105
154
|
return result;
|
|
106
155
|
}
|
|
107
156
|
|
|
@@ -115,8 +164,10 @@ function checkHasAuthorities(authCollection) {
|
|
|
115
164
|
return result;
|
|
116
165
|
}
|
|
117
166
|
|
|
118
|
-
function
|
|
119
|
-
|
|
167
|
+
function checkHasAuthorityCore(auth) {
|
|
168
|
+
if (checkIsSuper()) {
|
|
169
|
+
return true;
|
|
170
|
+
}
|
|
120
171
|
|
|
121
172
|
if ((0, _tools.isObject)(auth)) {
|
|
122
173
|
console.log({
|
|
@@ -140,21 +191,8 @@ function checkHasAuthority(auth) {
|
|
|
140
191
|
}
|
|
141
192
|
}
|
|
142
193
|
|
|
143
|
-
var list =
|
|
194
|
+
var list = getAllAuthority();
|
|
144
195
|
var accessWayCollection = (0, _globalStorageAssist.getAccessWayCollectionCache)();
|
|
145
|
-
var superAuth = (_accessWayCollection$ = accessWayCollection.super.permission) !== null && _accessWayCollection$ !== void 0 ? _accessWayCollection$ : '';
|
|
146
|
-
var isSuper = (list || []).find(function (o) {
|
|
147
|
-
return o === superAuth;
|
|
148
|
-
});
|
|
149
|
-
|
|
150
|
-
if (isSuper === superAuth) {
|
|
151
|
-
(0, _cacheAssist.setCache)({
|
|
152
|
-
key: auth,
|
|
153
|
-
value: '1'
|
|
154
|
-
});
|
|
155
|
-
return true;
|
|
156
|
-
}
|
|
157
|
-
|
|
158
196
|
var v = (list || []).find(function (o) {
|
|
159
197
|
return o === auth;
|
|
160
198
|
});
|
|
@@ -175,6 +213,28 @@ function checkHasAuthority(auth) {
|
|
|
175
213
|
});
|
|
176
214
|
return result !== '0';
|
|
177
215
|
}
|
|
216
|
+
|
|
217
|
+
function checkHasAuthority(auth) {
|
|
218
|
+
if ((0, _tools.isObject)(auth)) {
|
|
219
|
+
console.log({
|
|
220
|
+
auth: auth,
|
|
221
|
+
attachedTargetName: (this || null) != null ? (this.constructor || null) != null ? this.constructor.name : '' : ''
|
|
222
|
+
});
|
|
223
|
+
}
|
|
224
|
+
|
|
225
|
+
if ((0, _tools.isArray)(auth)) {
|
|
226
|
+
return checkHasAuthorities(auth);
|
|
227
|
+
}
|
|
228
|
+
|
|
229
|
+
if ((0, _tools.isString)(auth)) {
|
|
230
|
+
return checkHasAuthorityCore(auth);
|
|
231
|
+
}
|
|
232
|
+
|
|
233
|
+
(0, _tools.recordObject)({
|
|
234
|
+
auth: auth
|
|
235
|
+
});
|
|
236
|
+
throw new Error('auth need string or string array, please check in console.');
|
|
237
|
+
}
|
|
178
238
|
/**
|
|
179
239
|
* 缓存用户权限数据体
|
|
180
240
|
* @param {*} authority
|
|
@@ -398,7 +398,7 @@ function request(_x) {
|
|
|
398
398
|
|
|
399
399
|
function _request() {
|
|
400
400
|
_request = _asyncToGenerator( /*#__PURE__*/regeneratorRuntime.mark(function _callee(_ref4) {
|
|
401
|
-
var api, _ref4$params, params, _ref4$method, method, _ref4$useVirtualReque, useVirtualRequest, _ref4$showUseVirtualR, showUseVirtualRequestMessage, _ref4$virtualSuccessR, virtualSuccessResponse, _ref4$virtualFailResp, virtualFailResponse, _ref4$virtualRequestR, virtualRequestResult, _ref4$virtualNeedAuth, virtualNeedAuthorize, apiVersion, url, showRequestInfo,
|
|
401
|
+
var api, _ref4$params, params, _ref4$method, method, _ref4$useVirtualReque, useVirtualRequest, _ref4$showUseVirtualR, showUseVirtualRequestMessage, _ref4$virtualSuccessR, virtualSuccessResponse, _ref4$virtualFailResp, virtualFailResponse, _ref4$virtualRequestR, virtualRequestResult, _ref4$virtualNeedAuth, virtualNeedAuthorize, apiVersion, url, showRequestInfo, result, verifyToken, token, loginPath;
|
|
402
402
|
|
|
403
403
|
return regeneratorRuntime.wrap(function _callee$(_context) {
|
|
404
404
|
while (1) {
|
|
@@ -441,10 +441,12 @@ function _request() {
|
|
|
441
441
|
}
|
|
442
442
|
|
|
443
443
|
if (showUseVirtualRequestMessage) {
|
|
444
|
-
|
|
445
|
-
|
|
446
|
-
|
|
447
|
-
|
|
444
|
+
setTimeout(function () {
|
|
445
|
+
var text = '由虚拟访问返回';
|
|
446
|
+
(0, _tools.showInfoMessage)({
|
|
447
|
+
message: text
|
|
448
|
+
});
|
|
449
|
+
}, 500);
|
|
448
450
|
}
|
|
449
451
|
|
|
450
452
|
result = {};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "antd-management-fast-framework",
|
|
3
|
-
"version": "1.11.
|
|
3
|
+
"version": "1.11.17",
|
|
4
4
|
"description": "antd-management-fast-framework",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"antd-management-fast-framework"
|
|
@@ -167,5 +167,5 @@
|
|
|
167
167
|
"bugs": {
|
|
168
168
|
"url": "https://github.com/kityandhero/antd-management-fast-framework/issues"
|
|
169
169
|
},
|
|
170
|
-
"gitHead": "
|
|
170
|
+
"gitHead": "70323abf4d38c2c07c61e4e66fd386516f623495"
|
|
171
171
|
}
|