@bchr/bchr-front-lib 0.4.5 → 0.5.2
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/lib/base/layout/ActionButton.js +705 -0
- package/lib/base/utils/Arrays.js +37 -0
- package/lib/base/utils/CNKits.js +227 -0
- package/lib/base/utils/CharReplaceUtils.js +111 -0
- package/lib/base/utils/DES24JS.js +58 -0
- package/lib/base/utils/DateTimes.js +163 -0
- package/lib/base/utils/FormDatas.js +109 -0
- package/lib/base/utils/LangTypes.js +173 -0
- package/lib/base/utils/Objects.js +60 -0
- package/lib/base/utils/Randoms.js +146 -0
- package/lib/base/utils/Strings.js +152 -0
- package/lib/base/utils/TreeDataUtils.js +165 -0
- package/lib/base/utils/Values.js +181 -0
- package/lib/base/utils/index.js +45 -0
- package/lib/services/http.js +486 -0
- package/lib/style/ExtCustomKendo.less +1063 -935
- package/package.json +5 -2
- package/src/base/layout/ActionButton.js +628 -0
- package/src/base/utils/Arrays.js +29 -0
- package/src/base/utils/CNKits.js +236 -0
- package/src/base/utils/CharReplaceUtils.js +99 -0
- package/src/base/utils/DES24JS.js +54 -0
- package/src/base/utils/DateTimes.js +136 -0
- package/src/base/utils/FormDatas.js +103 -0
- package/src/base/utils/LangTypes.js +202 -0
- package/src/base/utils/Objects.js +48 -0
- package/src/base/utils/Randoms.js +142 -0
- package/src/base/utils/Strings.js +146 -0
- package/src/base/utils/TreeDataUtils.js +128 -0
- package/src/base/utils/Values.js +196 -0
- package/src/base/utils/index.js +15 -0
- package/src/services/http.js +460 -0
- package/src/style/ExtCustomKendo.less +1063 -935
|
@@ -0,0 +1,181 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports["default"] = void 0;
|
|
7
|
+
|
|
8
|
+
var _decimal = _interopRequireDefault(require("decimal.js"));
|
|
9
|
+
|
|
10
|
+
var _lodash = _interopRequireDefault(require("lodash"));
|
|
11
|
+
|
|
12
|
+
var _moment = _interopRequireDefault(require("moment"));
|
|
13
|
+
|
|
14
|
+
var _Strings = _interopRequireDefault(require("./Strings"));
|
|
15
|
+
|
|
16
|
+
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }
|
|
17
|
+
|
|
18
|
+
var Values = {
|
|
19
|
+
ifNull: function ifNull(rawValue, defaultValue) {
|
|
20
|
+
if (rawValue === null || rawValue === void 0) {
|
|
21
|
+
return defaultValue;
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
return rawValue;
|
|
25
|
+
},
|
|
26
|
+
ifEmpty: function ifEmpty(rawValue, defaultValue) {
|
|
27
|
+
if (this.isEmpty(rawValue)) {
|
|
28
|
+
return defaultValue;
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
return rawValue;
|
|
32
|
+
},
|
|
33
|
+
isUndefined: function isUndefined(value) {
|
|
34
|
+
return value === void 0;
|
|
35
|
+
},
|
|
36
|
+
isNull: function isNull(value) {
|
|
37
|
+
return value === null || value === void 0;
|
|
38
|
+
},
|
|
39
|
+
isNotNull: function isNotNull(value) {
|
|
40
|
+
return !this.isNull(value);
|
|
41
|
+
},
|
|
42
|
+
isEmptyArray: function isEmptyArray(value) {
|
|
43
|
+
return value === void 0 || value === null || Array.isArray(value) && value.length === 0;
|
|
44
|
+
},
|
|
45
|
+
isNotEmptyArray: function isNotEmptyArray(value) {
|
|
46
|
+
return Array.isArray(value) && value.length > 0;
|
|
47
|
+
},
|
|
48
|
+
isEmpty: function isEmpty(rawValue) {
|
|
49
|
+
if (rawValue === null || rawValue === void 0) {
|
|
50
|
+
return true;
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
if (_lodash["default"].isString(rawValue)) {
|
|
54
|
+
return this.isBlankString(rawValue);
|
|
55
|
+
} else if (this.isEmptyArray(rawValue)) {
|
|
56
|
+
return true;
|
|
57
|
+
} else if (_lodash["default"].isSet(rawValue)) {
|
|
58
|
+
return rawValue.size === 0;
|
|
59
|
+
} else if (_lodash["default"].isMap(rawValue)) {
|
|
60
|
+
return rawValue.size === 0;
|
|
61
|
+
} else if (_lodash["default"].isPlainObject(rawValue)) {
|
|
62
|
+
return _lodash["default"].isEmpty(rawValue);
|
|
63
|
+
} else if (_lodash["default"].isArrayLike(rawValue)) {
|
|
64
|
+
return rawValue.length === 0;
|
|
65
|
+
} else if (_lodash["default"].isArrayBuffer(rawValue)) {
|
|
66
|
+
return rawValue.byteLength === 0;
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
return false;
|
|
70
|
+
},
|
|
71
|
+
isNotEmpty: function isNotEmpty(rawValue) {
|
|
72
|
+
return !this.isEmpty(rawValue);
|
|
73
|
+
},
|
|
74
|
+
isBlankString: function isBlankString(value) {
|
|
75
|
+
return _Strings["default"].isBlankString(value);
|
|
76
|
+
},
|
|
77
|
+
isNotBlankString: function isNotBlankString(value) {
|
|
78
|
+
return _Strings["default"].isNotBlankString(value);
|
|
79
|
+
},
|
|
80
|
+
isPK: function isPK(value) {
|
|
81
|
+
if (value === null || value === void 0) {
|
|
82
|
+
return false;
|
|
83
|
+
}
|
|
84
|
+
|
|
85
|
+
if (_lodash["default"].isString(value)) {
|
|
86
|
+
return this.isNotBlankString(value);
|
|
87
|
+
} else if (_lodash["default"].isNumber(value)) {
|
|
88
|
+
return _lodash["default"].isInteger(value) && value > 0;
|
|
89
|
+
}
|
|
90
|
+
|
|
91
|
+
return false;
|
|
92
|
+
},
|
|
93
|
+
isDateValue: function isDateValue(value) {
|
|
94
|
+
if (value === null || value === void 0) {
|
|
95
|
+
return false;
|
|
96
|
+
}
|
|
97
|
+
|
|
98
|
+
if (_lodash["default"].isString(value)) {
|
|
99
|
+
var day = (0, _moment["default"])(value);
|
|
100
|
+
return day.isValid();
|
|
101
|
+
} else if (_lodash["default"].isDate(value)) {
|
|
102
|
+
return true;
|
|
103
|
+
} else if (_lodash["default"].isFunction(value.toDate) && _lodash["default"].isFunction(value.isValid)) {
|
|
104
|
+
return value.isValid();
|
|
105
|
+
} else if (_lodash["default"].isPlainObject(value) && Object.prototype.hasOwnProperty.call(value, "value")) {
|
|
106
|
+
return this.isDateValue(value.value);
|
|
107
|
+
}
|
|
108
|
+
|
|
109
|
+
return false;
|
|
110
|
+
},
|
|
111
|
+
isInteger: function isInteger(value) {
|
|
112
|
+
if (value === null || value === void 0) {
|
|
113
|
+
return false;
|
|
114
|
+
}
|
|
115
|
+
|
|
116
|
+
if (_lodash["default"].isInteger(value)) {
|
|
117
|
+
return true;
|
|
118
|
+
}
|
|
119
|
+
|
|
120
|
+
if (_lodash["default"].isString(value)) {
|
|
121
|
+
var _value = value.replaceAll(",", "").replaceAll(' ', '');
|
|
122
|
+
|
|
123
|
+
try {
|
|
124
|
+
var decimalValue = new _decimal["default"](_value);
|
|
125
|
+
return decimalValue.isInteger();
|
|
126
|
+
} catch (e) {
|
|
127
|
+
return false;
|
|
128
|
+
}
|
|
129
|
+
}
|
|
130
|
+
|
|
131
|
+
return false;
|
|
132
|
+
},
|
|
133
|
+
isInteger2: function isInteger2(value) {
|
|
134
|
+
if (value === null || value === void 0) {
|
|
135
|
+
return false;
|
|
136
|
+
}
|
|
137
|
+
|
|
138
|
+
if (_lodash["default"].isInteger(value)) {
|
|
139
|
+
return true;
|
|
140
|
+
}
|
|
141
|
+
|
|
142
|
+
if (_lodash["default"].isString(value)) {
|
|
143
|
+
try {
|
|
144
|
+
var decimalValue = new _decimal["default"](value);
|
|
145
|
+
return decimalValue.isInteger();
|
|
146
|
+
} catch (e) {
|
|
147
|
+
return false;
|
|
148
|
+
}
|
|
149
|
+
}
|
|
150
|
+
|
|
151
|
+
return false;
|
|
152
|
+
},
|
|
153
|
+
isNumber: function isNumber(value) {
|
|
154
|
+
if (value === null || value === void 0) {
|
|
155
|
+
return false;
|
|
156
|
+
}
|
|
157
|
+
|
|
158
|
+
if (isNaN(value)) {
|
|
159
|
+
return false;
|
|
160
|
+
}
|
|
161
|
+
|
|
162
|
+
if (_lodash["default"].isNumber(value)) {
|
|
163
|
+
return true;
|
|
164
|
+
}
|
|
165
|
+
|
|
166
|
+
if (_lodash["default"].isString(value)) {
|
|
167
|
+
var _value = value.replaceAll(",", "").replaceAll(' ', '');
|
|
168
|
+
|
|
169
|
+
try {
|
|
170
|
+
new _decimal["default"](_value);
|
|
171
|
+
return true;
|
|
172
|
+
} catch (e) {
|
|
173
|
+
return false;
|
|
174
|
+
}
|
|
175
|
+
}
|
|
176
|
+
|
|
177
|
+
return false;
|
|
178
|
+
}
|
|
179
|
+
};
|
|
180
|
+
var _default = Values;
|
|
181
|
+
exports["default"] = _default;
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
Object.defineProperty(exports, "convertFormValues2VOUsingVOFormat", {
|
|
7
|
+
enumerable: true,
|
|
8
|
+
get: function get() {
|
|
9
|
+
return _FormDatas.convertFormValues2VOUsingVOFormat;
|
|
10
|
+
}
|
|
11
|
+
});
|
|
12
|
+
Object.defineProperty(exports, "convertVO2FormValuesUsingFormValueFormat", {
|
|
13
|
+
enumerable: true,
|
|
14
|
+
get: function get() {
|
|
15
|
+
return _FormDatas.convertVO2FormValuesUsingFormValueFormat;
|
|
16
|
+
}
|
|
17
|
+
});
|
|
18
|
+
Object.defineProperty(exports, "Strings", {
|
|
19
|
+
enumerable: true,
|
|
20
|
+
get: function get() {
|
|
21
|
+
return _Strings["default"];
|
|
22
|
+
}
|
|
23
|
+
});
|
|
24
|
+
Object.defineProperty(exports, "Values", {
|
|
25
|
+
enumerable: true,
|
|
26
|
+
get: function get() {
|
|
27
|
+
return _Values["default"];
|
|
28
|
+
}
|
|
29
|
+
});
|
|
30
|
+
Object.defineProperty(exports, "DateTimes", {
|
|
31
|
+
enumerable: true,
|
|
32
|
+
get: function get() {
|
|
33
|
+
return _DateTimes["default"];
|
|
34
|
+
}
|
|
35
|
+
});
|
|
36
|
+
|
|
37
|
+
var _FormDatas = require("./FormDatas");
|
|
38
|
+
|
|
39
|
+
var _Strings = _interopRequireDefault(require("./Strings"));
|
|
40
|
+
|
|
41
|
+
var _Values = _interopRequireDefault(require("./Values"));
|
|
42
|
+
|
|
43
|
+
var _DateTimes = _interopRequireDefault(require("./DateTimes"));
|
|
44
|
+
|
|
45
|
+
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }
|
|
@@ -0,0 +1,486 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports["default"] = void 0;
|
|
7
|
+
|
|
8
|
+
var _lodash = _interopRequireDefault(require("lodash"));
|
|
9
|
+
|
|
10
|
+
var _queryString = _interopRequireDefault(require("query-string"));
|
|
11
|
+
|
|
12
|
+
var _utils = require("../base/utils");
|
|
13
|
+
|
|
14
|
+
var _antd = require("antd");
|
|
15
|
+
|
|
16
|
+
var _this = void 0;
|
|
17
|
+
|
|
18
|
+
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }
|
|
19
|
+
|
|
20
|
+
function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); if (enumerableOnly) symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; }); keys.push.apply(keys, symbols); } return keys; }
|
|
21
|
+
|
|
22
|
+
function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i] != null ? arguments[i] : {}; if (i % 2) { ownKeys(Object(source), true).forEach(function (key) { _defineProperty(target, key, source[key]); }); } else if (Object.getOwnPropertyDescriptors) { Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)); } else { ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } } return target; }
|
|
23
|
+
|
|
24
|
+
function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
|
|
25
|
+
|
|
26
|
+
var http = {
|
|
27
|
+
isUseDefaultExceptionHandler: function isUseDefaultExceptionHandler() {
|
|
28
|
+
return false;
|
|
29
|
+
},
|
|
30
|
+
getRequestContextPath: function getRequestContextPath(options) {
|
|
31
|
+
if (_lodash["default"].isString(options)) {
|
|
32
|
+
var requestURL = options;
|
|
33
|
+
|
|
34
|
+
if (requestURL.toLowerCase().startsWith("http")) {
|
|
35
|
+
return requestURL;
|
|
36
|
+
} else if (requestURL.startsWith(AppConfig.BackServiceRpcPrefix)) {
|
|
37
|
+
// like "/d/module_code/function_let_code/method1
|
|
38
|
+
var requestContextPathParts = requestURL.split("/");
|
|
39
|
+
|
|
40
|
+
if (requestContextPathParts.length >= 4) {
|
|
41
|
+
return requestContextPathParts.slice(0, 4).join("/");
|
|
42
|
+
} else {
|
|
43
|
+
return requestURL;
|
|
44
|
+
}
|
|
45
|
+
} else if (requestURL.startsWith("/")) {
|
|
46
|
+
return requestURL;
|
|
47
|
+
}
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
var SERVICE_HOST_NAME = AppConfig.BackServiceHostAddress;
|
|
51
|
+
var SERVICE_CONTEXT_PATH = AppConfig.BackServiceContextPath;
|
|
52
|
+
var BACK_SERVICE_RPC_PREFIX = AppConfig.BackServiceRpcPrefix;
|
|
53
|
+
var ajaxBasePath = null;
|
|
54
|
+
|
|
55
|
+
if (_lodash["default"].isPlainObject(options)) {
|
|
56
|
+
ajaxBasePath = options.ajaxBasePath;
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
if (_utils.Values.isBlankString(ajaxBasePath)) {
|
|
60
|
+
ajaxBasePath = this.requestContextPath;
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
if (_utils.Values.isBlankString(ajaxBasePath)) {
|
|
64
|
+
var locationHash = window.location.hash;
|
|
65
|
+
|
|
66
|
+
if (!locationHash || locationHash === "#") {
|
|
67
|
+
return null;
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
locationHash = locationHash.substring(1);
|
|
71
|
+
|
|
72
|
+
if (!locationHash) {
|
|
73
|
+
return null;
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
var _requestContextPathParts = locationHash.split('/');
|
|
77
|
+
|
|
78
|
+
if (_requestContextPathParts.length >= 3) {
|
|
79
|
+
ajaxBasePath = _requestContextPathParts.slice(0, 3).join("/");
|
|
80
|
+
} else {
|
|
81
|
+
ajaxBasePath = locationHash;
|
|
82
|
+
}
|
|
83
|
+
}
|
|
84
|
+
|
|
85
|
+
var requestContextPath = SERVICE_HOST_NAME + SERVICE_CONTEXT_PATH + BACK_SERVICE_RPC_PREFIX + ajaxBasePath;
|
|
86
|
+
|
|
87
|
+
if (!requestContextPath.endsWith("/")) {
|
|
88
|
+
requestContextPath = requestContextPath + "/";
|
|
89
|
+
}
|
|
90
|
+
|
|
91
|
+
return requestContextPath;
|
|
92
|
+
},
|
|
93
|
+
getRequestPath: function getRequestPath(options) {
|
|
94
|
+
var rpcMethodName = null;
|
|
95
|
+
var ajaxOptions = {};
|
|
96
|
+
|
|
97
|
+
if (_lodash["default"].isPlainObject(options)) {
|
|
98
|
+
rpcMethodName = options.rpcMethodName;
|
|
99
|
+
ajaxOptions = _objectSpread({}, options);
|
|
100
|
+
} else if (_lodash["default"].isString(options)) {
|
|
101
|
+
var requestURL = options;
|
|
102
|
+
|
|
103
|
+
if (requestURL.toLowerCase().startsWith("http")) {
|
|
104
|
+
return requestURL;
|
|
105
|
+
} else if (requestURL.toLowerCase().startsWith("/")) {
|
|
106
|
+
return requestURL;
|
|
107
|
+
} else {
|
|
108
|
+
rpcMethodName = options;
|
|
109
|
+
}
|
|
110
|
+
} else {
|
|
111
|
+
throw new Error("Invalid arguments value [" + options + "] for http#getRequestPath");
|
|
112
|
+
}
|
|
113
|
+
|
|
114
|
+
if (!rpcMethodName) {
|
|
115
|
+
rpcMethodName = "";
|
|
116
|
+
}
|
|
117
|
+
|
|
118
|
+
if (ajaxOptions.url) {
|
|
119
|
+
return ajaxOptions.url;
|
|
120
|
+
} else {
|
|
121
|
+
var requestContextPath = this.getRequestContextPath(options);
|
|
122
|
+
return requestContextPath + rpcMethodName;
|
|
123
|
+
}
|
|
124
|
+
},
|
|
125
|
+
getFunctionLetUIPathFromLocationString: function getFunctionLetUIPathFromLocationString(locationString) {
|
|
126
|
+
if (locationString == null || locationString === "") {
|
|
127
|
+
return null;
|
|
128
|
+
}
|
|
129
|
+
|
|
130
|
+
var index1 = locationString.indexOf("#");
|
|
131
|
+
|
|
132
|
+
if (index1 === -1) {
|
|
133
|
+
return null;
|
|
134
|
+
}
|
|
135
|
+
|
|
136
|
+
var locationHash = locationString.substring(index1);
|
|
137
|
+
var index2 = locationHash.indexOf("?");
|
|
138
|
+
|
|
139
|
+
if (index2 === -1) {
|
|
140
|
+
return locationHash;
|
|
141
|
+
}
|
|
142
|
+
|
|
143
|
+
return locationHash.substring(0, index2);
|
|
144
|
+
},
|
|
145
|
+
getFunctionLetUIContextPathFromLocationString: function getFunctionLetUIContextPathFromLocationString(locationString) {
|
|
146
|
+
var functionLetUIPath = this.getFunctionLetUIPathFromLocationString(locationString);
|
|
147
|
+
|
|
148
|
+
if (functionLetUIPath == null) {
|
|
149
|
+
return null;
|
|
150
|
+
}
|
|
151
|
+
|
|
152
|
+
if (functionLetUIPath.endsWith("/")) {
|
|
153
|
+
return functionLetUIPath;
|
|
154
|
+
}
|
|
155
|
+
|
|
156
|
+
var index1 = functionLetUIPath.lastIndexOf("/");
|
|
157
|
+
|
|
158
|
+
if (index1 == -1) {
|
|
159
|
+
return functionLetUIPath;
|
|
160
|
+
}
|
|
161
|
+
|
|
162
|
+
return functionLetUIPath.substring(0, index1 + 1);
|
|
163
|
+
},
|
|
164
|
+
getViewNameFromLocationHash: function getViewNameFromLocationHash() {
|
|
165
|
+
var currentHash = window.location.hash;
|
|
166
|
+
|
|
167
|
+
if (!currentHash) {
|
|
168
|
+
return null;
|
|
169
|
+
}
|
|
170
|
+
|
|
171
|
+
var pureHashLocation = currentHash;
|
|
172
|
+
var p1 = pureHashLocation.indexOf("?");
|
|
173
|
+
|
|
174
|
+
if (p1 > 0) {
|
|
175
|
+
pureHashLocation = pureHashLocation.substring(0, p1);
|
|
176
|
+
}
|
|
177
|
+
|
|
178
|
+
if (pureHashLocation.endsWith("/")) {
|
|
179
|
+
return null;
|
|
180
|
+
}
|
|
181
|
+
|
|
182
|
+
var p2 = pureHashLocation.lastIndexOf("/");
|
|
183
|
+
|
|
184
|
+
if (p2 > 0) {
|
|
185
|
+
return pureHashLocation.substring(p2 + 1);
|
|
186
|
+
} else {
|
|
187
|
+
return pureHashLocation.substring(1);
|
|
188
|
+
}
|
|
189
|
+
},
|
|
190
|
+
getParameterValue: function getParameterValue(paramName) {
|
|
191
|
+
if (!paramName) {
|
|
192
|
+
return null;
|
|
193
|
+
}
|
|
194
|
+
|
|
195
|
+
var hash = window.location.hash;
|
|
196
|
+
|
|
197
|
+
if (!hash) {
|
|
198
|
+
return null;
|
|
199
|
+
}
|
|
200
|
+
|
|
201
|
+
var index = hash.indexOf("?");
|
|
202
|
+
|
|
203
|
+
if (index < 0) {
|
|
204
|
+
return null;
|
|
205
|
+
}
|
|
206
|
+
|
|
207
|
+
var search = hash.substring(index + 1);
|
|
208
|
+
|
|
209
|
+
var paramObject = _queryString["default"].parse(search);
|
|
210
|
+
|
|
211
|
+
if (!paramObject) {
|
|
212
|
+
return null;
|
|
213
|
+
}
|
|
214
|
+
|
|
215
|
+
return paramObject[paramName];
|
|
216
|
+
},
|
|
217
|
+
getParameterObject: function getParameterObject() {
|
|
218
|
+
var hash = window.location.hash;
|
|
219
|
+
|
|
220
|
+
if (!hash) {
|
|
221
|
+
return null;
|
|
222
|
+
}
|
|
223
|
+
|
|
224
|
+
var index = hash.indexOf("?");
|
|
225
|
+
|
|
226
|
+
if (index < 0) {
|
|
227
|
+
return null;
|
|
228
|
+
}
|
|
229
|
+
|
|
230
|
+
var search = hash.substring(index + 1);
|
|
231
|
+
|
|
232
|
+
var paramObject = _queryString["default"].parse(search);
|
|
233
|
+
|
|
234
|
+
for (var _len = arguments.length, paramNames = new Array(_len), _key = 0; _key < _len; _key++) {
|
|
235
|
+
paramNames[_key] = arguments[_key];
|
|
236
|
+
}
|
|
237
|
+
|
|
238
|
+
if (!Array.isArray(paramNames)) {
|
|
239
|
+
return paramObject;
|
|
240
|
+
}
|
|
241
|
+
|
|
242
|
+
var _paramObject = {};
|
|
243
|
+
|
|
244
|
+
for (var i = 0, len = paramNames.length; i < len; i++) {
|
|
245
|
+
var param = paramNames[i];
|
|
246
|
+
_paramObject[param] = paramObject[param];
|
|
247
|
+
}
|
|
248
|
+
|
|
249
|
+
return _paramObject;
|
|
250
|
+
},
|
|
251
|
+
encodeObject2ParameterString2: function encodeObject2ParameterString2(object) {
|
|
252
|
+
if (!_lodash["default"].isPlainObject(object)) {
|
|
253
|
+
return "";
|
|
254
|
+
}
|
|
255
|
+
|
|
256
|
+
return "?" + _queryString["default"].stringify(object);
|
|
257
|
+
},
|
|
258
|
+
encodeObject2ParameterString: function encodeObject2ParameterString(object) {
|
|
259
|
+
if (!_lodash["default"].isPlainObject(object)) {
|
|
260
|
+
return "";
|
|
261
|
+
}
|
|
262
|
+
|
|
263
|
+
return _queryString["default"].stringify(object);
|
|
264
|
+
},
|
|
265
|
+
redirectToFunctionLet: function redirectToFunctionLet(functionLetRouterPath, parameterObject) {
|
|
266
|
+
this.redirectTo("#" + functionLetRouterPath, parameterObject);
|
|
267
|
+
},
|
|
268
|
+
redirectTo: function redirectTo(targetLocation, parameterObject) {
|
|
269
|
+
if (targetLocation === null || targetLocation === void 0) {
|
|
270
|
+
return;
|
|
271
|
+
}
|
|
272
|
+
|
|
273
|
+
if (_utils.Values.isBlankString(targetLocation)) {
|
|
274
|
+
return;
|
|
275
|
+
}
|
|
276
|
+
|
|
277
|
+
var location = targetLocation;
|
|
278
|
+
|
|
279
|
+
if (_lodash["default"].isPlainObject(parameterObject)) {
|
|
280
|
+
location = location + this.encodeObject2ParameterString2(parameterObject);
|
|
281
|
+
}
|
|
282
|
+
|
|
283
|
+
var lowerCaseLocation = location.toLowerCase();
|
|
284
|
+
|
|
285
|
+
if (lowerCaseLocation.startsWith("http://") || lowerCaseLocation.startsWith("https://") || lowerCaseLocation.startsWith("/")) {
|
|
286
|
+
window.location = location;
|
|
287
|
+
}
|
|
288
|
+
|
|
289
|
+
if (location.startsWith("#")) {
|
|
290
|
+
window.location.hash = location;
|
|
291
|
+
} else if (location.startsWith("./")) {
|
|
292
|
+
var currentHash = window.location.hash;
|
|
293
|
+
|
|
294
|
+
if (!currentHash) {
|
|
295
|
+
window.location = location;
|
|
296
|
+
} else if (currentHash === "#/") {
|
|
297
|
+
window.location.hash = "#" + location.substring(1);
|
|
298
|
+
} else {
|
|
299
|
+
var pureHashLocation = currentHash;
|
|
300
|
+
var p1 = pureHashLocation.indexOf("?");
|
|
301
|
+
|
|
302
|
+
if (p1 > 0) {
|
|
303
|
+
pureHashLocation = pureHashLocation.substring(0, p1);
|
|
304
|
+
}
|
|
305
|
+
|
|
306
|
+
var p2 = pureHashLocation.lastIndexOf("/");
|
|
307
|
+
|
|
308
|
+
if (p2 > 0) {
|
|
309
|
+
window.location.hash = pureHashLocation.substring(0, p2 + 1) + location.substring(2);
|
|
310
|
+
} else {
|
|
311
|
+
window.location.hash = "#" + location.substring(1);
|
|
312
|
+
}
|
|
313
|
+
}
|
|
314
|
+
} else if (location.indexOf("../") >= 0) {
|
|
315
|
+
var _currentHash = window.location.hash;
|
|
316
|
+
|
|
317
|
+
if (!_currentHash) {
|
|
318
|
+
window.location = location;
|
|
319
|
+
} else {
|
|
320
|
+
_antd.message.error("Not support the location pattern:" + location);
|
|
321
|
+
}
|
|
322
|
+
} else {
|
|
323
|
+
var _currentHash2 = window.location.hash;
|
|
324
|
+
|
|
325
|
+
if (!_currentHash2) {
|
|
326
|
+
window.location = location;
|
|
327
|
+
} else {
|
|
328
|
+
var _pureHashLocation = _currentHash2;
|
|
329
|
+
|
|
330
|
+
var _p = _pureHashLocation.indexOf("?");
|
|
331
|
+
|
|
332
|
+
if (_p > 0) {
|
|
333
|
+
_pureHashLocation = _pureHashLocation.substring(0, _p);
|
|
334
|
+
}
|
|
335
|
+
|
|
336
|
+
var _p2 = _pureHashLocation.lastIndexOf("/");
|
|
337
|
+
|
|
338
|
+
if (_p2 > 0) {
|
|
339
|
+
window.location.hash = _pureHashLocation.substring(0, _p2 + 1) + location;
|
|
340
|
+
} else {
|
|
341
|
+
window.location.hash = "#/" + location;
|
|
342
|
+
}
|
|
343
|
+
}
|
|
344
|
+
}
|
|
345
|
+
},
|
|
346
|
+
goBack: function goBack() {
|
|
347
|
+
var currentHash = window.location.hash;
|
|
348
|
+
|
|
349
|
+
if (currentHash == null || currentHash.length == 0 || currentHash == "#/" || currentHash == "#") {
|
|
350
|
+
window.history.go(-1);
|
|
351
|
+
return;
|
|
352
|
+
}
|
|
353
|
+
|
|
354
|
+
var pureHashLocation = currentHash;
|
|
355
|
+
var p1 = pureHashLocation.indexOf("?");
|
|
356
|
+
|
|
357
|
+
if (p1 > 0) {
|
|
358
|
+
pureHashLocation = pureHashLocation.substring(0, p1);
|
|
359
|
+
}
|
|
360
|
+
|
|
361
|
+
var p2 = pureHashLocation.lastIndexOf("/");
|
|
362
|
+
var hash = "";
|
|
363
|
+
|
|
364
|
+
if (p2 > 0) {
|
|
365
|
+
window.location.hash = pureHashLocation.substring(0, p2 + 1);
|
|
366
|
+
return;
|
|
367
|
+
} else {
|
|
368
|
+
window.history.go(-1);
|
|
369
|
+
return;
|
|
370
|
+
}
|
|
371
|
+
},
|
|
372
|
+
getFullURL: function getFullURL(targetLocation, parameterObject) {
|
|
373
|
+
if (targetLocation === null || targetLocation === void 0) {
|
|
374
|
+
return null;
|
|
375
|
+
}
|
|
376
|
+
|
|
377
|
+
if (_utils.Values.isBlankString(targetLocation)) {
|
|
378
|
+
return null;
|
|
379
|
+
}
|
|
380
|
+
|
|
381
|
+
var location = targetLocation;
|
|
382
|
+
|
|
383
|
+
if (_lodash["default"].isPlainObject(parameterObject)) {
|
|
384
|
+
location = location + this.encodeObject2ParameterString2(parameterObject);
|
|
385
|
+
}
|
|
386
|
+
|
|
387
|
+
var lowerCaseLocation = location.toLowerCase();
|
|
388
|
+
|
|
389
|
+
if (lowerCaseLocation.startsWith("http://") || lowerCaseLocation.startsWith("https://") || lowerCaseLocation.startsWith("/")) {
|
|
390
|
+
return location;
|
|
391
|
+
}
|
|
392
|
+
|
|
393
|
+
if (location.startsWith("#")) {
|
|
394
|
+
return window.location.origin + window.location.pathname + location;
|
|
395
|
+
} else if (location.startsWith("./")) {
|
|
396
|
+
var currentHash = window.location.hash;
|
|
397
|
+
|
|
398
|
+
if (_utils.Values.isBlankString(currentHash)) {
|
|
399
|
+
var currentPathname = window.location.pathname;
|
|
400
|
+
var idx = currentHash.lastIndexOf("/");
|
|
401
|
+
|
|
402
|
+
if (idx >= 0) {
|
|
403
|
+
return window.location.origin + currentPathname.substring(0, idx + 1) + location.substring(2);
|
|
404
|
+
} else {
|
|
405
|
+
return window.location.origin + location.substring(1);
|
|
406
|
+
}
|
|
407
|
+
} else if (currentHash === "#/") {
|
|
408
|
+
return window.location.origin + window.location.pathname + "#" + location.substring(1);
|
|
409
|
+
} else {
|
|
410
|
+
var pureHashLocation = currentHash;
|
|
411
|
+
var p1 = pureHashLocation.indexOf("?");
|
|
412
|
+
|
|
413
|
+
if (p1 > 0) {
|
|
414
|
+
pureHashLocation = pureHashLocation.substring(0, p1);
|
|
415
|
+
}
|
|
416
|
+
|
|
417
|
+
var p2 = pureHashLocation.lastIndexOf("/");
|
|
418
|
+
var hash = "";
|
|
419
|
+
|
|
420
|
+
if (p2 > 0) {
|
|
421
|
+
hash = pureHashLocation.substring(0, p2 + 1) + location.substring(2);
|
|
422
|
+
} else {
|
|
423
|
+
hash = "#" + location.substring(1);
|
|
424
|
+
}
|
|
425
|
+
|
|
426
|
+
return window.location.origin + window.location.pathname + hash;
|
|
427
|
+
}
|
|
428
|
+
} else {
|
|
429
|
+
var _currentHash3 = window.location.hash;
|
|
430
|
+
|
|
431
|
+
if (_utils.Values.isBlankString(_currentHash3)) {
|
|
432
|
+
var _currentPathname = window.location.pathname;
|
|
433
|
+
|
|
434
|
+
var _idx = _currentHash3.lastIndexOf("/");
|
|
435
|
+
|
|
436
|
+
if (_idx >= 0) {
|
|
437
|
+
return window.location.origin + _currentPathname.substring(0, _idx + 1) + location;
|
|
438
|
+
} else {
|
|
439
|
+
return window.location.origin + "/" + location;
|
|
440
|
+
}
|
|
441
|
+
} else {
|
|
442
|
+
var _pureHashLocation2 = _currentHash3;
|
|
443
|
+
|
|
444
|
+
var _p3 = _pureHashLocation2.indexOf("?");
|
|
445
|
+
|
|
446
|
+
if (_p3 > 0) {
|
|
447
|
+
_pureHashLocation2 = _pureHashLocation2.substring(0, _p3);
|
|
448
|
+
}
|
|
449
|
+
|
|
450
|
+
var _p4 = _pureHashLocation2.lastIndexOf("/");
|
|
451
|
+
|
|
452
|
+
var _hash = "";
|
|
453
|
+
|
|
454
|
+
if (_p4 > 0) {
|
|
455
|
+
_hash = _pureHashLocation2.substring(0, _p4 + 1) + location;
|
|
456
|
+
} else {
|
|
457
|
+
_hash = "#/" + location;
|
|
458
|
+
}
|
|
459
|
+
|
|
460
|
+
return window.location.origin + window.location.pathname + _hash;
|
|
461
|
+
}
|
|
462
|
+
}
|
|
463
|
+
},
|
|
464
|
+
isInView: function isInView(viewName) {
|
|
465
|
+
if (!_lodash["default"].isString(viewName)) {
|
|
466
|
+
return false;
|
|
467
|
+
}
|
|
468
|
+
|
|
469
|
+
var currentView = this.getViewNameFromLocationHash();
|
|
470
|
+
|
|
471
|
+
if (!currentView) {
|
|
472
|
+
return false;
|
|
473
|
+
}
|
|
474
|
+
|
|
475
|
+
return viewName.toLowerCase() === currentView.toLowerCase();
|
|
476
|
+
},
|
|
477
|
+
switchMainView: function switchMainView(parameterObject) {
|
|
478
|
+
if (_this.isInView("main_view")) {
|
|
479
|
+
_this.redirectTo("main_view2", parameterObject);
|
|
480
|
+
} else if (_this.isInView("main_view2")) {
|
|
481
|
+
_this.redirectTo("main_view", parameterObject);
|
|
482
|
+
}
|
|
483
|
+
}
|
|
484
|
+
};
|
|
485
|
+
var _default = http;
|
|
486
|
+
exports["default"] = _default;
|