@ibiz-template/core 0.0.1-alpha.16 → 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.
@@ -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,YAQzB,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
  */
@@ -9,4 +10,7 @@ export const Environment = {
9
10
  ExportFile: '/ibizutil/download',
10
11
  UploadFile: '/ibizutil/upload',
11
12
  casLoginUrl: '',
13
+ loginMode: LoginMode.DEFAULT,
14
+ menuPermissionMode: MenuPermissionMode.MIXIN,
15
+ enablePermission: true,
12
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,14 @@ 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;
26
35
  /**
27
36
  * 中央认证登录地址
28
37
  *
@@ -71,5 +80,21 @@ export interface IEnvironment {
71
80
  * @type {string}
72
81
  */
73
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;
74
99
  }
75
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,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;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"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ibiz-template/core",
3
- "version": "0.0.1-alpha.16",
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": "6e22ada91af231ce1add4b411418226b2ff85d3b"
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
  /**
@@ -11,4 +12,7 @@ export const Environment: IEnvironment = {
11
12
  ExportFile: '/ibizutil/download',
12
13
  UploadFile: '/ibizutil/upload',
13
14
  casLoginUrl: '',
15
+ loginMode: LoginMode.DEFAULT,
16
+ menuPermissionMode: MenuPermissionMode.MIXIN,
17
+ enablePermission: true,
14
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,15 @@ 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
+
28
39
  /**
29
40
  * 中央认证登录地址
30
41
  *
@@ -78,4 +89,22 @@ export interface IEnvironment {
78
89
  * @type {string}
79
90
  */
80
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;
81
110
  }