@ibiz-template/core 0.7.41-alpha.12 → 0.7.41-alpha.138
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/dist/index.esm.js +94 -23
- package/dist/index.system.min.js +1 -1
- package/out/environment/environment.d.ts.map +1 -1
- package/out/environment/environment.js +10 -0
- package/out/error/http-error/http-error-factory.d.ts +1 -1
- package/out/error/http-error/http-error-factory.d.ts.map +1 -1
- package/out/error/http-error/http-error-factory.js +11 -1
- package/out/error/http-error/http-error.d.ts +2 -2
- package/out/error/http-error/http-error.d.ts.map +1 -1
- package/out/interface/api/chat-message/i-api-chat-message.d.ts +63 -0
- package/out/interface/api/chat-message/i-api-chat-message.d.ts.map +1 -0
- package/out/interface/api/chat-message/i-api-chat-message.js +1 -0
- package/out/interface/api/chat-message/index.d.ts +2 -0
- package/out/interface/api/chat-message/index.d.ts.map +1 -0
- package/out/interface/api/chat-message/index.js +1 -0
- package/out/interface/api/environment/i-devtool-config.d.ts +29 -1
- package/out/interface/api/environment/i-devtool-config.d.ts.map +1 -1
- package/out/interface/api/environment/i-environment.d.ts +146 -1
- package/out/interface/api/environment/i-environment.d.ts.map +1 -1
- package/out/interface/api/ibizsys/i-app-data.d.ts +57 -0
- package/out/interface/api/ibizsys/i-app-data.d.ts.map +1 -0
- package/out/interface/api/ibizsys/i-app-data.js +1 -0
- package/out/interface/api/ibizsys/i-org-data.d.ts +1 -1
- package/out/interface/api/ibizsys/index.d.ts +1 -0
- package/out/interface/api/ibizsys/index.d.ts.map +1 -1
- package/out/interface/api/index.d.ts +1 -0
- package/out/interface/api/index.d.ts.map +1 -1
- package/out/interface/api/index.js +1 -0
- package/out/interface/api/utils/i-api-i18n.d.ts +9 -9
- package/out/interface/api/utils/index.d.ts +1 -0
- package/out/interface/api/utils/index.d.ts.map +1 -1
- package/out/interface/api/utils/message-center/base/i-message-base.d.ts +3 -3
- package/out/interface/api/utils/message-center/command/add-in-changed/i-command-add-in-changed.d.ts +1 -1
- package/out/interface/api/utils/message-center/command/async-action/i-command-async-action.d.ts +1 -1
- package/out/interface/api/utils/message-center/command/i-message-command.d.ts +1 -1
- package/out/interface/api/utils/message-center/command/internal-message/i-command-internal-message.d.ts +1 -1
- package/out/interface/api/utils/message-center/command/mark-open-data/i-command-mark-open-data.d.ts +1 -1
- package/out/interface/api/utils/message-center/common/i-message-center-event.d.ts +5 -0
- package/out/interface/api/utils/message-center/common/i-message-center-event.d.ts.map +1 -1
- package/out/interface/api/utils/message-center/common/i-portal-message.d.ts +3 -3
- package/out/interface/api/utils/message-center/console/i-message-console.d.ts +1 -1
- package/out/interface/api/utils/message-center/error/i-message-error.d.ts +1 -1
- package/out/interface/api/utils/message-center/i-message-center.d.ts +2 -2
- package/out/interface/api/utils/net/i-api-http-error.d.ts +39 -0
- package/out/interface/api/utils/net/i-api-http-error.d.ts.map +1 -0
- package/out/interface/api/utils/net/i-api-http-error.js +1 -0
- package/out/interface/api/utils/net/i-api-net.d.ts +1 -1
- package/out/interface/i-chat-message/i-chat-message.d.ts +2 -49
- package/out/interface/i-chat-message/i-chat-message.d.ts.map +1 -1
- package/out/utils/download-file/download-file.d.ts.map +1 -1
- package/out/utils/download-file/download-file.js +5 -1
- package/out/utils/interceptor/core-interceptor.js +2 -1
- package/out/utils/net/http-response.d.ts +2 -1
- package/out/utils/net/http-response.d.ts.map +1 -1
- package/out/utils/net/http-response.js +5 -1
- package/out/utils/net/net.d.ts +1 -1
- package/out/utils/net/net.d.ts.map +1 -1
- package/out/utils/net/net.js +16 -6
- package/out/utils/recursive/find-recursive-child.d.ts +20 -0
- package/out/utils/recursive/find-recursive-child.d.ts.map +1 -1
- package/out/utils/recursive/find-recursive-child.js +69 -7
- package/out/utils/string-util/string-util.d.ts.map +1 -1
- package/out/utils/string-util/string-util.js +2 -4
- package/package.json +5 -4
- package/src/command/command-register.ts +121 -0
- package/src/command/command.ts +78 -0
- package/src/command/index.ts +8 -0
- package/src/command/utils/index.ts +2 -0
- package/src/command/utils/linked-list.ts +136 -0
- package/src/command/utils/util.ts +103 -0
- package/src/constant/core/core.ts +54 -0
- package/src/constant/emoji/emoji.ts +2929 -0
- package/src/constant/http-status-message/http-status-message.ts +18 -0
- package/src/constant/index.ts +4 -0
- package/src/constant/util/util.ts +3 -0
- package/src/context/index.ts +231 -0
- package/src/environment/environment.ts +67 -0
- package/src/error/http-error/entity-error.ts +29 -0
- package/src/error/http-error/http-error-factory.ts +33 -0
- package/src/error/http-error/http-error.ts +52 -0
- package/src/error/index.ts +7 -0
- package/src/error/model-error/model-error.ts +27 -0
- package/src/error/notice-error/notice-error.ts +16 -0
- package/src/error/runtime-error/runtime-error.ts +13 -0
- package/src/error/runtime-model-error/runtime-model-error.ts +27 -0
- package/src/ibizsys.ts +82 -0
- package/src/index.ts +14 -0
- package/src/install.ts +12 -0
- package/src/interface/api/chat-message/i-api-chat-message.ts +71 -0
- package/src/interface/api/chat-message/index.ts +1 -0
- package/src/interface/api/constant/index.ts +2 -0
- package/src/interface/api/constant/login-mode/login-mode.ts +25 -0
- package/src/interface/api/constant/menu-permission-mode/menu-permission-mode.ts +20 -0
- package/src/interface/api/environment/i-devtool-config.ts +76 -0
- package/src/interface/api/environment/i-environment.ts +532 -0
- package/src/interface/api/environment/index.ts +2 -0
- package/src/interface/api/global-param/i-api-context.ts +37 -0
- package/src/interface/api/global-param/i-global-param.ts +27 -0
- package/src/interface/api/global-param/index.ts +2 -0
- package/src/interface/api/ibizsys/i-api-ibizsys.ts +54 -0
- package/src/interface/api/ibizsys/i-app-data.ts +64 -0
- package/src/interface/api/ibizsys/i-org-data.ts +31 -0
- package/src/interface/api/ibizsys/index.ts +3 -0
- package/src/interface/api/index.ts +6 -0
- package/src/interface/api/utils/i-api-i18n.ts +56 -0
- package/src/interface/api/utils/index.ts +5 -0
- package/src/interface/api/utils/message-center/base/i-message-all.ts +8 -0
- package/src/interface/api/utils/message-center/base/i-message-base.ts +29 -0
- package/src/interface/api/utils/message-center/base/index.ts +2 -0
- package/src/interface/api/utils/message-center/command/add-in-changed/i-add-in-changed.ts +25 -0
- package/src/interface/api/utils/message-center/command/add-in-changed/i-command-add-in-changed.ts +16 -0
- package/src/interface/api/utils/message-center/command/async-action/i-command-async-action.ts +17 -0
- package/src/interface/api/utils/message-center/command/change/i-command-change.ts +8 -0
- package/src/interface/api/utils/message-center/command/create/i-command-create.ts +18 -0
- package/src/interface/api/utils/message-center/command/i-command-base.ts +23 -0
- package/src/interface/api/utils/message-center/command/i-message-command.ts +94 -0
- package/src/interface/api/utils/message-center/command/index.ts +20 -0
- package/src/interface/api/utils/message-center/command/internal-message/i-command-internal-message.ts +17 -0
- package/src/interface/api/utils/message-center/command/internal-message/i-internal-message.ts +132 -0
- package/src/interface/api/utils/message-center/command/mark-open-data/i-command-mark-open-data.ts +17 -0
- package/src/interface/api/utils/message-center/command/mark-open-data/i-mark-open-data.ts +47 -0
- package/src/interface/api/utils/message-center/command/remove/i-command-remove.ts +18 -0
- package/src/interface/api/utils/message-center/command/update/i-command-update.ts +18 -0
- package/src/interface/api/utils/message-center/common/i-app-data-entity.ts +16 -0
- package/src/interface/api/utils/message-center/common/i-message-center-event.ts +15 -0
- package/src/interface/api/utils/message-center/common/i-msg-meta-data.ts +13 -0
- package/src/interface/api/utils/message-center/common/i-portal-async-action.ts +144 -0
- package/src/interface/api/utils/message-center/common/i-portal-message.ts +84 -0
- package/src/interface/api/utils/message-center/common/index.ts +5 -0
- package/src/interface/api/utils/message-center/console/i-message-console.ts +17 -0
- package/src/interface/api/utils/message-center/error/i-message-error.ts +17 -0
- package/src/interface/api/utils/message-center/i-message-center.ts +53 -0
- package/src/interface/api/utils/message-center/index.ts +6 -0
- package/src/interface/api/utils/net/i-api-http-error.ts +43 -0
- package/src/interface/api/utils/net/i-api-net.ts +93 -0
- package/src/interface/api/utils/net/i-http-response.ts +67 -0
- package/src/interface/click-outside/click-outside.ts +51 -0
- package/src/interface/command/command/i-command-option.ts +47 -0
- package/src/interface/command/command/i-command.ts +68 -0
- package/src/interface/command/disposable/i-disposable.ts +12 -0
- package/src/interface/command/i-command-controller.ts +50 -0
- package/src/interface/command/index.ts +11 -0
- package/src/interface/context/index.ts +42 -0
- package/src/interface/error/index.ts +13 -0
- package/src/interface/i-chat-message/i-chat-message.ts +16 -0
- package/src/interface/ibizsys/i-ibizsys.ts +33 -0
- package/src/interface/ibizsys/index.ts +1 -0
- package/src/interface/index.ts +11 -0
- package/src/interface/utils/i-18n.ts +22 -0
- package/src/interface/utils/index.ts +1 -0
- package/src/locale/en/index.ts +30 -0
- package/src/locale/index.ts +2 -0
- package/src/locale/zh-CN/index.ts +28 -0
- package/src/params/params.ts +131 -0
- package/src/types.ts +26 -0
- package/src/utils/bit-mask/bit-mask.ts +87 -0
- package/src/utils/click-outside/click-outside.ts +108 -0
- package/src/utils/clone/clone.ts +38 -0
- package/src/utils/color/color.ts +84 -0
- package/src/utils/cookie-util/cookie-util.ts +192 -0
- package/src/utils/data-type/data-types.ts +93 -0
- package/src/utils/download-file/download-file.ts +110 -0
- package/src/utils/event/event.ts +69 -0
- package/src/utils/history-list/history-item.ts +41 -0
- package/src/utils/history-list/history-list.ts +137 -0
- package/src/utils/index.ts +24 -0
- package/src/utils/interceptor/core-interceptor.ts +127 -0
- package/src/utils/interceptor/index.ts +2 -0
- package/src/utils/interceptor/interceptor.ts +122 -0
- package/src/utils/logger/logger.ts +34 -0
- package/src/utils/message-center/base/message-all.ts +10 -0
- package/src/utils/message-center/base/message-base.ts +73 -0
- package/src/utils/message-center/command/add-in-changed/command-add-in-changed.ts +23 -0
- package/src/utils/message-center/command/async-action/command-async-action.ts +23 -0
- package/src/utils/message-center/command/change/command-change.ts +11 -0
- package/src/utils/message-center/command/command-base/command-base.ts +35 -0
- package/src/utils/message-center/command/create/command-create.ts +25 -0
- package/src/utils/message-center/command/internal-message/command-internal-message.ts +26 -0
- package/src/utils/message-center/command/mark-open-data/command-mark-open-data.ts +23 -0
- package/src/utils/message-center/command/message-command.ts +162 -0
- package/src/utils/message-center/command/remove/command-remove.ts +25 -0
- package/src/utils/message-center/command/update/command-update.ts +25 -0
- package/src/utils/message-center/console/message-console.ts +27 -0
- package/src/utils/message-center/error/message-error.ts +27 -0
- package/src/utils/message-center/index.ts +1 -0
- package/src/utils/message-center/message-center.ts +77 -0
- package/src/utils/namespace/namespace.ts +217 -0
- package/src/utils/net/http-response.ts +60 -0
- package/src/utils/net/net.ts +463 -0
- package/src/utils/recursive/find-recursive-child.ts +238 -0
- package/src/utils/string-util/string-util.ts +76 -0
- package/src/utils/style/remote-style.ts +17 -0
- package/src/utils/sync/await-timeout.ts +29 -0
- package/src/utils/sync/count-latch.ts +79 -0
- package/src/utils/sync/index.ts +2 -0
- package/src/utils/types/types.ts +24 -0
- package/src/utils/upload/select-file.ts +93 -0
- package/src/utils/upload/upload-file.ts +194 -0
- package/src/utils/url-helper/url-helper.ts +52 -0
- package/src/utils/util/util.ts +580 -0
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
import { ICommandHandler, ICommandOption } from '../../command';
|
|
2
|
+
import { IDisposable } from './disposable/i-disposable';
|
|
3
|
+
|
|
4
|
+
/**
|
|
5
|
+
* @description 指令控制器接口
|
|
6
|
+
* @export
|
|
7
|
+
* @interface ICommandController
|
|
8
|
+
*/
|
|
9
|
+
export interface ICommandController {
|
|
10
|
+
/**
|
|
11
|
+
* @description 注册指令
|
|
12
|
+
* @param {string} id 指令id
|
|
13
|
+
* @param {ICommandHandler} handler 指令处理回调
|
|
14
|
+
* @param {ICommandOption} [opts] 指令参数
|
|
15
|
+
* @returns {*} {IDisposable} 指令释放对象
|
|
16
|
+
* @memberof ICommandController
|
|
17
|
+
*/
|
|
18
|
+
register(
|
|
19
|
+
id: string,
|
|
20
|
+
handler: ICommandHandler,
|
|
21
|
+
opts?: ICommandOption,
|
|
22
|
+
): IDisposable;
|
|
23
|
+
|
|
24
|
+
/**
|
|
25
|
+
* @description 执行指令
|
|
26
|
+
* @template T
|
|
27
|
+
* @param {string} id 指令id
|
|
28
|
+
* @param {...unknown[]} args 指令参数
|
|
29
|
+
* @returns {*} {Promise<T>} 指令返回值
|
|
30
|
+
* @memberof ICommandController
|
|
31
|
+
*/
|
|
32
|
+
execute<T = undefined>(id: string, ...args: unknown[]): Promise<T>;
|
|
33
|
+
|
|
34
|
+
/**
|
|
35
|
+
* @description 判断指令是否存在,没有则直接抛出异常
|
|
36
|
+
* @param {string} id 指令id
|
|
37
|
+
* @param {boolean} [err] 是否抛出异常
|
|
38
|
+
* @returns {*} {boolean} 是否存在
|
|
39
|
+
* @memberof ICommandController
|
|
40
|
+
*/
|
|
41
|
+
hasCommand(id: string, err?: boolean): boolean;
|
|
42
|
+
|
|
43
|
+
/**
|
|
44
|
+
* @description 获取指令参数
|
|
45
|
+
* @param {string} id 指令id
|
|
46
|
+
* @returns {*} {(ICommandOption | undefined)} 指令参数
|
|
47
|
+
* @memberof ICommandController
|
|
48
|
+
*/
|
|
49
|
+
getCommandOpts(id: string): ICommandOption | undefined;
|
|
50
|
+
}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
export type {
|
|
2
|
+
ICommand,
|
|
3
|
+
ICommandsMap,
|
|
4
|
+
ICommandRegistry,
|
|
5
|
+
} from './command/i-command';
|
|
6
|
+
export type {
|
|
7
|
+
ICommandOption,
|
|
8
|
+
ICommandHandler,
|
|
9
|
+
} from './command/i-command-option';
|
|
10
|
+
export type { IDisposable } from './disposable/i-disposable';
|
|
11
|
+
export type { ICommandController } from './i-command-controller';
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @description 应用上下文处理接口
|
|
3
|
+
* @export
|
|
4
|
+
* @interface IIBizContext
|
|
5
|
+
* @extends {IContext}
|
|
6
|
+
*/
|
|
7
|
+
export interface IIBizContext extends IContext {
|
|
8
|
+
/**
|
|
9
|
+
* @description 返回自身的上下文,独有的和与父有差异的
|
|
10
|
+
* @returns {*} {IData}
|
|
11
|
+
* @memberof IIBizContext
|
|
12
|
+
*/
|
|
13
|
+
getOwnContext(): IData;
|
|
14
|
+
|
|
15
|
+
/**
|
|
16
|
+
* @description 销毁当前上下文
|
|
17
|
+
* @memberof IIBizContext
|
|
18
|
+
*/
|
|
19
|
+
destroy(): void;
|
|
20
|
+
|
|
21
|
+
/**
|
|
22
|
+
* @description 克隆当前上下文
|
|
23
|
+
* @returns {*} {IContext}
|
|
24
|
+
* @memberof IIBizContext
|
|
25
|
+
*/
|
|
26
|
+
clone(): IContext;
|
|
27
|
+
|
|
28
|
+
/**
|
|
29
|
+
* @description 深度克隆
|
|
30
|
+
* @return {*} {IData}
|
|
31
|
+
* @memberof IIBizContext
|
|
32
|
+
*/
|
|
33
|
+
deepClone(): IData;
|
|
34
|
+
|
|
35
|
+
/**
|
|
36
|
+
* @description 在不改变对象引用的情况下,重置上下文,等效于重新实例化,但是引用不变
|
|
37
|
+
* @param {IData} [context] 默认值
|
|
38
|
+
* @param {IContext} [parent] 父上下文
|
|
39
|
+
* @memberof IIBizContext
|
|
40
|
+
*/
|
|
41
|
+
reset(context?: IData, parent?: IContext): void;
|
|
42
|
+
}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import { IPortalAsyncAction } from '../api';
|
|
2
|
+
import { IApiChatMessage } from '../api/chat-message';
|
|
3
|
+
|
|
4
|
+
/**
|
|
5
|
+
* @description AI聊天消息
|
|
6
|
+
* @export
|
|
7
|
+
* @interface IChatMessage
|
|
8
|
+
*/
|
|
9
|
+
export interface IChatMessage extends IApiChatMessage {
|
|
10
|
+
/**
|
|
11
|
+
* @description 消息数据
|
|
12
|
+
* @type {(IPortalAsyncAction | IData | string | unknown)}
|
|
13
|
+
* @memberof IChatMessage
|
|
14
|
+
*/
|
|
15
|
+
data?: IPortalAsyncAction | IData | string | unknown;
|
|
16
|
+
}
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
/* eslint-disable @typescript-eslint/no-explicit-any */
|
|
2
|
+
import { Logger } from 'loglevel';
|
|
3
|
+
import { IApiIBizsys } from '../api';
|
|
4
|
+
import { ICommandController } from '../command';
|
|
5
|
+
|
|
6
|
+
/**
|
|
7
|
+
* @description 全局对象
|
|
8
|
+
* @export
|
|
9
|
+
* @interface IIBizsys
|
|
10
|
+
*/
|
|
11
|
+
export interface IIBizsys extends IApiIBizsys {
|
|
12
|
+
/**
|
|
13
|
+
* @description 日志输出工具
|
|
14
|
+
* @type {Logger}
|
|
15
|
+
* @memberof IIBizsys
|
|
16
|
+
*/
|
|
17
|
+
log: Logger;
|
|
18
|
+
|
|
19
|
+
/**
|
|
20
|
+
* @description 指令控制器
|
|
21
|
+
* @type {ICommandController}
|
|
22
|
+
* @memberof IIBizsys
|
|
23
|
+
*/
|
|
24
|
+
commands: ICommandController;
|
|
25
|
+
|
|
26
|
+
/**
|
|
27
|
+
* @description 注册全局扩展,用于替换预置能力
|
|
28
|
+
* @param {keyof IBizSys} key
|
|
29
|
+
* @param {*} value
|
|
30
|
+
* @memberof IIBizsys
|
|
31
|
+
*/
|
|
32
|
+
registerExtension(key: keyof IApiIBizsys, value: any): void;
|
|
33
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export type { IIBizsys } from './i-ibizsys';
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { IOrgData } from './api/ibizsys/i-org-data';
|
|
2
|
+
|
|
3
|
+
export * from './api';
|
|
4
|
+
export * from './click-outside/click-outside';
|
|
5
|
+
export * from './command';
|
|
6
|
+
export * from './context';
|
|
7
|
+
export * from './error';
|
|
8
|
+
export type { IChatMessage } from './i-chat-message/i-chat-message';
|
|
9
|
+
export type OrgData = IOrgData;
|
|
10
|
+
export * from './ibizsys';
|
|
11
|
+
export * from './utils';
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import { IApiI18n } from '../api';
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* @description 多语言工具接口
|
|
5
|
+
* @export
|
|
6
|
+
* @interface I18n
|
|
7
|
+
*/
|
|
8
|
+
export interface I18n extends IApiI18n {
|
|
9
|
+
/**
|
|
10
|
+
* @description 异步初始化,加载多语言文件
|
|
11
|
+
* @returns {*} {Promise<void>}
|
|
12
|
+
* @memberof I18n
|
|
13
|
+
*/
|
|
14
|
+
init(): Promise<void>;
|
|
15
|
+
|
|
16
|
+
/**
|
|
17
|
+
* @description 设置异步加载的多语言模块
|
|
18
|
+
* @param {Record<string, () => Promise<IData>>} languages
|
|
19
|
+
* @memberof I18n
|
|
20
|
+
*/
|
|
21
|
+
setLangConfigs(languages: Record<string, () => Promise<IData>>): void;
|
|
22
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export type { I18n } from './i-18n';
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
export const en = {
|
|
2
|
+
core: {
|
|
3
|
+
command: {
|
|
4
|
+
unregisteredCommand:
|
|
5
|
+
'Unregistered command: {id}, please register the command first',
|
|
6
|
+
},
|
|
7
|
+
error: {
|
|
8
|
+
networkAbnormality: 'Network abnormality, please try again later',
|
|
9
|
+
modelMsg: '「{id}」 model {msg}',
|
|
10
|
+
unsupportedModels: 'Unsupported models',
|
|
11
|
+
modelConfigurationMissing: 'Model Configuration Missing',
|
|
12
|
+
serviceException: 'Exception in service handling',
|
|
13
|
+
serviceResNotExist: 'Request resource path does not exist',
|
|
14
|
+
serviceResNotPermission: 'Requesting resources without permission',
|
|
15
|
+
},
|
|
16
|
+
utils: {
|
|
17
|
+
powerOfTwo: '{permission} is not a power of two.',
|
|
18
|
+
targetElement: 'The target element does not exist',
|
|
19
|
+
cannotFindWindow: 'Cannot find window',
|
|
20
|
+
unrealized: 'unrealized',
|
|
21
|
+
remoteStylesheet: 'Failed to load remote stylesheet',
|
|
22
|
+
notMatchLockUnlock: 'The lock and unlock counts do not match!',
|
|
23
|
+
multiApplicationMode:
|
|
24
|
+
'Multi-application mode waiting for reimplementation requests',
|
|
25
|
+
uploadFailed: '{file}Upload failed',
|
|
26
|
+
invalidInputValue: 'Invalid input value, must be >= 0',
|
|
27
|
+
},
|
|
28
|
+
noReInstall: 'ibiz already exists, no need to re-install it',
|
|
29
|
+
},
|
|
30
|
+
};
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
export const zhCn = {
|
|
2
|
+
core: {
|
|
3
|
+
command: {
|
|
4
|
+
unregisteredCommand: '未注册指令: {id},请先注册指令',
|
|
5
|
+
},
|
|
6
|
+
error: {
|
|
7
|
+
networkAbnormality: '网络异常,请稍后重试',
|
|
8
|
+
modelMsg: '「{id}」模型 {msg}',
|
|
9
|
+
unsupportedModels: '未支持的模型',
|
|
10
|
+
modelConfigurationMissing: '模型配置缺失',
|
|
11
|
+
serviceException: '服务处理异常',
|
|
12
|
+
serviceResNotExist: '请求资源路径不存在',
|
|
13
|
+
serviceResNotPermission: '请求资源无权限',
|
|
14
|
+
},
|
|
15
|
+
utils: {
|
|
16
|
+
powerOfTwo: '{permission}不是2的幂',
|
|
17
|
+
targetElement: 'target元素不存在',
|
|
18
|
+
cannotFindWindow: '找不到window',
|
|
19
|
+
unrealized: '未实现',
|
|
20
|
+
remoteStylesheet: '未实现加载远程样式表失败',
|
|
21
|
+
notMatchLockUnlock: 'lock和unlock次数不匹配!',
|
|
22
|
+
multiApplicationMode: '多应用模式等待重新实现请求',
|
|
23
|
+
uploadFailed: '{file}Upload failed',
|
|
24
|
+
invalidInputValue: '无效输入值,必须>=0',
|
|
25
|
+
},
|
|
26
|
+
noReInstall: 'ibiz 已经存在, 无需重复安装',
|
|
27
|
+
},
|
|
28
|
+
};
|
|
@@ -0,0 +1,131 @@
|
|
|
1
|
+
/* eslint-disable no-constructor-return */
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* @description 视图参数处理类
|
|
5
|
+
* @export
|
|
6
|
+
* @class IBizParams
|
|
7
|
+
* @implements {IParams}
|
|
8
|
+
*/
|
|
9
|
+
export class IBizParams implements IParams {
|
|
10
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
11
|
+
[key: string | symbol]: any;
|
|
12
|
+
|
|
13
|
+
/**
|
|
14
|
+
* @description 自身的属性
|
|
15
|
+
* @protected
|
|
16
|
+
* @type {IParams}
|
|
17
|
+
* @memberof IBizParams
|
|
18
|
+
*/
|
|
19
|
+
declare protected _params: IParams;
|
|
20
|
+
|
|
21
|
+
/**
|
|
22
|
+
* @description 父视图参数
|
|
23
|
+
* @protected
|
|
24
|
+
* @type {IParams}
|
|
25
|
+
* @memberof IBizParams
|
|
26
|
+
*/
|
|
27
|
+
declare protected _parent?: IParams;
|
|
28
|
+
|
|
29
|
+
/**
|
|
30
|
+
* Creates an instance of IBizParams.
|
|
31
|
+
* @param {IParams} [params] 自身的参数
|
|
32
|
+
* @param {IParams} [parent] 父视图参数
|
|
33
|
+
* @memberof IBizParams
|
|
34
|
+
*/
|
|
35
|
+
constructor(params?: IParams, parent?: IParams) {
|
|
36
|
+
// 定义私有变量,存放父视图参数源对象
|
|
37
|
+
Object.defineProperty(this, '_parent', {
|
|
38
|
+
enumerable: false,
|
|
39
|
+
configurable: true,
|
|
40
|
+
writable: true,
|
|
41
|
+
value: parent,
|
|
42
|
+
});
|
|
43
|
+
|
|
44
|
+
// 定义私有变量,用于存储对父已有视图参数的修改。
|
|
45
|
+
Object.defineProperty(this, '_params', {
|
|
46
|
+
enumerable: false,
|
|
47
|
+
configurable: true,
|
|
48
|
+
writable: true,
|
|
49
|
+
value: params || {},
|
|
50
|
+
});
|
|
51
|
+
|
|
52
|
+
return this.createProxy();
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
/**
|
|
56
|
+
* @description 创建代理对象
|
|
57
|
+
* @protected
|
|
58
|
+
* @returns {*} {IBizParams}
|
|
59
|
+
* @memberof IBizParams
|
|
60
|
+
*/
|
|
61
|
+
protected createProxy(): IBizParams {
|
|
62
|
+
// 更新属性,缺的补充定义
|
|
63
|
+
function updateKeyDefine(target: IParams, keys: string[]): void {
|
|
64
|
+
keys.forEach(key => {
|
|
65
|
+
if (!Object.prototype.hasOwnProperty.call(target, key)) {
|
|
66
|
+
Object.defineProperty(target, key, {
|
|
67
|
+
enumerable: true,
|
|
68
|
+
configurable: true,
|
|
69
|
+
writable: true,
|
|
70
|
+
value: undefined,
|
|
71
|
+
});
|
|
72
|
+
}
|
|
73
|
+
});
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
return new Proxy(this, {
|
|
77
|
+
set(target: IBizParams, p: string, value: unknown): boolean {
|
|
78
|
+
if (['_params', '_parent'].includes(p)) {
|
|
79
|
+
target[p] = value;
|
|
80
|
+
} else {
|
|
81
|
+
target._params[p] = value;
|
|
82
|
+
}
|
|
83
|
+
return true;
|
|
84
|
+
},
|
|
85
|
+
|
|
86
|
+
get(target: IBizParams, p: string | symbol, _receiver: unknown): unknown {
|
|
87
|
+
if (target[p] !== undefined) {
|
|
88
|
+
return target[p];
|
|
89
|
+
}
|
|
90
|
+
if (target._params[p] !== undefined) {
|
|
91
|
+
return target._params[p];
|
|
92
|
+
}
|
|
93
|
+
if (target._parent && target._parent[p] !== undefined) {
|
|
94
|
+
return target._parent[p];
|
|
95
|
+
}
|
|
96
|
+
},
|
|
97
|
+
|
|
98
|
+
ownKeys(target: IBizParams): ArrayLike<string | symbol> {
|
|
99
|
+
// 整合所有并排重
|
|
100
|
+
const allKeys = [
|
|
101
|
+
...new Set([
|
|
102
|
+
...Object.keys(target._params),
|
|
103
|
+
...Object.keys(target._parent || {}),
|
|
104
|
+
]),
|
|
105
|
+
];
|
|
106
|
+
updateKeyDefine(target, allKeys);
|
|
107
|
+
return allKeys;
|
|
108
|
+
},
|
|
109
|
+
});
|
|
110
|
+
}
|
|
111
|
+
|
|
112
|
+
/**
|
|
113
|
+
* @description 在不改变对象引用的情况下,重置视图参数,等效于重新实例化,但是引用不变
|
|
114
|
+
* @param {IParams} [params] 视图参数
|
|
115
|
+
* @param {IParams} [parent] 父视图参数
|
|
116
|
+
* @memberof IBizParams
|
|
117
|
+
*/
|
|
118
|
+
reset(params?: IParams, parent?: IParams): void {
|
|
119
|
+
this._params = params || {};
|
|
120
|
+
this._parent = parent;
|
|
121
|
+
}
|
|
122
|
+
|
|
123
|
+
/**
|
|
124
|
+
* @description 销毁视图参数,避免内存泄漏
|
|
125
|
+
* @memberof IBizParams
|
|
126
|
+
*/
|
|
127
|
+
destroy(): void {
|
|
128
|
+
this._params = {};
|
|
129
|
+
this._parent = undefined;
|
|
130
|
+
}
|
|
131
|
+
}
|
package/src/types.ts
ADDED
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
/* eslint-disable @typescript-eslint/no-explicit-any */
|
|
2
|
+
import { IBizSys } from './ibizsys';
|
|
3
|
+
import {
|
|
4
|
+
IApiContext,
|
|
5
|
+
IApiData,
|
|
6
|
+
IApiObject,
|
|
7
|
+
IApiParams,
|
|
8
|
+
IEnvironment,
|
|
9
|
+
} from './interface';
|
|
10
|
+
|
|
11
|
+
declare global {
|
|
12
|
+
const ibiz: IBizSys;
|
|
13
|
+
|
|
14
|
+
interface Window {
|
|
15
|
+
ibiz: IBizSys;
|
|
16
|
+
Environment: IEnvironment;
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
type IContext = IApiContext;
|
|
20
|
+
|
|
21
|
+
type IParams = IApiParams;
|
|
22
|
+
|
|
23
|
+
type IData = IApiData;
|
|
24
|
+
|
|
25
|
+
type IObject = IApiObject;
|
|
26
|
+
}
|
|
@@ -0,0 +1,87 @@
|
|
|
1
|
+
/* eslint-disable default-param-last */
|
|
2
|
+
/* eslint-disable no-bitwise */
|
|
3
|
+
|
|
4
|
+
import { RuntimeError } from '../../error';
|
|
5
|
+
|
|
6
|
+
/**
|
|
7
|
+
* @description 检查权限码是否有效,权限码是否是2的幂
|
|
8
|
+
* @example
|
|
9
|
+
* ```typescript
|
|
10
|
+
* validate(1) // => true
|
|
11
|
+
* validate(3) // => false
|
|
12
|
+
* ```
|
|
13
|
+
* @static
|
|
14
|
+
* @param {number} permission
|
|
15
|
+
*/
|
|
16
|
+
function validate(permission: number): boolean {
|
|
17
|
+
return !!permission && !(permission & (permission - 1));
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
/**
|
|
21
|
+
* @description 检查权限码是否有效,无效抛错
|
|
22
|
+
* @param {number} permission
|
|
23
|
+
*/
|
|
24
|
+
function validateAndThrow(permission: number): void {
|
|
25
|
+
const isPowerOf2 = validate(permission);
|
|
26
|
+
if (!isPowerOf2) {
|
|
27
|
+
throw new RuntimeError(
|
|
28
|
+
ibiz.i18n.t('core.utils.powerOfTwo', { permission }),
|
|
29
|
+
);
|
|
30
|
+
}
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
/**
|
|
34
|
+
* @description 设置权限,数字转二进制后进行|运算, 设置对应bit位为1(bit位为1代表有权限,bit位为0代表没有权限)
|
|
35
|
+
* @example
|
|
36
|
+
* ```typescript
|
|
37
|
+
* setPermission(0, 1) // => 1
|
|
38
|
+
* setPermission(1, 4) // => 5
|
|
39
|
+
* ```
|
|
40
|
+
* @param {number} [allPermissions=0]
|
|
41
|
+
* @param {number} permission
|
|
42
|
+
* @returns {*} {number}
|
|
43
|
+
*/
|
|
44
|
+
function setPermission(allPermissions: number = 0, permission: number): number {
|
|
45
|
+
validateAndThrow(permission);
|
|
46
|
+
return allPermissions | permission;
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
/**
|
|
50
|
+
* @description 移出权限,数字转二进制后进行取反并且进行&运算, 设置对应bit位为0(bit位为1代表有权限,bit位为0代表没有权限)
|
|
51
|
+
* @param {number} [allPermissions=0] 当前所有权限
|
|
52
|
+
* @param {number} permission 要移出的权限
|
|
53
|
+
* @returns {*} {number}
|
|
54
|
+
*/
|
|
55
|
+
function removePermission(
|
|
56
|
+
allPermissions: number = 0,
|
|
57
|
+
permission: number,
|
|
58
|
+
): number {
|
|
59
|
+
validateAndThrow(permission);
|
|
60
|
+
return allPermissions & ~permission;
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
/**
|
|
64
|
+
* @description 检查是否有某个权限,数字转二进制后进行&运算,为1则有权限,为0则没有权限
|
|
65
|
+
* @example
|
|
66
|
+
* ```typescript
|
|
67
|
+
* checkPermission(0, 1) // => false
|
|
68
|
+
* checkPermission(5, 4) // => true
|
|
69
|
+
* ```
|
|
70
|
+
* @param {number} [allPermissions=0]
|
|
71
|
+
* @param {number} permission
|
|
72
|
+
* @returns {*} {boolean}
|
|
73
|
+
*/
|
|
74
|
+
function checkPermission(
|
|
75
|
+
allPermissions: number = 0,
|
|
76
|
+
permission: number,
|
|
77
|
+
): boolean {
|
|
78
|
+
validateAndThrow(permission);
|
|
79
|
+
return (allPermissions & permission) !== 0;
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
export const BitMask = {
|
|
83
|
+
validate,
|
|
84
|
+
setPermission,
|
|
85
|
+
removePermission,
|
|
86
|
+
checkPermission,
|
|
87
|
+
};
|
|
@@ -0,0 +1,108 @@
|
|
|
1
|
+
import { RuntimeError } from '../../error';
|
|
2
|
+
import {
|
|
3
|
+
OnClickOutsideHandler,
|
|
4
|
+
OnClickOutsideOptions,
|
|
5
|
+
OnClickOutsideResult,
|
|
6
|
+
} from '../../interface';
|
|
7
|
+
import { eventPath, isEventInside, listenJSEvent } from '../event/event';
|
|
8
|
+
|
|
9
|
+
const defaultWindow = typeof window !== 'undefined' ? window : undefined;
|
|
10
|
+
|
|
11
|
+
/**
|
|
12
|
+
* @description 监听目标元素之外的点击事件回调
|
|
13
|
+
* @export
|
|
14
|
+
* @param {HTMLElement} target 目标元素
|
|
15
|
+
* @param {OnClickOutsideHandler} handler 触发的时间回调
|
|
16
|
+
* @param {OnClickOutsideOptions} [options={}] 额外配置参数
|
|
17
|
+
* @returns {*} {OnClickOutsideResult}
|
|
18
|
+
*/
|
|
19
|
+
export function onClickOutside(
|
|
20
|
+
target: HTMLElement,
|
|
21
|
+
handler: OnClickOutsideHandler,
|
|
22
|
+
options: OnClickOutsideOptions = {},
|
|
23
|
+
): OnClickOutsideResult {
|
|
24
|
+
const { window = defaultWindow, ignore = [], capture = true } = options;
|
|
25
|
+
|
|
26
|
+
if (!target) throw new RuntimeError(ibiz.i18n.t('core.utils.targetElement'));
|
|
27
|
+
if (!window)
|
|
28
|
+
throw new RuntimeError(ibiz.i18n.t('core.utils.cannotFindWindow'));
|
|
29
|
+
|
|
30
|
+
/** 是否需要监听,为false时handler不会执行 */
|
|
31
|
+
let shouldListen = true;
|
|
32
|
+
|
|
33
|
+
/**
|
|
34
|
+
* 判断event的触发是否是在元素的外部(排除了ignore元素)
|
|
35
|
+
* @param event 事件对象
|
|
36
|
+
* @returns
|
|
37
|
+
*/
|
|
38
|
+
const isOutside = (event: MouseEvent): boolean => {
|
|
39
|
+
// 有一个判断是在内部,则不算外部,返回false
|
|
40
|
+
return ![target, ...ignore].some(el => {
|
|
41
|
+
return isEventInside(event, el);
|
|
42
|
+
});
|
|
43
|
+
};
|
|
44
|
+
|
|
45
|
+
/** 暂停,所有监听的回调都不执行,用于增强某些ignore无法实现的场景 */
|
|
46
|
+
let isPaused = false;
|
|
47
|
+
const pause = (): void => {
|
|
48
|
+
isPaused = true;
|
|
49
|
+
};
|
|
50
|
+
const proceed = (): void => {
|
|
51
|
+
isPaused = false;
|
|
52
|
+
};
|
|
53
|
+
|
|
54
|
+
/** pointerup延时触发标识 */
|
|
55
|
+
let fallback: number;
|
|
56
|
+
|
|
57
|
+
/**
|
|
58
|
+
* 事件监听处理回调
|
|
59
|
+
* @param event 事件对象
|
|
60
|
+
* @returns
|
|
61
|
+
*/
|
|
62
|
+
const listener = (event: MouseEvent): void => {
|
|
63
|
+
if (isPaused) return;
|
|
64
|
+
window.clearTimeout(fallback);
|
|
65
|
+
|
|
66
|
+
// 当需要监听并且最终触发在外部时才需要执行回调
|
|
67
|
+
if (!(shouldListen && isOutside(event))) return;
|
|
68
|
+
|
|
69
|
+
handler(event);
|
|
70
|
+
};
|
|
71
|
+
|
|
72
|
+
// 鼠标左键单击先后触发pointerdown,pointerup,click
|
|
73
|
+
// 鼠标右键单击先后触发pointerdown,pointerup
|
|
74
|
+
const cleanups = [
|
|
75
|
+
listenJSEvent(window, 'click', listener, { passive: true, capture }),
|
|
76
|
+
listenJSEvent(
|
|
77
|
+
window,
|
|
78
|
+
'pointerdown',
|
|
79
|
+
e => {
|
|
80
|
+
if (isPaused) return;
|
|
81
|
+
// 当pointerdown是在内部触发则不需要后续监听
|
|
82
|
+
shouldListen = isOutside(e);
|
|
83
|
+
},
|
|
84
|
+
{ passive: true },
|
|
85
|
+
),
|
|
86
|
+
listenJSEvent(
|
|
87
|
+
window,
|
|
88
|
+
'pointerup',
|
|
89
|
+
e => {
|
|
90
|
+
if (isPaused) return;
|
|
91
|
+
// 鼠标左键触发才执行
|
|
92
|
+
if (e.button === 0) {
|
|
93
|
+
// 锁死结果避免延时执行时变更
|
|
94
|
+
const path = eventPath(e);
|
|
95
|
+
e.composedPath = (): (EventTarget | null)[] => path;
|
|
96
|
+
fallback = window.setTimeout(() => listener(e), 50);
|
|
97
|
+
}
|
|
98
|
+
},
|
|
99
|
+
{ passive: true },
|
|
100
|
+
),
|
|
101
|
+
].filter(Boolean);
|
|
102
|
+
|
|
103
|
+
/**
|
|
104
|
+
* 停止事件监听,移除监听
|
|
105
|
+
*/
|
|
106
|
+
const stop = (): void => cleanups.forEach(fn => fn());
|
|
107
|
+
return { stop, pause, proceed };
|
|
108
|
+
}
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
import { cloneDeepWith, cloneWith, isFunction, isObject } from 'lodash-es';
|
|
2
|
+
import { mergeDeepRight } from 'ramda';
|
|
3
|
+
|
|
4
|
+
export type CloneOpts = {
|
|
5
|
+
deep?: boolean;
|
|
6
|
+
};
|
|
7
|
+
|
|
8
|
+
/**
|
|
9
|
+
* @description 自定义克隆逻辑,有clone方法的拿clone方法,否则直接用lodash的clone
|
|
10
|
+
* @template T
|
|
11
|
+
* @param {T} value
|
|
12
|
+
* @returns {*} {(T | undefined)}
|
|
13
|
+
*/
|
|
14
|
+
function customizeFn<T>(value: T): T | undefined {
|
|
15
|
+
if (isObject(value) && isFunction((value as IData).clone)) {
|
|
16
|
+
return (value as IData).clone();
|
|
17
|
+
}
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
const DefaultCloneOpts: CloneOpts = {
|
|
21
|
+
deep: true,
|
|
22
|
+
} as const;
|
|
23
|
+
|
|
24
|
+
/**
|
|
25
|
+
* @description 克隆方法(如果对象有clone方法会用clone方法调用clone)
|
|
26
|
+
* @export
|
|
27
|
+
* @template T
|
|
28
|
+
* @param {T} value
|
|
29
|
+
* @param {CloneOpts} [opts]
|
|
30
|
+
* @returns {*} {T}
|
|
31
|
+
*/
|
|
32
|
+
export function clone<T>(value: T, opts?: CloneOpts): T {
|
|
33
|
+
const options = mergeDeepRight(DefaultCloneOpts, opts || {})!;
|
|
34
|
+
if (options.deep) {
|
|
35
|
+
return cloneDeepWith(value, customizeFn);
|
|
36
|
+
}
|
|
37
|
+
return cloneWith(value, customizeFn);
|
|
38
|
+
}
|