@pisell/core 1.0.15 → 1.0.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,50 +1,202 @@
1
- import App from "../app";
2
- import { LoadLibraryByUrlParams } from "../locales/type";
3
- import { MenuItem } from "../menuManager/index";
1
+ import App from '../app';
2
+ import { LoadLibraryByUrlParams } from '../locales/type';
3
+ import { MenuItem } from '../menuManager/index';
4
+ /**
5
+ * 应用接口类型定义
6
+ * @description 描述应用中单个页面、组件或功能的接口结构
7
+ */
4
8
  export declare type ApplicationInterface = {
5
- page_type: "low_code" | "code";
9
+ /** 页面类型:低代码或普通代码 */
10
+ page_type: 'low_code' | 'code';
11
+ /** 页面唯一标识 */
6
12
  page_id: number | string;
13
+ /** 页面code 优先使用 page_code 因为这个不会变, id在不同环境会变 */
7
14
  page_code: string;
15
+ /** 页面版本号,可选 */
8
16
  page_version?: string;
17
+ /** 页面显示名称, 这个会展示在tab标签页 */
9
18
  page_name: string;
10
- router: string;
11
- category: "page" | "component" | "function";
19
+ /** 路由地址, 可选 组件类型不使用这个 */
20
+ router?: string;
21
+ /** interface类别:页面、组件或功能 */
22
+ category: 'page' | 'component' | 'function';
23
+ /** React组件,可选, 不选使用低代码渲染 */
12
24
  Component?: any;
25
+ /** 子组件或子元素,可选, Layout会需要 */
13
26
  children?: any;
27
+ /** 布局模板,可选, 不选为默认layout */
14
28
  layout?: string;
29
+ /** 原始URL地址,可选 */
15
30
  originalUrl?: string;
31
+ autoRender?: boolean;
16
32
  };
33
+ /**
34
+ * 应用数据类型定义
35
+ * @description 描述完整应用的数据结构,包含应用的基本信息、接口、功能等
36
+ */
17
37
  export declare type ApplicationData = {
38
+ /** 应用唯一标识 */
18
39
  app_id: number;
40
+ /** 应用名称 */
19
41
  app_name: string;
20
- app_type: "system" | "custom";
42
+ /** 应用类型:系统应用或自定义应用 */
43
+ app_type: 'system' | 'custom';
44
+ /** 应用包含的接口列表 */
21
45
  interfaces: ApplicationInterface[];
46
+ /** 应用包含的功能列表,可选 */
22
47
  functions?: any[];
48
+ /** 应用的菜单配置 */
23
49
  menu?: {
24
50
  [key: string]: MenuItem[];
25
51
  };
52
+ /** 多语言配置,可选 */
26
53
  locales?: LoadLibraryByUrlParams;
54
+ /** 其他扩展属性 */
27
55
  [key: string]: any;
28
56
  };
57
+ /**
58
+ * 应用管理类
59
+ * @description 负责管理单个应用的生命周期,包括接口、组件、功能的初始化和管理
60
+ * @class Application
61
+ * @author zhiwei.Wang
62
+ */
29
63
  export declare class Application {
64
+ /** 应用配置数据 */
30
65
  options: ApplicationData;
31
- name: ApplicationData["app_name"];
32
- interfaces: Map<ApplicationInterface["page_name"], ApplicationInterface>;
66
+ /** 应用名称 */
67
+ name: ApplicationData['app_name'];
68
+ /** 应用内的页面接口映射表,以页面名称为键 */
69
+ interfaces: Map<ApplicationInterface['page_name'], ApplicationInterface>;
70
+ /** 应用内的组件映射表,以组件编码为键 */
33
71
  components: Map<string, any>;
72
+ /** 应用内的功能函数映射表,比如跳转登录页面的方法等 */
34
73
  functions: Map<string, any>;
74
+ /** 应用实例引用 */
35
75
  app: App;
76
+ /**
77
+ * 构造函数
78
+ * @description 初始化应用实例,设置基本属性并初始化接口和功能
79
+ * @param {ApplicationData} options - 应用配置数据
80
+ * @param {App} app - 应用实例引用
81
+ */
36
82
  constructor(options: ApplicationData, app: App);
37
- afterAdd(application: Application): Promise<void>;
38
- beforeLoad(): Promise<void>;
39
- load(): Promise<void>;
40
- initInterfaces(interfaces: ApplicationData["interfaces"]): void;
41
- initFunctions(functions: ApplicationData["functions"]): void;
83
+ /**
84
+ * 应用添加后的内部处理方法
85
+ * @description 在应用被添加到应用管理器后执行的内部逻辑,包括加载多语言配置和执行用户自定义的afterAdd方法
86
+ * @param {Application} application - 被添加的应用实例
87
+ * @returns {Promise<void>}
88
+ * @private
89
+ */
90
+ _afterAdd(application: Application): Promise<void>;
91
+ /**
92
+ * 应用加载前的内部处理方法
93
+ * @description 在应用开始加载前执行的内部逻辑,调用用户自定义的beforeLoad方法
94
+ * @returns {Promise<void>}
95
+ * @private
96
+ */
97
+ _beforeLoad(): Promise<void>;
98
+ /**
99
+ * 应用加载的内部处理方法
100
+ * @description 执行应用的实际加载逻辑,将应用中的所有接口注册为路由
101
+ * @returns {Promise<void>}
102
+ * @private
103
+ */
104
+ _load(): Promise<void>;
105
+ /**
106
+ * 初始化应用接口
107
+ * @description 遍历应用配置中的接口列表,根据类别将它们分别设置到对应的映射表中
108
+ * @param {ApplicationData['interfaces']} interfaces - 接口配置数组
109
+ * @returns {void}
110
+ */
111
+ initInterfaces(interfaces: ApplicationData['interfaces']): void;
112
+ /**
113
+ * 初始化应用功能函数
114
+ * @description 遍历应用配置中的功能列表,将它们设置到功能映射表中
115
+ * @param {ApplicationData['functions']} functions - 功能配置数组,可选
116
+ * @returns {void}
117
+ */
118
+ initFunctions(functions: ApplicationData['functions']): void;
119
+ /**
120
+ * 加载接口组件
121
+ * @description 根据接口类型加载对应的组件,支持低代码和普通代码两种类型
122
+ * @param {ApplicationInterface} interfaceItem - 接口配置项
123
+ * @returns {Promise<ApplicationInterface>} 加载后的接口配置
124
+ */
42
125
  loadInterface(interfaceItem: ApplicationInterface): Promise<ApplicationInterface>;
126
+ /**
127
+ * 设置页面
128
+ * @description 将页面接口添加到接口映射表中
129
+ * @param {string} code - 页面编码
130
+ * @param {ApplicationInterface} interfaceItem - 接口配置项
131
+ * @returns {void}
132
+ */
43
133
  setInterface(code: string, interfaceItem: ApplicationInterface): void;
134
+ /**
135
+ * 设置组件
136
+ * @description 将组件添加到组件映射表中
137
+ * @param {string} code - 组件编码
138
+ * @param {ApplicationInterface} component - 组件配置项
139
+ * @returns {void}
140
+ */
44
141
  setComponent(code: string, component: ApplicationInterface): void;
142
+ /**
143
+ * 设置功能函数
144
+ * @description 将功能函数添加到功能映射表中
145
+ * @param {string} code - 功能编码
146
+ * @param {ApplicationInterface} functionItem - 功能配置项
147
+ * @returns {void}
148
+ */
45
149
  setFunction(code: string, functionItem: ApplicationInterface): void;
150
+ /**
151
+ * 获取页面
152
+ * @description 根据编码从接口映射表中获取页面接口
153
+ * @param {string} code - 页面编码
154
+ * @returns {ApplicationInterface | undefined} 接口配置项或undefined
155
+ */
46
156
  getInterface(code: string): ApplicationInterface | undefined;
157
+ /**
158
+ * 获取组件
159
+ * @description 根据编码从组件映射表中获取组件
160
+ * @param {string} code - 组件编码
161
+ * @returns {any | undefined} 组件或undefined
162
+ */
47
163
  getComponent(code: string): any;
164
+ /**
165
+ * 获取功能函数
166
+ * @description 根据编码从功能映射表中获取功能函数
167
+ * @param {string} code - 功能编码
168
+ * @returns {any | undefined} 功能函数或undefined
169
+ */
48
170
  getFunction(code: string): any;
171
+ /**
172
+ * 执行功能函数
173
+ * @description 根据编码执行对应的功能函数,自动注入应用实例并合并参数
174
+ * @param {string} code - 功能编码
175
+ * @param {any} params - 传递给功能函数的参数对象,可选
176
+ * @param {...any} args - 传递给功能函数的其他参数
177
+ * @returns {any} 功能函数的执行结果
178
+ */
49
179
  runFunction(code: string, params?: any, ...args: any): any;
180
+ /**
181
+ * 应用添加后触发的钩子函数
182
+ * @description 在应用被添加到应用管理器后触发,可被子类覆盖以实现自定义逻辑
183
+ * @param {Application} application - 被添加的应用实例
184
+ * @returns {Promise<void>}
185
+ * @author zhiwei.Wang
186
+ */
187
+ afterAdd(application: Application): Promise<void>;
188
+ /**
189
+ * 应用加载前触发的钩子函数
190
+ * @description 在应用开始加载前触发,可被子类覆盖以实现自定义预处理逻辑
191
+ * @returns {Promise<void>}
192
+ * @author zhiwei.Wang
193
+ */
194
+ beforeLoad(application: Application): Promise<void>;
195
+ /**
196
+ * 应用加载完成后触发的钩子函数
197
+ * @description 在应用完成加载后触发,可被子类覆盖以实现自定义后处理逻辑
198
+ * @returns {Promise<void>}
199
+ * @author zhiwei.Wang
200
+ */
201
+ load(application: Application): Promise<void>;
50
202
  }