@bchr/bchr-front-lib 0.5.1-alpha-20241221 → 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/utils/Strings.js +1 -3
- package/lib/services/http.js +0 -616
- package/package.json +1 -1
- package/src/base/utils/Strings.js +1 -2
- package/src/services/http.js +1 -616
- package/lib/base/utils/AppKits.js +0 -96
- package/src/base/utils/AppKits.js +0 -62
|
@@ -1,96 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
Object.defineProperty(exports, "__esModule", {
|
|
4
|
-
value: true
|
|
5
|
-
});
|
|
6
|
-
exports.isNeedForceRedirect = exports.forceRedirectToForLogout = exports.forceRedirectToForError = void 0;
|
|
7
|
-
|
|
8
|
-
var _lodash = _interopRequireDefault(require("lodash"));
|
|
9
|
-
|
|
10
|
-
var _config = require("../../config");
|
|
11
|
-
|
|
12
|
-
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }
|
|
13
|
-
|
|
14
|
-
function _createForOfIteratorHelper(o, allowArrayLike) { var it; if (typeof Symbol === "undefined" || o[Symbol.iterator] == null) { if (Array.isArray(o) || (it = _unsupportedIterableToArray(o)) || allowArrayLike && o && typeof o.length === "number") { if (it) o = it; var i = 0; var F = function F() {}; return { s: F, n: function n() { if (i >= o.length) return { done: true }; return { done: false, value: o[i++] }; }, e: function e(_e) { throw _e; }, f: F }; } throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); } var normalCompletion = true, didErr = false, err; return { s: function s() { it = o[Symbol.iterator](); }, n: function n() { var step = it.next(); normalCompletion = step.done; return step; }, e: function e(_e2) { didErr = true; err = _e2; }, f: function f() { try { if (!normalCompletion && it["return"] != null) it["return"](); } finally { if (didErr) throw err; } } }; }
|
|
15
|
-
|
|
16
|
-
function _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o === "string") return _arrayLikeToArray(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === "Object" && o.constructor) n = o.constructor.name; if (n === "Map" || n === "Set") return Array.from(o); if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); }
|
|
17
|
-
|
|
18
|
-
function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) { arr2[i] = arr[i]; } return arr2; }
|
|
19
|
-
|
|
20
|
-
var forceRedirectToForError = function forceRedirectToForError(targetURL) {
|
|
21
|
-
var forceRedirectURL = _config.AppConfig.FrontPathForForceRedirect;
|
|
22
|
-
|
|
23
|
-
if (targetURL !== null && targetURL !== void 0 && _lodash["default"].isString(targetURL)) {
|
|
24
|
-
forceRedirectURL = targetURL;
|
|
25
|
-
}
|
|
26
|
-
|
|
27
|
-
var lowerCaseForceRedirectURL = forceRedirectURL.toLowerCase();
|
|
28
|
-
|
|
29
|
-
if (lowerCaseForceRedirectURL.startsWith("http://") || lowerCaseForceRedirectURL.startsWith("https://")) {
|
|
30
|
-
window.top.location = lowerCaseForceRedirectURL;
|
|
31
|
-
return;
|
|
32
|
-
}
|
|
33
|
-
|
|
34
|
-
if (forceRedirectURL.startsWith("#")) {
|
|
35
|
-
window.top.location = window.location.origin + window.location.pathname + forceRedirectURL;
|
|
36
|
-
return;
|
|
37
|
-
} else if (forceRedirectURL.startsWith("/")) {
|
|
38
|
-
window.top.location = window.location.origin + forceRedirectURL;
|
|
39
|
-
return;
|
|
40
|
-
} else {
|
|
41
|
-
window.top.location = window.location.origin + "/" + forceRedirectURL;
|
|
42
|
-
return;
|
|
43
|
-
}
|
|
44
|
-
};
|
|
45
|
-
|
|
46
|
-
exports.forceRedirectToForError = forceRedirectToForError;
|
|
47
|
-
|
|
48
|
-
var forceRedirectToForLogout = function forceRedirectToForLogout() {
|
|
49
|
-
forceRedirectToForError(_config.AppConfig.FrontPathForForceRedirect);
|
|
50
|
-
};
|
|
51
|
-
|
|
52
|
-
exports.forceRedirectToForLogout = forceRedirectToForLogout;
|
|
53
|
-
|
|
54
|
-
var isNeedForceRedirect = function isNeedForceRedirect() {
|
|
55
|
-
if (!Array.isArray(_config.AppConfig.FrontPathArrayNoNeedForceRedirect)) {
|
|
56
|
-
return true;
|
|
57
|
-
}
|
|
58
|
-
|
|
59
|
-
if (_config.AppConfig.FrontPathArrayNoNeedForceRedirect.length === 0) {
|
|
60
|
-
return true;
|
|
61
|
-
}
|
|
62
|
-
|
|
63
|
-
var currentPagePath = window.location.pathname;
|
|
64
|
-
|
|
65
|
-
if (window.location.hash) {
|
|
66
|
-
var pageHash = window.location.hash;
|
|
67
|
-
var idx = pageHash.indexOf("?");
|
|
68
|
-
|
|
69
|
-
if (idx > 0) {
|
|
70
|
-
currentPagePath = currentPagePath + pageHash.substring(0, idx);
|
|
71
|
-
} else {
|
|
72
|
-
currentPagePath = currentPagePath + pageHash;
|
|
73
|
-
}
|
|
74
|
-
}
|
|
75
|
-
|
|
76
|
-
var _iterator = _createForOfIteratorHelper(_config.AppConfig.FrontPathArrayNoNeedForceRedirect),
|
|
77
|
-
_step;
|
|
78
|
-
|
|
79
|
-
try {
|
|
80
|
-
for (_iterator.s(); !(_step = _iterator.n()).done;) {
|
|
81
|
-
var pathStr = _step.value;
|
|
82
|
-
|
|
83
|
-
if (currentPagePath === pathStr) {
|
|
84
|
-
return false;
|
|
85
|
-
}
|
|
86
|
-
}
|
|
87
|
-
} catch (err) {
|
|
88
|
-
_iterator.e(err);
|
|
89
|
-
} finally {
|
|
90
|
-
_iterator.f();
|
|
91
|
-
}
|
|
92
|
-
|
|
93
|
-
return true;
|
|
94
|
-
};
|
|
95
|
-
|
|
96
|
-
exports.isNeedForceRedirect = isNeedForceRedirect;
|
|
@@ -1,62 +0,0 @@
|
|
|
1
|
-
import lodash from "lodash";
|
|
2
|
-
import {AppConfig} from "../../config";
|
|
3
|
-
|
|
4
|
-
export const forceRedirectToForError = function (targetURL) {
|
|
5
|
-
let forceRedirectURL = AppConfig.FrontPathForForceRedirect;
|
|
6
|
-
if (targetURL !== null && targetURL !== void 0 && lodash.isString(targetURL)) {
|
|
7
|
-
forceRedirectURL = targetURL;
|
|
8
|
-
}
|
|
9
|
-
|
|
10
|
-
let lowerCaseForceRedirectURL = forceRedirectURL.toLowerCase();
|
|
11
|
-
if (lowerCaseForceRedirectURL.startsWith("http://") || lowerCaseForceRedirectURL.startsWith("https://")) {
|
|
12
|
-
window.top.location = lowerCaseForceRedirectURL;
|
|
13
|
-
return;
|
|
14
|
-
}
|
|
15
|
-
|
|
16
|
-
if (forceRedirectURL.startsWith("#")) {
|
|
17
|
-
window.top.location = window.location.origin + window.location.pathname + forceRedirectURL;
|
|
18
|
-
return;
|
|
19
|
-
}
|
|
20
|
-
else if (forceRedirectURL.startsWith("/")) {
|
|
21
|
-
window.top.location = window.location.origin + forceRedirectURL;
|
|
22
|
-
return;
|
|
23
|
-
}
|
|
24
|
-
else {
|
|
25
|
-
window.top.location = window.location.origin + "/" + forceRedirectURL;
|
|
26
|
-
return;
|
|
27
|
-
}
|
|
28
|
-
}
|
|
29
|
-
|
|
30
|
-
export const forceRedirectToForLogout = function () {
|
|
31
|
-
forceRedirectToForError(AppConfig.FrontPathForForceRedirect);
|
|
32
|
-
}
|
|
33
|
-
|
|
34
|
-
export const isNeedForceRedirect = function() {
|
|
35
|
-
if (!Array.isArray(AppConfig.FrontPathArrayNoNeedForceRedirect)) {
|
|
36
|
-
return true;
|
|
37
|
-
}
|
|
38
|
-
|
|
39
|
-
if (AppConfig.FrontPathArrayNoNeedForceRedirect.length === 0) {
|
|
40
|
-
return true;
|
|
41
|
-
}
|
|
42
|
-
|
|
43
|
-
let currentPagePath = window.location.pathname;
|
|
44
|
-
if (window.location.hash) {
|
|
45
|
-
let pageHash = window.location.hash;
|
|
46
|
-
let idx = pageHash.indexOf("?");
|
|
47
|
-
if (idx > 0) {
|
|
48
|
-
currentPagePath = currentPagePath + pageHash.substring(0, idx);
|
|
49
|
-
}
|
|
50
|
-
else {
|
|
51
|
-
currentPagePath = currentPagePath + pageHash;
|
|
52
|
-
}
|
|
53
|
-
}
|
|
54
|
-
|
|
55
|
-
for (let pathStr of AppConfig.FrontPathArrayNoNeedForceRedirect) {
|
|
56
|
-
if (currentPagePath === pathStr) {
|
|
57
|
-
return false;
|
|
58
|
-
}
|
|
59
|
-
}
|
|
60
|
-
|
|
61
|
-
return true;
|
|
62
|
-
}
|