Skip to content

Commit 0aa7044

Browse files
committed
refactor: add VisualInteractions interface
1 parent 7ce11c4 commit 0aa7044

2 files changed

Lines changed: 38 additions & 6 deletions

File tree

src/interfaces.ts

Lines changed: 22 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
export interface VisualAttr {
2-
left?: number;
3-
top?: number;
2+
left: number;
3+
top: number;
44
width?: number;
55
height?: number;
66
deg?: number;
@@ -29,6 +29,25 @@ export interface VisualActions {
2929
[k: string]: VisualAction;
3030
}
3131

32+
export interface VisualInteraction {
33+
/** 交互事件 */
34+
event: string;
35+
/** 交互组件 */
36+
component: { id: string; name: string };
37+
/** 交互动作 */
38+
action: string;
39+
/** 数据过滤器 */
40+
filters: VisualDataFilter[];
41+
/** 条件配置 */
42+
conditions?: VisualDataFilter[];
43+
/** 条件类型:全部满足或者只满足一个 */
44+
conditionType?: 'all' | 'either' | null;
45+
}
46+
47+
export interface VisualInteractions {
48+
[k: string]: VisualInteraction[];
49+
}
50+
3251
export interface VisualApiField {
3352
/** 字段描述 */
3453
description: string;
@@ -51,7 +70,7 @@ export interface VisualApi {
5170
handler: string;
5271
/** 字段列表 */
5372
fields?: VisualApiFields;
54-
};
73+
}
5574

5675
export interface VisualApis {
5776
[k: string]: VisualApi;

src/visual-component.ts

Lines changed: 16 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ import {
88
VisualDataConfig,
99
VisualDataSource,
1010
VisualEvents,
11+
VisualInteractions,
1112
} from './interfaces';
1213
import { mergeDataSource } from './utils';
1314

@@ -52,11 +53,14 @@ export class VisualComponent {
5253

5354
private _cdr?: ChangeDetectorRef;
5455

56+
/** 组件 ID */
57+
id = '';
58+
5559
/** 版本号 */
5660
version = '';
5761

5862
/** 基础属性 */
59-
attr: VisualAttr = {};
63+
attr: VisualAttr = { left: 0, top: 0 };
6064

6165
/** 配置项的 GUI 定义 */
6266
config: GuiFields = {};
@@ -86,6 +90,9 @@ export class VisualComponent {
8690
},
8791
};
8892

93+
/** 交互配置 */
94+
interactions: VisualInteractions = {};
95+
8996
/** API 字段配置 */
9097
apis: VisualApis = {};
9198

@@ -102,10 +109,16 @@ export class VisualComponent {
102109
resources: Record<string, any> = {};
103110

104111
/** 控制隐藏的变量 */
105-
isHide = false;
112+
isHide?: boolean;
106113

107114
/** 无数据标记,每个组件根据业务场景独立控制 */
108-
noData = false;
115+
noData?: boolean;
116+
117+
/** 父组件 */
118+
parent?: VisualComponent;
119+
120+
/** 子组件 */
121+
children?: VisualComponent[];
109122

110123
/** 显示 */
111124
show() {

0 commit comments

Comments
 (0)