@ibiz-template/core 0.0.1-alpha.13 → 0.0.1-alpha.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.
Files changed (38) hide show
  1. package/out/constant/index.d.ts +2 -0
  2. package/out/constant/index.d.ts.map +1 -1
  3. package/out/constant/index.js +2 -0
  4. package/out/constant/login-mode/login-mode.d.ts +23 -0
  5. package/out/constant/login-mode/login-mode.d.ts.map +1 -0
  6. package/out/constant/login-mode/login-mode.js +24 -0
  7. package/out/constant/menu-permission-mode/menu-permission-mode.d.ts +23 -0
  8. package/out/constant/menu-permission-mode/menu-permission-mode.d.ts.map +1 -0
  9. package/out/constant/menu-permission-mode/menu-permission-mode.js +24 -0
  10. package/out/context/index.d.ts +1 -46
  11. package/out/context/index.d.ts.map +1 -1
  12. package/out/context/index.js +33 -80
  13. package/out/environment/environment.d.ts.map +1 -1
  14. package/out/environment/environment.js +5 -0
  15. package/out/index.d.ts +1 -1
  16. package/out/index.d.ts.map +1 -1
  17. package/out/index.js +1 -1
  18. package/out/interface/i-environment/i-environment.d.ts +33 -0
  19. package/out/interface/i-environment/i-environment.d.ts.map +1 -1
  20. package/out/utils/index.d.ts +1 -0
  21. package/out/utils/index.d.ts.map +1 -1
  22. package/out/utils/index.js +1 -0
  23. package/out/utils/net/http-response.d.ts +1 -1
  24. package/out/utils/net/http-response.d.ts.map +1 -1
  25. package/out/utils/url-helper/url-helper.d.ts +51 -0
  26. package/out/utils/url-helper/url-helper.d.ts.map +1 -0
  27. package/out/utils/url-helper/url-helper.js +59 -0
  28. package/package.json +2 -2
  29. package/src/constant/index.ts +2 -0
  30. package/src/constant/login-mode/login-mode.ts +23 -0
  31. package/src/constant/menu-permission-mode/menu-permission-mode.ts +23 -0
  32. package/src/context/index.ts +34 -87
  33. package/src/environment/environment.ts +5 -0
  34. package/src/index.ts +1 -1
  35. package/src/interface/i-environment/i-environment.ts +38 -0
  36. package/src/utils/index.ts +1 -0
  37. package/src/utils/net/http-response.ts +1 -1
  38. package/src/utils/url-helper/url-helper.ts +62 -0
@@ -1,3 +1,5 @@
1
1
  export { CoreConst } from './core/core';
2
2
  export { HttpStatusMessageConst } from './http-status-message/http-status-message';
3
+ export { LoginMode } from './login-mode/login-mode';
4
+ export { MenuPermissionMode } from './menu-permission-mode/menu-permission-mode';
3
5
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/constant/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,aAAa,CAAC;AACxC,OAAO,EAAE,sBAAsB,EAAE,MAAM,2CAA2C,CAAC"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/constant/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,aAAa,CAAC;AACxC,OAAO,EAAE,sBAAsB,EAAE,MAAM,2CAA2C,CAAC;AACnF,OAAO,EAAE,SAAS,EAAE,MAAM,yBAAyB,CAAC;AACpD,OAAO,EAAE,kBAAkB,EAAE,MAAM,6CAA6C,CAAC"}
@@ -1,2 +1,4 @@
1
1
  export { CoreConst } from './core/core';
2
2
  export { HttpStatusMessageConst } from './http-status-message/http-status-message';
3
+ export { LoginMode } from './login-mode/login-mode';
4
+ export { MenuPermissionMode } from './menu-permission-mode/menu-permission-mode';
@@ -0,0 +1,23 @@
1
+ /**
2
+ * 登录模式
3
+ *
4
+ * @author lxm
5
+ * @date 2022-10-12 14:10:56
6
+ * @export
7
+ * @enum {number}
8
+ */
9
+ export declare enum LoginMode {
10
+ /**
11
+ * 默认标准登录
12
+ */
13
+ DEFAULT = "DEFAULT",
14
+ /**
15
+ * 自定义登录
16
+ */
17
+ CUSTOM = "CUSTOM",
18
+ /**
19
+ * 中央认证登录
20
+ */
21
+ CAS = "CAS"
22
+ }
23
+ //# sourceMappingURL=login-mode.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"login-mode.d.ts","sourceRoot":"","sources":["../../../src/constant/login-mode/login-mode.ts"],"names":[],"mappings":"AACA;;;;;;;GAOG;AACH,oBAAY,SAAS;IACnB;;OAEG;IACH,OAAO,YAAY;IACnB;;OAEG;IACH,MAAM,WAAW;IACjB;;OAEG;IACH,GAAG,QAAQ;CACZ"}
@@ -0,0 +1,24 @@
1
+ /* eslint-disable no-shadow */
2
+ /**
3
+ * 登录模式
4
+ *
5
+ * @author lxm
6
+ * @date 2022-10-12 14:10:56
7
+ * @export
8
+ * @enum {number}
9
+ */
10
+ export var LoginMode;
11
+ (function (LoginMode) {
12
+ /**
13
+ * 默认标准登录
14
+ */
15
+ LoginMode["DEFAULT"] = "DEFAULT";
16
+ /**
17
+ * 自定义登录
18
+ */
19
+ LoginMode["CUSTOM"] = "CUSTOM";
20
+ /**
21
+ * 中央认证登录
22
+ */
23
+ LoginMode["CAS"] = "CAS";
24
+ })(LoginMode || (LoginMode = {}));
@@ -0,0 +1,23 @@
1
+ /**
2
+ * 菜单权限校验模式
3
+ *
4
+ * @author lxm
5
+ * @date 2022-10-12 14:10:56
6
+ * @export
7
+ * @enum {number}
8
+ */
9
+ export declare enum MenuPermissionMode {
10
+ /**
11
+ * 混合模式(默认)
12
+ */
13
+ MIXIN = "MIXIN",
14
+ /**
15
+ * 统一资源模式
16
+ */
17
+ RESOURCE = "RESOURCE",
18
+ /**
19
+ * RT模式
20
+ */
21
+ RT = "RT"
22
+ }
23
+ //# sourceMappingURL=menu-permission-mode.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"menu-permission-mode.d.ts","sourceRoot":"","sources":["../../../src/constant/menu-permission-mode/menu-permission-mode.ts"],"names":[],"mappings":"AACA;;;;;;;GAOG;AACH,oBAAY,kBAAkB;IAC5B;;OAEG;IACH,KAAK,UAAU;IACf;;OAEG;IACH,QAAQ,aAAa;IACrB;;OAEG;IACH,EAAE,OAAO;CACV"}
@@ -0,0 +1,24 @@
1
+ /* eslint-disable no-shadow */
2
+ /**
3
+ * 菜单权限校验模式
4
+ *
5
+ * @author lxm
6
+ * @date 2022-10-12 14:10:56
7
+ * @export
8
+ * @enum {number}
9
+ */
10
+ export var MenuPermissionMode;
11
+ (function (MenuPermissionMode) {
12
+ /**
13
+ * 混合模式(默认)
14
+ */
15
+ MenuPermissionMode["MIXIN"] = "MIXIN";
16
+ /**
17
+ * 统一资源模式
18
+ */
19
+ MenuPermissionMode["RESOURCE"] = "RESOURCE";
20
+ /**
21
+ * RT模式
22
+ */
23
+ MenuPermissionMode["RT"] = "RT";
24
+ })(MenuPermissionMode || (MenuPermissionMode = {}));
@@ -1,15 +1,3 @@
1
- /**
2
- * 上下文代理处理
3
- *
4
- * @author chitanda
5
- * @date 2022-07-14 10:07:45
6
- * @class IBizContextProxyHandle
7
- * @implements {ProxyHandler<IBizContext>}
8
- */
9
- export declare class IBizContextProxyHandle implements ProxyHandler<IBizContext> {
10
- set(target: IBizContext, p: string | symbol, value: unknown): boolean;
11
- get(target: IBizContext, p: string | symbol, _receiver: unknown): unknown;
12
- }
13
1
  /**
14
2
  * 上下文处理类
15
3
  *
@@ -19,17 +7,8 @@ export declare class IBizContextProxyHandle implements ProxyHandler<IBizContext>
19
7
  * @class IBizContext
20
8
  */
21
9
  export declare class IBizContext implements IContext {
22
- context: IContext;
23
10
  [key: string | symbol]: any;
24
- /**
25
- * 父上下文
26
- *
27
- * @author chitanda
28
- * @date 2022-07-14 10:07:06
29
- * @protected
30
- * @type {(IBizContext | null)}
31
- */
32
- protected _parent: IContext | null;
11
+ protected _context: IContext;
33
12
  /**
34
13
  * Creates an instance of IBizContext.
35
14
  *
@@ -39,29 +18,5 @@ export declare class IBizContext implements IContext {
39
18
  * @param {IBizContext} [parent]
40
19
  */
41
20
  constructor(context?: IContext, parent?: IBizContext);
42
- /**
43
- * 创建代理
44
- *
45
- * @author chitanda
46
- * @date 2022-07-14 11:07:37
47
- * @protected
48
- * @return {*} {IBizContext}
49
- */
50
- protected createProxy(): IBizContext;
51
- /**
52
- * 获取所有上下文参数,无多层级默认合并
53
- *
54
- * @author chitanda
55
- * @date 2022-09-28 14:09:20
56
- * @return {*} {IContext}
57
- */
58
- getContext(): IContext;
59
- /**
60
- * 销毁上下文,避免内存泄漏
61
- *
62
- * @author chitanda
63
- * @date 2022-07-14 11:07:45
64
- */
65
- destroy(): void;
66
21
  }
67
22
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/context/index.ts"],"names":[],"mappings":"AAOA;;;;;;;GAOG;AACH,qBAAa,sBAAuB,YAAW,YAAY,CAAC,WAAW,CAAC;IACtE,GAAG,CAAC,MAAM,EAAE,WAAW,EAAE,CAAC,EAAE,MAAM,GAAG,MAAM,EAAE,KAAK,EAAE,OAAO,GAAG,OAAO;IAKrE,GAAG,CAAC,MAAM,EAAE,WAAW,EAAE,CAAC,EAAE,MAAM,GAAG,MAAM,EAAE,SAAS,EAAE,OAAO,GAAG,OAAO;CAa1E;AAED;;;;;;;GAOG;AACH,qBAAa,WAAY,YAAW,QAAQ;IAsBvB,OAAO,EAAE,QAAQ;IApBpC,CAAC,GAAG,EAAE,MAAM,GAAG,MAAM,GAAG,GAAG,CAAC;IAE5B;;;;;;;OAOG;IACH,SAAS,CAAC,OAAO,EAAE,QAAQ,GAAG,IAAI,CAAQ;IAE1C;;;;;;;OAOG;gBACgB,OAAO,GAAE,QAAa,EAAE,MAAM,CAAC,EAAE,WAAW;IAO/D;;;;;;;OAOG;IACH,SAAS,CAAC,WAAW,IAAI,WAAW;IAIpC;;;;;;OAMG;IACH,UAAU,IAAI,QAAQ;IAStB;;;;;OAKG;IACH,OAAO,IAAI,IAAI;CAIhB"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/context/index.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AACH,qBAAa,WAAY,YAAW,QAAQ;IAE1C,CAAC,GAAG,EAAE,MAAM,GAAG,MAAM,GAAG,GAAG,CAAC;IAE5B,SAAS,CAAC,QAAQ,EAAG,QAAQ,CAAC;IAE9B;;;;;;;OAOG;gBAES,OAAO,GAAE,QAAa,EAAE,MAAM,CAAC,EAAE,WAAW;CAmCzD"}
@@ -1,35 +1,3 @@
1
- /* eslint-disable no-param-reassign */
2
- /* eslint-disable no-constructor-return */
3
- /* eslint-disable no-underscore-dangle */
4
- /* eslint-disable max-classes-per-file */
5
- import { clone } from 'lodash-es';
6
- /**
7
- * 上下文代理处理
8
- *
9
- * @author chitanda
10
- * @date 2022-07-14 10:07:45
11
- * @class IBizContextProxyHandle
12
- * @implements {ProxyHandler<IBizContext>}
13
- */
14
- export class IBizContextProxyHandle {
15
- set(target, p, value) {
16
- target.context[p] = value;
17
- return true;
18
- }
19
- get(target, p, _receiver) {
20
- if (target[p] !== undefined) {
21
- return target[p];
22
- }
23
- if (target.context[p] !== undefined) {
24
- return target.context[p];
25
- }
26
- // eslint-disable-next-line @typescript-eslint/no-explicit-any
27
- if (target._parent && target._parent[p] !== undefined) {
28
- // eslint-disable-next-line @typescript-eslint/no-explicit-any
29
- return target._parent[p];
30
- }
31
- }
32
- }
33
1
  /**
34
2
  * 上下文处理类
35
3
  *
@@ -47,56 +15,41 @@ export class IBizContext {
47
15
  * @param {IContext} [context={}] 自身的上下文
48
16
  * @param {IBizContext} [parent]
49
17
  */
18
+ // eslint-disable-next-line default-param-last
50
19
  constructor(context = {}, parent) {
51
- this.context = context;
52
- /**
53
- * 父上下文
54
- *
55
- * @author chitanda
56
- * @date 2022-07-14 10:07:06
57
- * @protected
58
- * @type {(IBizContext | null)}
59
- */
60
- this._parent = null;
61
20
  if (parent) {
62
- this._parent = parent;
63
- }
64
- return this.createProxy();
65
- }
66
- /**
67
- * 创建代理
68
- *
69
- * @author chitanda
70
- * @date 2022-07-14 11:07:37
71
- * @protected
72
- * @return {*} {IBizContext}
73
- */
74
- createProxy() {
75
- return new Proxy(this, new IBizContextProxyHandle());
76
- }
77
- /**
78
- * 获取所有上下文参数,无多层级默认合并
79
- *
80
- * @author chitanda
81
- * @date 2022-09-28 14:09:20
82
- * @return {*} {IContext}
83
- */
84
- getContext() {
85
- if (this.parent) {
86
- const ctx = this.parent.getContext();
87
- Object.assign(ctx, clone(this.context));
88
- return ctx;
21
+ // eslint-disable-next-line @typescript-eslint/no-this-alias
22
+ const self = this;
23
+ // 定义私有变量,用于存储父已有上下文,方便覆盖
24
+ Object.defineProperty(this, '_context', {
25
+ enumerable: false,
26
+ value: {},
27
+ });
28
+ // 监控父上下文参数,自身不存在时从父取
29
+ const properties = {};
30
+ const keys = Object.keys(parent);
31
+ keys.forEach(key => {
32
+ properties[key] = {
33
+ enumerable: true,
34
+ set(val) {
35
+ if (val == null) {
36
+ self._context[key] = null;
37
+ }
38
+ else {
39
+ self._context[key] = val;
40
+ }
41
+ },
42
+ get() {
43
+ if (self._context[key] !== undefined) {
44
+ return self._context[key];
45
+ }
46
+ return parent[key];
47
+ },
48
+ };
49
+ });
50
+ Object.defineProperties(this, properties);
89
51
  }
90
- return clone(this.context);
91
- }
92
- /**
93
- * 销毁上下文,避免内存泄漏
94
- *
95
- * @author chitanda
96
- * @date 2022-07-14 11:07:45
97
- */
98
- destroy() {
99
- this.context = {};
100
- this._parent = null;
52
+ // 合并给入上下文
53
+ Object.assign(this, context);
101
54
  }
102
55
  }
@@ -1 +1 @@
1
- {"version":3,"file":"environment.d.ts","sourceRoot":"","sources":["../../src/environment/environment.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,MAAM,cAAc,CAAC;AAE5C;;GAEG;AACH,eAAO,MAAM,WAAW,EAAE,YAOzB,CAAC"}
1
+ {"version":3,"file":"environment.d.ts","sourceRoot":"","sources":["../../src/environment/environment.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,YAAY,EAAE,MAAM,cAAc,CAAC;AAE5C;;GAEG;AACH,eAAO,MAAM,WAAW,EAAE,YAWzB,CAAC"}
@@ -1,3 +1,4 @@
1
+ import { LoginMode, MenuPermissionMode } from '../constant';
1
2
  /**
2
3
  * 环境变量
3
4
  */
@@ -8,4 +9,8 @@ export const Environment = {
8
9
  dcSystem: '',
9
10
  ExportFile: '/ibizutil/download',
10
11
  UploadFile: '/ibizutil/upload',
12
+ casLoginUrl: '',
13
+ loginMode: LoginMode.DEFAULT,
14
+ menuPermissionMode: MenuPermissionMode.MIXIN,
15
+ enablePermission: true,
11
16
  };
package/out/index.d.ts CHANGED
@@ -1,6 +1,6 @@
1
1
  import './types';
2
2
  export * from './constant';
3
- export { IBizContext, IBizContextProxyHandle } from './context';
3
+ export { IBizContext } from './context';
4
4
  export { Environment } from './environment/environment';
5
5
  export * from './error';
6
6
  export * from './interface';
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,SAAS,CAAC;AAEjB,cAAc,YAAY,CAAC;AAC3B,OAAO,EAAE,WAAW,EAAE,sBAAsB,EAAE,MAAM,WAAW,CAAC;AAChE,OAAO,EAAE,WAAW,EAAE,MAAM,2BAA2B,CAAC;AACxD,cAAc,SAAS,CAAC;AACxB,cAAc,aAAa,CAAC;AAC5B,cAAc,SAAS,CAAC;AACxB,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AACpC,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,SAAS,CAAC;AAEjB,cAAc,YAAY,CAAC;AAC3B,OAAO,EAAE,WAAW,EAAE,MAAM,WAAW,CAAC;AACxC,OAAO,EAAE,WAAW,EAAE,MAAM,2BAA2B,CAAC;AACxD,cAAc,SAAS,CAAC;AACxB,cAAc,aAAa,CAAC;AAC5B,cAAc,SAAS,CAAC;AACxB,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AACpC,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC"}
package/out/index.js CHANGED
@@ -1,6 +1,6 @@
1
1
  import './types';
2
2
  export * from './constant';
3
- export { IBizContext, IBizContextProxyHandle } from './context';
3
+ export { IBizContext } from './context';
4
4
  export { Environment } from './environment/environment';
5
5
  export * from './error';
6
6
  export * from './interface';
@@ -1,3 +1,4 @@
1
+ import { LoginMode, MenuPermissionMode } from '../../constant';
1
2
  /**
2
3
  * 配置参数
3
4
  *
@@ -23,6 +24,22 @@ export interface IEnvironment {
23
24
  * @type {string}
24
25
  */
25
26
  baseUrl: string;
27
+ /**
28
+ * 登录模式
29
+ *
30
+ * @author lxm
31
+ * @date 2022-10-12 14:10:51
32
+ * @type {LoginMode}
33
+ */
34
+ loginMode: LoginMode;
35
+ /**
36
+ * 中央认证登录地址
37
+ *
38
+ * @author lxm
39
+ * @date 2022-10-11 12:10:21
40
+ * @type {string}
41
+ */
42
+ casLoginUrl: string;
26
43
  /**
27
44
  * 远程模型路径
28
45
  *
@@ -63,5 +80,21 @@ export interface IEnvironment {
63
80
  * @type {string}
64
81
  */
65
82
  UploadFile: string;
83
+ /**
84
+ * 是否启用权限校验(默认true)
85
+ *
86
+ * @author lxm
87
+ * @date 2022-10-12 18:10:25
88
+ * @type {boolean}
89
+ */
90
+ enablePermission: boolean;
91
+ /**
92
+ * 菜单权限校验模式(默认MIXIN)
93
+ *
94
+ * @author lxm
95
+ * @date 2022-10-12 18:10:27
96
+ * @type {MenuPermissionMode}
97
+ */
98
+ menuPermissionMode: MenuPermissionMode;
66
99
  }
67
100
  //# sourceMappingURL=i-environment.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"i-environment.d.ts","sourceRoot":"","sources":["../../../src/interface/i-environment/i-environment.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AACH,MAAM,WAAW,YAAY;IAC3B;;;;;;OAMG;IACH,SAAS,CAAC,EAAE,MAAM,CAAC;IAEnB;;;;;;OAMG;IACH,OAAO,EAAE,MAAM,CAAC;IAEhB;;;;;;OAMG;IACH,cAAc,EAAE,MAAM,CAAC;IAEvB;;;;;;OAMG;IACH,SAAS,EAAE,MAAM,CAAC;IAElB;;;;;;OAMG;IACH,QAAQ,EAAE,MAAM,CAAC;IAEjB;;;;;;OAMG;IACH,UAAU,EAAE,MAAM,CAAC;IAEnB;;;;;;OAMG;IACH,UAAU,EAAE,MAAM,CAAC;CACpB"}
1
+ {"version":3,"file":"i-environment.d.ts","sourceRoot":"","sources":["../../../src/interface/i-environment/i-environment.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,kBAAkB,EAAE,MAAM,gBAAgB,CAAC;AAE/D;;;;;;;GAOG;AACH,MAAM,WAAW,YAAY;IAC3B;;;;;;OAMG;IACH,SAAS,CAAC,EAAE,MAAM,CAAC;IAEnB;;;;;;OAMG;IACH,OAAO,EAAE,MAAM,CAAC;IAEhB;;;;;;OAMG;IACH,SAAS,EAAE,SAAS,CAAC;IAErB;;;;;;OAMG;IACH,WAAW,EAAE,MAAM,CAAC;IAEpB;;;;;;OAMG;IACH,cAAc,EAAE,MAAM,CAAC;IAEvB;;;;;;OAMG;IACH,SAAS,EAAE,MAAM,CAAC;IAElB;;;;;;OAMG;IACH,QAAQ,EAAE,MAAM,CAAC;IAEjB;;;;;;OAMG;IACH,UAAU,EAAE,MAAM,CAAC;IAEnB;;;;;;OAMG;IACH,UAAU,EAAE,MAAM,CAAC;IAEnB;;;;;;OAMG;IACH,gBAAgB,EAAE,OAAO,CAAC;IAE1B;;;;;;OAMG;IACH,kBAAkB,EAAE,kBAAkB,CAAC;CACxC"}
@@ -4,4 +4,5 @@ export { IHttpResponse, HttpResponse } from './net/http-response';
4
4
  export { Net } from './net/net';
5
5
  export { plural, pluralLower } from './plural/plural';
6
6
  export * from './util/util';
7
+ export * from './url-helper/url-helper';
7
8
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/utils/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,MAAM,2BAA2B,CAAC;AACxD,OAAO,EAAE,SAAS,EAAE,MAAM,uBAAuB,CAAC;AAClD,OAAO,EAAE,aAAa,EAAE,YAAY,EAAE,MAAM,qBAAqB,CAAC;AAClE,OAAO,EAAE,GAAG,EAAE,MAAM,WAAW,CAAC;AAChC,OAAO,EAAE,MAAM,EAAE,WAAW,EAAE,MAAM,iBAAiB,CAAC;AACtD,cAAc,aAAa,CAAC"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/utils/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,MAAM,2BAA2B,CAAC;AACxD,OAAO,EAAE,SAAS,EAAE,MAAM,uBAAuB,CAAC;AAClD,OAAO,EAAE,aAAa,EAAE,YAAY,EAAE,MAAM,qBAAqB,CAAC;AAClE,OAAO,EAAE,GAAG,EAAE,MAAM,WAAW,CAAC;AAChC,OAAO,EAAE,MAAM,EAAE,WAAW,EAAE,MAAM,iBAAiB,CAAC;AACtD,cAAc,aAAa,CAAC;AAC5B,cAAc,yBAAyB,CAAC"}
@@ -4,3 +4,4 @@ export { HttpResponse } from './net/http-response';
4
4
  export { Net } from './net/net';
5
5
  export { plural, pluralLower } from './plural/plural';
6
6
  export * from './util/util';
7
+ export * from './url-helper/url-helper';
@@ -27,7 +27,7 @@ export interface IHttpResponse<T = IData> extends AxiosResponse {
27
27
  * @date 2022-08-18 15:08:44
28
28
  * @type {boolean}
29
29
  */
30
- local?: boolean;
30
+ local: boolean;
31
31
  data: T;
32
32
  /**
33
33
  * 当前页
@@ -1 +1 @@
1
- {"version":3,"file":"http-response.d.ts","sourceRoot":"","sources":["../../../src/utils/net/http-response.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,kBAAkB,EAAE,aAAa,EAAE,oBAAoB,EAAE,MAAM,OAAO,CAAC;AAEhF;;;;;;;;;GASG;AACH,MAAM,WAAW,aAAa,CAAC,CAAC,GAAG,KAAK,CAAE,SAAQ,aAAa;IAC7D;;;;;;;OAOG;IACH,EAAE,EAAE,OAAO,CAAC;IACZ;;;;;;;OAOG;IACH,KAAK,CAAC,EAAE,OAAO,CAAC;IAEhB,IAAI,EAAE,CAAC,CAAC;IAER;;OAEG;IACH,IAAI,CAAC,EAAE,MAAM,CAAC;IAEd;;OAEG;IACH,IAAI,CAAC,EAAE,MAAM,CAAC;IAEd;;OAEG;IACH,KAAK,CAAC,EAAE,MAAM,CAAC;CAChB;AAED;;;;;;;;;GASG;AACH,qBAAa,YAAY,CAAC,CAAC,GAAG,KAAK,CAAE,YAAW,aAAa,CAAC,CAAC,CAAC;IAC9D;;;;;OAKG;IACH,KAAK,UAAQ;IAEb,EAAE,UAAS;IAEX,IAAI,EAAE,CAAC,CAAC;IAER,MAAM,EAAE,MAAM,CAAC;IAEf,UAAU,EAAE,MAAM,CAAC;IAEnB;;;;;;OAMG;IACH,OAAO,EAAE,oBAAoB,CAAM;IAEnC;;;;;;OAMG;IACH,MAAM,EAAE,kBAAkB,CAAC,KAAK,CAAC,CAAM;IAEvC;;;;;;;;OAQG;gBACS,IAAI,CAAC,EAAE,OAAO,EAAE,MAAM,CAAC,EAAE,MAAM,EAAE,UAAU,CAAC,EAAE,MAAM;CAQjE"}
1
+ {"version":3,"file":"http-response.d.ts","sourceRoot":"","sources":["../../../src/utils/net/http-response.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,kBAAkB,EAAE,aAAa,EAAE,oBAAoB,EAAE,MAAM,OAAO,CAAC;AAEhF;;;;;;;;;GASG;AACH,MAAM,WAAW,aAAa,CAAC,CAAC,GAAG,KAAK,CAAE,SAAQ,aAAa;IAC7D;;;;;;;OAOG;IACH,EAAE,EAAE,OAAO,CAAC;IACZ;;;;;;;OAOG;IACH,KAAK,EAAE,OAAO,CAAC;IAEf,IAAI,EAAE,CAAC,CAAC;IAER;;OAEG;IACH,IAAI,CAAC,EAAE,MAAM,CAAC;IAEd;;OAEG;IACH,IAAI,CAAC,EAAE,MAAM,CAAC;IAEd;;OAEG;IACH,KAAK,CAAC,EAAE,MAAM,CAAC;CAChB;AAED;;;;;;;;;GASG;AACH,qBAAa,YAAY,CAAC,CAAC,GAAG,KAAK,CAAE,YAAW,aAAa,CAAC,CAAC,CAAC;IAC9D;;;;;OAKG;IACH,KAAK,UAAQ;IAEb,EAAE,UAAS;IAEX,IAAI,EAAE,CAAC,CAAC;IAER,MAAM,EAAE,MAAM,CAAC;IAEf,UAAU,EAAE,MAAM,CAAC;IAEnB;;;;;;OAMG;IACH,OAAO,EAAE,oBAAoB,CAAM;IAEnC;;;;;;OAMG;IACH,MAAM,EAAE,kBAAkB,CAAC,KAAK,CAAC,CAAM;IAEvC;;;;;;;;OAQG;gBACS,IAAI,CAAC,EAAE,OAAO,EAAE,MAAM,CAAC,EAAE,MAAM,EAAE,UAAU,CAAC,EAAE,MAAM;CAQjE"}
@@ -0,0 +1,51 @@
1
+ /**
2
+ * 路径解析助手
3
+ *
4
+ * @author lxm
5
+ * @date 2022-10-11 14:10:12
6
+ * @export
7
+ * @class UrlHelper
8
+ */
9
+ export declare 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(): string;
20
+ /**
21
+ * 应用的的基础路径
22
+ * 如:http://172.16.103.120:30061/portalwebapp/#/index/appportalview?params=123
23
+ * 返回:http://172.16.103.120:30061/portalwebapp
24
+ *
25
+ * @author lxm
26
+ * @date 2022-10-11 20:10:29
27
+ * @returns {*}
28
+ */
29
+ static get appBase(): string;
30
+ /**
31
+ * #开始到末尾,即路由地址
32
+ * 如:http://172.16.103.120:30061/portalwebapp/#/index/appportalview?params=123
33
+ * 返回:/index/appportalview?params=123
34
+ *
35
+ * @author lxm
36
+ * @date 2022-10-11 16:10:40
37
+ * @returns {*}
38
+ */
39
+ static get routePath(): string;
40
+ /**
41
+ * 当前地址的全路径,包含域名和参数
42
+ * 如:http://172.16.103.120:30061/portalwebapp/#/index/appportalview?params=123
43
+ *
44
+ * @author lxm
45
+ * @date 2022-10-11 21:10:39
46
+ * @readonly
47
+ * @static
48
+ */
49
+ static get fullPath(): string;
50
+ }
51
+ //# sourceMappingURL=url-helper.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"url-helper.d.ts","sourceRoot":"","sources":["../../../src/utils/url-helper/url-helper.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AACH,qBAAa,SAAS;IACpB;;;;;;;;OAQG;IACH,MAAM,KAAK,SAAS,WAEnB;IAED;;;;;;;;OAQG;IACH,MAAM,KAAK,OAAO,WAGjB;IAED;;;;;;;;OAQG;IACH,MAAM,KAAK,SAAS,WAEnB;IAED;;;;;;;;OAQG;IACH,MAAM,KAAK,QAAQ,WAElB;CACF"}
@@ -0,0 +1,59 @@
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
+ * 如:http://172.16.103.120:30061/portalwebapp/#/index/appportalview?params=123
25
+ * 返回:http://172.16.103.120:30061/portalwebapp
26
+ *
27
+ * @author lxm
28
+ * @date 2022-10-11 20:10:29
29
+ * @returns {*}
30
+ */
31
+ static get appBase() {
32
+ const { origin, pathname } = window.location;
33
+ return `${origin}${pathname}`.replace(/\/$/, '');
34
+ }
35
+ /**
36
+ * #开始到末尾,即路由地址
37
+ * 如:http://172.16.103.120:30061/portalwebapp/#/index/appportalview?params=123
38
+ * 返回:/index/appportalview?params=123
39
+ *
40
+ * @author lxm
41
+ * @date 2022-10-11 16:10:40
42
+ * @returns {*}
43
+ */
44
+ static get routePath() {
45
+ return window.location.hash.replace('#', '');
46
+ }
47
+ /**
48
+ * 当前地址的全路径,包含域名和参数
49
+ * 如:http://172.16.103.120:30061/portalwebapp/#/index/appportalview?params=123
50
+ *
51
+ * @author lxm
52
+ * @date 2022-10-11 21:10:39
53
+ * @readonly
54
+ * @static
55
+ */
56
+ static get fullPath() {
57
+ return window.location.href;
58
+ }
59
+ }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ibiz-template/core",
3
- "version": "0.0.1-alpha.13",
3
+ "version": "0.0.1-alpha.17",
4
4
  "description": "核心包",
5
5
  "main": "out/index.js",
6
6
  "types": "out/index.d.ts",
@@ -39,5 +39,5 @@
39
39
  "lodash-es": "^4.17.21",
40
40
  "qx-util": "^0.4.1"
41
41
  },
42
- "gitHead": "e72517e4226353804443c9a0cd7b40aaf0edf846"
42
+ "gitHead": "b66e58d737032ae8262a6a31ab6bea802260cd05"
43
43
  }
@@ -1,2 +1,4 @@
1
1
  export { CoreConst } from './core/core';
2
2
  export { HttpStatusMessageConst } from './http-status-message/http-status-message';
3
+ export { LoginMode } from './login-mode/login-mode';
4
+ export { MenuPermissionMode } from './menu-permission-mode/menu-permission-mode';
@@ -0,0 +1,23 @@
1
+ /* eslint-disable no-shadow */
2
+ /**
3
+ * 登录模式
4
+ *
5
+ * @author lxm
6
+ * @date 2022-10-12 14:10:56
7
+ * @export
8
+ * @enum {number}
9
+ */
10
+ export enum LoginMode {
11
+ /**
12
+ * 默认标准登录
13
+ */
14
+ DEFAULT = 'DEFAULT',
15
+ /**
16
+ * 自定义登录
17
+ */
18
+ CUSTOM = 'CUSTOM',
19
+ /**
20
+ * 中央认证登录
21
+ */
22
+ CAS = 'CAS',
23
+ }
@@ -0,0 +1,23 @@
1
+ /* eslint-disable no-shadow */
2
+ /**
3
+ * 菜单权限校验模式
4
+ *
5
+ * @author lxm
6
+ * @date 2022-10-12 14:10:56
7
+ * @export
8
+ * @enum {number}
9
+ */
10
+ export enum MenuPermissionMode {
11
+ /**
12
+ * 混合模式(默认)
13
+ */
14
+ MIXIN = 'MIXIN',
15
+ /**
16
+ * 统一资源模式
17
+ */
18
+ RESOURCE = 'RESOURCE',
19
+ /**
20
+ * RT模式
21
+ */
22
+ RT = 'RT',
23
+ }
@@ -1,39 +1,3 @@
1
- /* eslint-disable no-param-reassign */
2
- /* eslint-disable no-constructor-return */
3
- /* eslint-disable no-underscore-dangle */
4
- /* eslint-disable max-classes-per-file */
5
-
6
- import { clone } from 'lodash-es';
7
-
8
- /**
9
- * 上下文代理处理
10
- *
11
- * @author chitanda
12
- * @date 2022-07-14 10:07:45
13
- * @class IBizContextProxyHandle
14
- * @implements {ProxyHandler<IBizContext>}
15
- */
16
- export class IBizContextProxyHandle implements ProxyHandler<IBizContext> {
17
- set(target: IBizContext, p: string | symbol, value: unknown): boolean {
18
- target.context[p] = value;
19
- return true;
20
- }
21
-
22
- get(target: IBizContext, p: string | symbol, _receiver: unknown): unknown {
23
- if (target[p] !== undefined) {
24
- return target[p];
25
- }
26
- if (target.context[p] !== undefined) {
27
- return target.context[p];
28
- }
29
- // eslint-disable-next-line @typescript-eslint/no-explicit-any
30
- if ((target as any)._parent && (target as any)._parent[p] !== undefined) {
31
- // eslint-disable-next-line @typescript-eslint/no-explicit-any
32
- return (target as any)._parent[p];
33
- }
34
- }
35
- }
36
-
37
1
  /**
38
2
  * 上下文处理类
39
3
  *
@@ -46,15 +10,7 @@ export class IBizContext implements IContext {
46
10
  // eslint-disable-next-line @typescript-eslint/no-explicit-any
47
11
  [key: string | symbol]: any;
48
12
 
49
- /**
50
- * 父上下文
51
- *
52
- * @author chitanda
53
- * @date 2022-07-14 10:07:06
54
- * @protected
55
- * @type {(IBizContext | null)}
56
- */
57
- protected _parent: IContext | null = null;
13
+ protected _context!: IContext;
58
14
 
59
15
  /**
60
16
  * Creates an instance of IBizContext.
@@ -64,49 +20,40 @@ export class IBizContext implements IContext {
64
20
  * @param {IContext} [context={}] 自身的上下文
65
21
  * @param {IBizContext} [parent]
66
22
  */
67
- constructor(public context: IContext = {}, parent?: IBizContext) {
23
+ // eslint-disable-next-line default-param-last
24
+ constructor(context: IContext = {}, parent?: IBizContext) {
68
25
  if (parent) {
69
- this._parent = parent;
26
+ // eslint-disable-next-line @typescript-eslint/no-this-alias
27
+ const self = this;
28
+ // 定义私有变量,用于存储父已有上下文,方便覆盖
29
+ Object.defineProperty(this, '_context', {
30
+ enumerable: false,
31
+ value: {},
32
+ });
33
+ // 监控父上下文参数,自身不存在时从父取
34
+ const properties: { [key: string]: PropertyDescriptor } = {};
35
+ const keys = Object.keys(parent);
36
+ keys.forEach(key => {
37
+ properties[key] = {
38
+ enumerable: true,
39
+ set(val: unknown) {
40
+ if (val == null) {
41
+ self._context[key] = null;
42
+ } else {
43
+ self._context[key] = val;
44
+ }
45
+ },
46
+ get() {
47
+ if (self._context[key] !== undefined) {
48
+ return self._context[key];
49
+ }
50
+ return parent[key];
51
+ },
52
+ };
53
+ });
54
+ Object.defineProperties(this, properties);
70
55
  }
71
- return this.createProxy();
72
- }
73
-
74
- /**
75
- * 创建代理
76
- *
77
- * @author chitanda
78
- * @date 2022-07-14 11:07:37
79
- * @protected
80
- * @return {*} {IBizContext}
81
- */
82
- protected createProxy(): IBizContext {
83
- return new Proxy(this, new IBizContextProxyHandle());
84
- }
85
-
86
- /**
87
- * 获取所有上下文参数,无多层级默认合并
88
- *
89
- * @author chitanda
90
- * @date 2022-09-28 14:09:20
91
- * @return {*} {IContext}
92
- */
93
- getContext(): IContext {
94
- if (this.parent) {
95
- const ctx = this.parent.getContext();
96
- Object.assign(ctx, clone(this.context));
97
- return ctx;
98
- }
99
- return clone(this.context);
100
- }
101
-
102
- /**
103
- * 销毁上下文,避免内存泄漏
104
- *
105
- * @author chitanda
106
- * @date 2022-07-14 11:07:45
107
- */
108
- destroy(): void {
109
- this.context = {};
110
- this._parent = null;
56
+ // 合并给入上下文
57
+ Object.assign(this, context);
111
58
  }
112
59
  }
@@ -1,3 +1,4 @@
1
+ import { LoginMode, MenuPermissionMode } from '../constant';
1
2
  import { IEnvironment } from '../interface';
2
3
 
3
4
  /**
@@ -10,4 +11,8 @@ export const Environment: IEnvironment = {
10
11
  dcSystem: '',
11
12
  ExportFile: '/ibizutil/download',
12
13
  UploadFile: '/ibizutil/upload',
14
+ casLoginUrl: '',
15
+ loginMode: LoginMode.DEFAULT,
16
+ menuPermissionMode: MenuPermissionMode.MIXIN,
17
+ enablePermission: true,
13
18
  };
package/src/index.ts CHANGED
@@ -1,7 +1,7 @@
1
1
  import './types';
2
2
 
3
3
  export * from './constant';
4
- export { IBizContext, IBizContextProxyHandle } from './context';
4
+ export { IBizContext } from './context';
5
5
  export { Environment } from './environment/environment';
6
6
  export * from './error';
7
7
  export * from './interface';
@@ -1,3 +1,5 @@
1
+ import { LoginMode, MenuPermissionMode } from '../../constant';
2
+
1
3
  /**
2
4
  * 配置参数
3
5
  *
@@ -25,6 +27,24 @@ export interface IEnvironment {
25
27
  */
26
28
  baseUrl: string;
27
29
 
30
+ /**
31
+ * 登录模式
32
+ *
33
+ * @author lxm
34
+ * @date 2022-10-12 14:10:51
35
+ * @type {LoginMode}
36
+ */
37
+ loginMode: LoginMode;
38
+
39
+ /**
40
+ * 中央认证登录地址
41
+ *
42
+ * @author lxm
43
+ * @date 2022-10-11 12:10:21
44
+ * @type {string}
45
+ */
46
+ casLoginUrl: string;
47
+
28
48
  /**
29
49
  * 远程模型路径
30
50
  *
@@ -69,4 +89,22 @@ export interface IEnvironment {
69
89
  * @type {string}
70
90
  */
71
91
  UploadFile: string;
92
+
93
+ /**
94
+ * 是否启用权限校验(默认true)
95
+ *
96
+ * @author lxm
97
+ * @date 2022-10-12 18:10:25
98
+ * @type {boolean}
99
+ */
100
+ enablePermission: boolean;
101
+
102
+ /**
103
+ * 菜单权限校验模式(默认MIXIN)
104
+ *
105
+ * @author lxm
106
+ * @date 2022-10-12 18:10:27
107
+ * @type {MenuPermissionMode}
108
+ */
109
+ menuPermissionMode: MenuPermissionMode;
72
110
  }
@@ -4,3 +4,4 @@ export { IHttpResponse, HttpResponse } from './net/http-response';
4
4
  export { Net } from './net/net';
5
5
  export { plural, pluralLower } from './plural/plural';
6
6
  export * from './util/util';
7
+ export * from './url-helper/url-helper';
@@ -28,7 +28,7 @@ export interface IHttpResponse<T = IData> extends AxiosResponse {
28
28
  * @date 2022-08-18 15:08:44
29
29
  * @type {boolean}
30
30
  */
31
- local?: boolean;
31
+ local: boolean;
32
32
 
33
33
  data: T;
34
34
 
@@ -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
+ }