@ibiz-template/core 0.0.1-alpha.3 → 0.0.1-alpha.32

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 (74) hide show
  1. package/dist/system/index.system.js +1 -0
  2. package/out/constant/http-status-message/http-status-message.d.ts +5 -0
  3. package/out/constant/http-status-message/http-status-message.d.ts.map +1 -0
  4. package/out/constant/http-status-message/http-status-message.js +20 -0
  5. package/out/constant/index.d.ts +3 -0
  6. package/out/constant/index.d.ts.map +1 -1
  7. package/out/constant/index.js +3 -0
  8. package/out/constant/login-mode/login-mode.d.ts +23 -0
  9. package/out/constant/login-mode/login-mode.d.ts.map +1 -0
  10. package/out/constant/login-mode/login-mode.js +24 -0
  11. package/out/constant/menu-permission-mode/menu-permission-mode.d.ts +23 -0
  12. package/out/constant/menu-permission-mode/menu-permission-mode.d.ts.map +1 -0
  13. package/out/constant/menu-permission-mode/menu-permission-mode.js +24 -0
  14. package/out/context/index.d.ts +2 -39
  15. package/out/context/index.d.ts.map +1 -1
  16. package/out/context/index.js +34 -65
  17. package/out/environment/environment.d.ts.map +1 -1
  18. package/out/environment/environment.js +9 -1
  19. package/out/error/http-error/http-error.d.ts +18 -0
  20. package/out/error/http-error/http-error.d.ts.map +1 -0
  21. package/out/error/http-error/http-error.js +36 -0
  22. package/out/error/index.d.ts +3 -0
  23. package/out/error/index.d.ts.map +1 -0
  24. package/out/error/index.js +2 -0
  25. package/out/error/runtime-error/runtime-error.d.ts +15 -0
  26. package/out/error/runtime-error/runtime-error.d.ts.map +1 -0
  27. package/out/error/runtime-error/runtime-error.js +15 -0
  28. package/out/factory-center.d.ts +11 -0
  29. package/out/factory-center.d.ts.map +1 -0
  30. package/out/factory-center.js +10 -0
  31. package/out/index.d.ts +3 -1
  32. package/out/index.d.ts.map +1 -1
  33. package/out/index.js +3 -1
  34. package/out/install.d.ts.map +1 -1
  35. package/out/install.js +2 -0
  36. package/out/interface/i-environment/i-environment.d.ts +59 -0
  37. package/out/interface/i-environment/i-environment.d.ts.map +1 -1
  38. package/out/types.d.ts +20 -0
  39. package/out/types.d.ts.map +1 -1
  40. package/out/utils/index.d.ts +1 -0
  41. package/out/utils/index.d.ts.map +1 -1
  42. package/out/utils/index.js +1 -0
  43. package/out/utils/net/http-response.d.ts +4 -9
  44. package/out/utils/net/http-response.d.ts.map +1 -1
  45. package/out/utils/net/http-response.js +0 -7
  46. package/out/utils/net/net.d.ts +18 -11
  47. package/out/utils/net/net.d.ts.map +1 -1
  48. package/out/utils/net/net.js +57 -24
  49. package/out/utils/url-helper/url-helper.d.ts +51 -0
  50. package/out/utils/url-helper/url-helper.d.ts.map +1 -0
  51. package/out/utils/url-helper/url-helper.js +59 -0
  52. package/out/utils/util/util.d.ts +29 -0
  53. package/out/utils/util/util.d.ts.map +1 -1
  54. package/out/utils/util/util.js +50 -0
  55. package/package.json +19 -7
  56. package/src/constant/http-status-message/http-status-message.ts +20 -0
  57. package/src/constant/index.ts +3 -0
  58. package/src/constant/login-mode/login-mode.ts +23 -0
  59. package/src/constant/menu-permission-mode/menu-permission-mode.ts +23 -0
  60. package/src/context/index.ts +35 -69
  61. package/src/environment/environment.ts +9 -1
  62. package/src/error/http-error/http-error.ts +43 -0
  63. package/src/error/index.ts +2 -0
  64. package/src/error/runtime-error/runtime-error.ts +14 -0
  65. package/src/factory-center.ts +9 -0
  66. package/src/index.ts +3 -1
  67. package/src/install.ts +2 -0
  68. package/src/interface/i-environment/i-environment.ts +67 -0
  69. package/src/types.ts +21 -0
  70. package/src/utils/index.ts +1 -0
  71. package/src/utils/net/http-response.ts +6 -9
  72. package/src/utils/net/net.ts +66 -33
  73. package/src/utils/url-helper/url-helper.ts +62 -0
  74. package/src/utils/util/util.ts +64 -0
@@ -0,0 +1,62 @@
1
+ /**
2
+ * 路径解析助手
3
+ *
4
+ * @author lxm
5
+ * @date 2022-10-11 14:10:12
6
+ * @export
7
+ * @class UrlHelper
8
+ */
9
+ export class UrlHelper {
10
+ /**
11
+ * 路由路径前面的基础路径
12
+ * 如:http://172.16.103.120:30061/portalwebapp/#/index/appportalview?params=123
13
+ * 返回:http://172.16.103.120:30061/portalwebapp/#
14
+ *
15
+ * @author lxm
16
+ * @date 2022-10-11 20:10:29
17
+ * @returns {*}
18
+ */
19
+ static get routeBase() {
20
+ return `${this.appBase}/#`;
21
+ }
22
+
23
+ /**
24
+ * 应用的的基础路径
25
+ * 如:http://172.16.103.120:30061/portalwebapp/#/index/appportalview?params=123
26
+ * 返回:http://172.16.103.120:30061/portalwebapp
27
+ *
28
+ * @author lxm
29
+ * @date 2022-10-11 20:10:29
30
+ * @returns {*}
31
+ */
32
+ static get appBase() {
33
+ const { origin, pathname } = window.location;
34
+ return `${origin}${pathname}`.replace(/\/$/, '');
35
+ }
36
+
37
+ /**
38
+ * #开始到末尾,即路由地址
39
+ * 如:http://172.16.103.120:30061/portalwebapp/#/index/appportalview?params=123
40
+ * 返回:/index/appportalview?params=123
41
+ *
42
+ * @author lxm
43
+ * @date 2022-10-11 16:10:40
44
+ * @returns {*}
45
+ */
46
+ static get routePath() {
47
+ return window.location.hash.replace('#', '');
48
+ }
49
+
50
+ /**
51
+ * 当前地址的全路径,包含域名和参数
52
+ * 如:http://172.16.103.120:30061/portalwebapp/#/index/appportalview?params=123
53
+ *
54
+ * @author lxm
55
+ * @date 2022-10-11 21:10:39
56
+ * @readonly
57
+ * @static
58
+ */
59
+ static get fullPath() {
60
+ return window.location.href;
61
+ }
62
+ }
@@ -1,3 +1,5 @@
1
+ /* eslint-disable @typescript-eslint/no-explicit-any */
2
+ import { debounce, DebounceSettings } from 'lodash-es';
1
3
  import { getCookie } from 'qx-util';
2
4
  import { CoreConst } from '../../constant';
3
5
 
@@ -12,3 +14,65 @@ import { CoreConst } from '../../constant';
12
14
  export function getToken(): string | null {
13
15
  return getCookie(CoreConst.TOKEN);
14
16
  }
17
+
18
+ /**
19
+ * 判断两个数组是否有相同的元素
20
+ *
21
+ * @author lxm
22
+ * @date 2022-09-20 19:09:29
23
+ * @export
24
+ * @param {any[]} arr1
25
+ * @param {any[]} arr2
26
+ * @returns {*} {boolean}
27
+ */
28
+ export function isOverlap(arr1: any[], arr2: any[]): boolean {
29
+ const newArr = Array.from(new Set([...arr1, ...arr2]));
30
+ return newArr.length !== arr1.length + arr2.length;
31
+ }
32
+
33
+ /**
34
+ * 防抖并合并每次的参数
35
+ *
36
+ * @author lxm
37
+ * @date 2022-09-20 21:09:53
38
+ * @export
39
+ * @template T
40
+ * @param {T} func 要防抖的函数
41
+ * @param {(
42
+ * oldParams: Parameters<T>,
43
+ * newParams: Parameters<T>,
44
+ * ) => Parameters<T>} mergeFunc 合并的回调函数
45
+ * @param {number} [wait] 防抖的延迟毫秒数
46
+ * @param {DebounceSettings} [options] 防抖函数的额外参数
47
+ * @returns {*}
48
+ */
49
+ export function debounceAndMerge<T extends (...args: any[]) => any>(
50
+ func: T,
51
+ mergeFunc: (
52
+ oldParams: Parameters<T>,
53
+ newParams: Parameters<T>,
54
+ ) => Parameters<T>,
55
+ wait?: number,
56
+ options?: DebounceSettings,
57
+ ) {
58
+ // 缓存上一次的函数参数
59
+ let oldParams: Parameters<T> | undefined;
60
+ const debounceFunc = debounce(
61
+ (...params: Parameters<T>) => {
62
+ // 防抖函数执行的时候清空缓存参数
63
+ oldParams = undefined;
64
+ return func(...params);
65
+ },
66
+ wait,
67
+ options,
68
+ );
69
+ return (...args: Parameters<T>) => {
70
+ // 合并参数,并把参数缓存到oldParams里,用新参数调用防抖函数
71
+ let newParams = args;
72
+ if (oldParams) {
73
+ newParams = mergeFunc(oldParams, newParams);
74
+ }
75
+ oldParams = newParams;
76
+ return debounceFunc(...newParams);
77
+ };
78
+ }