react-native-fxview 1.0.3-beta1 → 1.0.3-beta3
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/FXCategoryController.js +24 -20
- package/FXCategoryController.ts +21 -20
- package/FXView.js +11 -11
- package/FXView.tsx +11 -17
- package/FXViewController.js +21 -17
- package/FXViewController.ts +18 -17
- package/FXViewManager.js +14 -15
- package/FXViewManager.ts +14 -15
- package/logger/FXLogger.d.ts +15 -12
- package/logger/FXLogger.js +34 -32
- package/logger/FXLogger.ts +35 -34
- package/package.json +1 -1
- package/FXViewCategoryController.d.ts +0 -100
- package/FXViewCategoryController.js +0 -270
package/logger/FXLogger.ts
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
/* eslint-disable @typescript-eslint/no-explicit-any */
|
|
1
2
|
// ========== Logger 类型定义 ==========
|
|
2
3
|
|
|
3
4
|
/**
|
|
@@ -18,7 +19,6 @@ export interface FXLoggerConfig {
|
|
|
18
19
|
debug: boolean; // 是否启用调试模式
|
|
19
20
|
level: FXLogLevel; // 日志级别
|
|
20
21
|
showTimestamp: boolean; // 是否显示时间戳
|
|
21
|
-
showTags: boolean; // 是否显示标签
|
|
22
22
|
prefix: string; // 日志前缀
|
|
23
23
|
}
|
|
24
24
|
|
|
@@ -42,7 +42,6 @@ export class FXLogger {
|
|
|
42
42
|
debug: isDevelopment, // 开发环境启用调试模式,生产环境禁用
|
|
43
43
|
level: isDevelopment ? FXLogLevel.DEBUG : FXLogLevel.ERROR, // 生产环境只显示错误日志
|
|
44
44
|
showTimestamp: true,
|
|
45
|
-
showTags: true,
|
|
46
45
|
prefix: isDevelopment ? "[FX-DEV]" : "[FX-PROD]", // 不同环境使用不同前缀
|
|
47
46
|
};
|
|
48
47
|
}
|
|
@@ -90,7 +89,7 @@ export class FXLogger {
|
|
|
90
89
|
}
|
|
91
90
|
} catch (error) {
|
|
92
91
|
// 如果检测过程中出错,默认返回 false(生产环境)
|
|
93
|
-
this.error("
|
|
92
|
+
this.error("Environment detection failed", error);
|
|
94
93
|
}
|
|
95
94
|
|
|
96
95
|
// 默认返回 false(生产环境)
|
|
@@ -171,7 +170,7 @@ export class FXLogger {
|
|
|
171
170
|
/**
|
|
172
171
|
* 格式化日志消息
|
|
173
172
|
*/
|
|
174
|
-
private formatMessage(level: string,
|
|
173
|
+
private formatMessage(level: string, message: string): string {
|
|
175
174
|
const parts: string[] = [];
|
|
176
175
|
|
|
177
176
|
if (this.config.prefix) {
|
|
@@ -188,89 +187,91 @@ export class FXLogger {
|
|
|
188
187
|
const colorSymbol = this.getLevelColor(levelEnum);
|
|
189
188
|
parts.push(`[${colorSymbol}${level.toUpperCase()}]`);
|
|
190
189
|
|
|
191
|
-
if (this.config.showTags && tag) {
|
|
192
|
-
parts.push(`[${tag}]`);
|
|
193
|
-
}
|
|
194
|
-
|
|
195
190
|
return parts.join("") + " " + message;
|
|
196
191
|
}
|
|
197
192
|
|
|
198
193
|
/**
|
|
199
194
|
* 调试日志
|
|
200
195
|
*/
|
|
201
|
-
|
|
196
|
+
log(message?: any, ...optionalParams: any[]): void {
|
|
202
197
|
if (!this.shouldLog(FXLogLevel.DEBUG)) return;
|
|
203
198
|
|
|
204
|
-
const formattedMessage = this.formatMessage("debug",
|
|
205
|
-
console.log(formattedMessage, ...
|
|
199
|
+
const formattedMessage = this.formatMessage("debug", message);
|
|
200
|
+
console.log(formattedMessage, ...optionalParams);
|
|
206
201
|
}
|
|
207
202
|
|
|
208
203
|
/**
|
|
209
204
|
* 信息日志
|
|
210
205
|
*/
|
|
211
|
-
info(
|
|
206
|
+
info(message?: any, ...optionalParams: any[]): void {
|
|
212
207
|
if (!this.shouldLog(FXLogLevel.INFO)) return;
|
|
213
208
|
|
|
214
|
-
const formattedMessage = this.formatMessage("info",
|
|
215
|
-
console.info(formattedMessage, ...
|
|
209
|
+
const formattedMessage = this.formatMessage("info", message);
|
|
210
|
+
console.info(formattedMessage, ...optionalParams);
|
|
216
211
|
}
|
|
217
212
|
|
|
218
213
|
/**
|
|
219
214
|
* 警告日志
|
|
220
215
|
*/
|
|
221
|
-
warn(
|
|
216
|
+
warn(message?: any, ...optionalParams: any[]): void {
|
|
222
217
|
if (!this.shouldLog(FXLogLevel.WARN)) return;
|
|
223
218
|
|
|
224
|
-
const formattedMessage = this.formatMessage("warn",
|
|
225
|
-
console.warn(formattedMessage, ...
|
|
219
|
+
const formattedMessage = this.formatMessage("warn", message);
|
|
220
|
+
console.warn(formattedMessage, ...optionalParams);
|
|
226
221
|
}
|
|
227
222
|
|
|
228
223
|
/**
|
|
229
224
|
* 错误日志
|
|
230
225
|
*/
|
|
231
|
-
error(
|
|
226
|
+
error(message?: any, ...optionalParams: any[]): void {
|
|
232
227
|
if (!this.shouldLog(FXLogLevel.ERROR)) return;
|
|
233
228
|
|
|
234
|
-
const formattedMessage = this.formatMessage("error",
|
|
235
|
-
console.error(formattedMessage, ...
|
|
229
|
+
const formattedMessage = this.formatMessage("error", message);
|
|
230
|
+
console.error(formattedMessage, ...optionalParams);
|
|
236
231
|
}
|
|
237
232
|
|
|
238
233
|
/**
|
|
239
|
-
*
|
|
234
|
+
* 追踪日志
|
|
240
235
|
*/
|
|
241
|
-
|
|
236
|
+
trace(message?: any, ...optionalParams: any[]): void {
|
|
242
237
|
if (!this.shouldLog(FXLogLevel.DEBUG)) return;
|
|
243
238
|
|
|
244
|
-
const
|
|
245
|
-
console.
|
|
239
|
+
const formattedMessage = this.formatMessage("trace", message);
|
|
240
|
+
console.trace(formattedMessage, ...optionalParams);
|
|
246
241
|
}
|
|
247
242
|
|
|
248
243
|
/**
|
|
249
|
-
*
|
|
244
|
+
* 表格日志
|
|
250
245
|
*/
|
|
251
|
-
|
|
246
|
+
table(...data: any[]): void {
|
|
252
247
|
if (!this.shouldLog(FXLogLevel.DEBUG)) return;
|
|
253
248
|
|
|
254
|
-
console.
|
|
249
|
+
console.table(...data);
|
|
255
250
|
}
|
|
256
251
|
|
|
257
252
|
/**
|
|
258
|
-
*
|
|
253
|
+
* 分组日志
|
|
259
254
|
*/
|
|
260
|
-
|
|
255
|
+
group(label?: string): void {
|
|
261
256
|
if (!this.shouldLog(FXLogLevel.DEBUG)) return;
|
|
262
257
|
|
|
263
|
-
console.
|
|
264
|
-
console.table(data);
|
|
258
|
+
console.group(label);
|
|
265
259
|
}
|
|
266
260
|
|
|
267
261
|
/**
|
|
268
|
-
*
|
|
262
|
+
* 结束分组日志
|
|
263
|
+
*/
|
|
264
|
+
groupEnd(): void {
|
|
265
|
+
console.groupEnd();
|
|
266
|
+
}
|
|
267
|
+
|
|
268
|
+
/**
|
|
269
|
+
* 折叠分组日志
|
|
269
270
|
*/
|
|
270
|
-
|
|
271
|
+
groupCollapsed(label?: string): void {
|
|
271
272
|
if (!this.shouldLog(FXLogLevel.DEBUG)) return;
|
|
272
273
|
|
|
273
|
-
console.
|
|
274
|
+
console.groupCollapsed(label);
|
|
274
275
|
}
|
|
275
276
|
}
|
|
276
277
|
|
package/package.json
CHANGED
|
@@ -1,100 +0,0 @@
|
|
|
1
|
-
import React from "react";
|
|
2
|
-
import { ComponentItem, ComponentController } from "./types";
|
|
3
|
-
export declare class FXViewCategoryController {
|
|
4
|
-
fxViewId: string;
|
|
5
|
-
categoryId: string;
|
|
6
|
-
private updateCallback?;
|
|
7
|
-
private componentMap;
|
|
8
|
-
private componentQueue;
|
|
9
|
-
constructor(fxViewId: string, categoryId: string, triggerUpdate?: () => void);
|
|
10
|
-
/**
|
|
11
|
-
* 创建并展示组件
|
|
12
|
-
* @param component 要显示的组件
|
|
13
|
-
* @param componentId 可选的组件 ID
|
|
14
|
-
* @returns 组件控制器
|
|
15
|
-
*/
|
|
16
|
-
add(component: React.ReactNode, componentId?: string): ComponentController;
|
|
17
|
-
/**
|
|
18
|
-
* 创建但不显示组件
|
|
19
|
-
* @param component 要创建的组件
|
|
20
|
-
* @param componentId 可选的组件 ID
|
|
21
|
-
* @returns 组件控制器
|
|
22
|
-
*/
|
|
23
|
-
build(component: React.ReactNode, componentId?: string): ComponentController;
|
|
24
|
-
/**
|
|
25
|
-
* 显示已存在的组件
|
|
26
|
-
* @param componentId 组件 ID
|
|
27
|
-
*/
|
|
28
|
-
show(componentId: string): void;
|
|
29
|
-
/**
|
|
30
|
-
* 隐藏但不删除组件
|
|
31
|
-
* @param componentId 组件 ID
|
|
32
|
-
*/
|
|
33
|
-
hide(componentId: string): void;
|
|
34
|
-
/**
|
|
35
|
-
* 更新组件内容
|
|
36
|
-
* @param componentId 组件 ID
|
|
37
|
-
* @param component 新的组件内容
|
|
38
|
-
*/
|
|
39
|
-
update(componentId: string, component: React.ReactNode): void;
|
|
40
|
-
/**
|
|
41
|
-
* 彻底删除组件
|
|
42
|
-
* @param componentId 组件 ID(必需)
|
|
43
|
-
*/
|
|
44
|
-
remove(componentId: string): void;
|
|
45
|
-
/**
|
|
46
|
-
* 移除最后一个组件(可选:用于向后兼容)
|
|
47
|
-
*/
|
|
48
|
-
removeLast(): void;
|
|
49
|
-
/**
|
|
50
|
-
* 清空所有组件
|
|
51
|
-
*/
|
|
52
|
-
clearAll(): void;
|
|
53
|
-
/**
|
|
54
|
-
* 注册更新回调
|
|
55
|
-
* @param updateCallback 更新回调函数
|
|
56
|
-
*/
|
|
57
|
-
registerUpdateCallback(updateCallback?: () => void): void;
|
|
58
|
-
/**
|
|
59
|
-
* 获取组件列表
|
|
60
|
-
* @returns 组件列表
|
|
61
|
-
*/
|
|
62
|
-
getComponents(): ComponentItem[];
|
|
63
|
-
/**
|
|
64
|
-
* 获取组件数量
|
|
65
|
-
* @returns 组件数量
|
|
66
|
-
*/
|
|
67
|
-
getComponentCount(): number;
|
|
68
|
-
/**
|
|
69
|
-
* 获取可见组件数量
|
|
70
|
-
* @returns 可见组件数量
|
|
71
|
-
*/
|
|
72
|
-
getVisibleComponentCount(): number;
|
|
73
|
-
/**
|
|
74
|
-
* 检查组件是否存在
|
|
75
|
-
* @param componentId 组件 ID
|
|
76
|
-
* @returns 是否存在
|
|
77
|
-
*/
|
|
78
|
-
hasComponent(componentId: string): boolean;
|
|
79
|
-
/**
|
|
80
|
-
* 检查组件是否可见
|
|
81
|
-
* @param componentId 组件 ID
|
|
82
|
-
* @returns 是否可见
|
|
83
|
-
*/
|
|
84
|
-
isVisible(componentId: string): boolean;
|
|
85
|
-
/**
|
|
86
|
-
* 触发更新
|
|
87
|
-
*/
|
|
88
|
-
private triggerUpdate;
|
|
89
|
-
/**
|
|
90
|
-
* 创建组件控制器
|
|
91
|
-
* @param componentId 组件 ID
|
|
92
|
-
* @returns 组件控制器
|
|
93
|
-
*/
|
|
94
|
-
private createController;
|
|
95
|
-
/**
|
|
96
|
-
* 自动生成 componentId
|
|
97
|
-
* @returns 生成的 componentId
|
|
98
|
-
*/
|
|
99
|
-
private autoComponentId;
|
|
100
|
-
}
|
|
@@ -1,270 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.FXViewCategoryController = void 0;
|
|
4
|
-
const PriorityQueue_1 = require("./queue/PriorityQueue");
|
|
5
|
-
class FXViewCategoryController {
|
|
6
|
-
constructor(fxViewId, categoryId, triggerUpdate) {
|
|
7
|
-
// 存储组件的 Map 和优先队列
|
|
8
|
-
this.componentMap = new Map();
|
|
9
|
-
this.componentQueue = new PriorityQueue_1.PriorityQueue(PriorityQueue_1.HeapType.MAX_HEAP, PriorityQueue_1.PriorityOrder.FIFO);
|
|
10
|
-
this.fxViewId = fxViewId;
|
|
11
|
-
this.categoryId = categoryId;
|
|
12
|
-
this.updateCallback = triggerUpdate;
|
|
13
|
-
}
|
|
14
|
-
// ========== 主要 API 方法 ==========
|
|
15
|
-
/**
|
|
16
|
-
* 创建并展示组件
|
|
17
|
-
* @param component 要显示的组件
|
|
18
|
-
* @param componentId 可选的组件 ID
|
|
19
|
-
* @returns 组件控制器
|
|
20
|
-
*/
|
|
21
|
-
add(component, componentId) {
|
|
22
|
-
console.log(`FXViewCategoryController.add`, `[${this.categoryId}]`, componentId);
|
|
23
|
-
const finalComponentId = componentId || this.autoComponentId();
|
|
24
|
-
// 如果组件已存在,先移除旧的
|
|
25
|
-
if (this.componentMap.has(finalComponentId)) {
|
|
26
|
-
console.warn(`Component ${finalComponentId} already exists, removing old one`);
|
|
27
|
-
this.remove(finalComponentId);
|
|
28
|
-
}
|
|
29
|
-
const componentItem = {
|
|
30
|
-
componentId: finalComponentId,
|
|
31
|
-
component,
|
|
32
|
-
visible: true, // add 方法默认可见
|
|
33
|
-
};
|
|
34
|
-
this.componentMap.set(finalComponentId, componentItem);
|
|
35
|
-
this.componentQueue.enqueue(componentItem);
|
|
36
|
-
this.triggerUpdate();
|
|
37
|
-
return this.createController(finalComponentId);
|
|
38
|
-
}
|
|
39
|
-
/**
|
|
40
|
-
* 创建但不显示组件
|
|
41
|
-
* @param component 要创建的组件
|
|
42
|
-
* @param componentId 可选的组件 ID
|
|
43
|
-
* @returns 组件控制器
|
|
44
|
-
*/
|
|
45
|
-
build(component, componentId) {
|
|
46
|
-
console.log(`FXViewCategoryController.build`, `[${this.categoryId}]`, componentId);
|
|
47
|
-
const finalComponentId = componentId || this.autoComponentId();
|
|
48
|
-
// 如果组件已存在,先移除旧的
|
|
49
|
-
if (this.componentMap.has(finalComponentId)) {
|
|
50
|
-
console.warn(`Component ${finalComponentId} already exists, removing old one`);
|
|
51
|
-
this.remove(finalComponentId);
|
|
52
|
-
}
|
|
53
|
-
const componentItem = {
|
|
54
|
-
componentId: finalComponentId,
|
|
55
|
-
component,
|
|
56
|
-
visible: false, // build 方法默认不可见
|
|
57
|
-
};
|
|
58
|
-
this.componentMap.set(finalComponentId, componentItem);
|
|
59
|
-
this.componentQueue.enqueue(componentItem);
|
|
60
|
-
// build 不触发更新,因为组件不可见
|
|
61
|
-
// this.triggerUpdate();
|
|
62
|
-
return this.createController(finalComponentId);
|
|
63
|
-
}
|
|
64
|
-
/**
|
|
65
|
-
* 显示已存在的组件
|
|
66
|
-
* @param componentId 组件 ID
|
|
67
|
-
*/
|
|
68
|
-
show(componentId) {
|
|
69
|
-
console.log(`FXViewCategoryController.show`, `[${this.categoryId}]`, componentId);
|
|
70
|
-
const componentItem = this.componentMap.get(componentId);
|
|
71
|
-
if (!componentItem) {
|
|
72
|
-
console.warn(`Component ${componentId} not found in category ${this.categoryId}`);
|
|
73
|
-
return;
|
|
74
|
-
}
|
|
75
|
-
// 如果已经可见,不需要重复操作
|
|
76
|
-
if (componentItem.visible) {
|
|
77
|
-
console.log(`Component ${componentId} is already visible`);
|
|
78
|
-
return;
|
|
79
|
-
}
|
|
80
|
-
componentItem.visible = true;
|
|
81
|
-
this.triggerUpdate();
|
|
82
|
-
}
|
|
83
|
-
/**
|
|
84
|
-
* 隐藏但不删除组件
|
|
85
|
-
* @param componentId 组件 ID
|
|
86
|
-
*/
|
|
87
|
-
hide(componentId) {
|
|
88
|
-
console.log(`FXViewCategoryController.hide`, `[${this.categoryId}]`, componentId);
|
|
89
|
-
const componentItem = this.componentMap.get(componentId);
|
|
90
|
-
if (!componentItem) {
|
|
91
|
-
console.warn(`Component ${componentId} not found in category ${this.categoryId}`);
|
|
92
|
-
return;
|
|
93
|
-
}
|
|
94
|
-
// 如果已经隐藏,不需要重复操作
|
|
95
|
-
if (!componentItem.visible) {
|
|
96
|
-
console.log(`Component ${componentId} is already hidden`);
|
|
97
|
-
return;
|
|
98
|
-
}
|
|
99
|
-
componentItem.visible = false;
|
|
100
|
-
this.triggerUpdate();
|
|
101
|
-
}
|
|
102
|
-
/**
|
|
103
|
-
* 更新组件内容
|
|
104
|
-
* @param componentId 组件 ID
|
|
105
|
-
* @param component 新的组件内容
|
|
106
|
-
*/
|
|
107
|
-
update(componentId, component) {
|
|
108
|
-
console.log(`FXViewCategoryController.update`, `[${this.categoryId}]`, componentId);
|
|
109
|
-
const componentItem = this.componentMap.get(componentId);
|
|
110
|
-
if (!componentItem) {
|
|
111
|
-
console.warn(`Component ${componentId} not found in category ${this.categoryId}`);
|
|
112
|
-
return;
|
|
113
|
-
}
|
|
114
|
-
// 更新组件内容
|
|
115
|
-
componentItem.component = component;
|
|
116
|
-
// 只有在组件可见时才触发更新
|
|
117
|
-
if (componentItem.visible) {
|
|
118
|
-
this.triggerUpdate();
|
|
119
|
-
}
|
|
120
|
-
else {
|
|
121
|
-
console.log(`Component ${componentId} is hidden, update without re-render`);
|
|
122
|
-
}
|
|
123
|
-
}
|
|
124
|
-
/**
|
|
125
|
-
* 彻底删除组件
|
|
126
|
-
* @param componentId 组件 ID(必需)
|
|
127
|
-
*/
|
|
128
|
-
remove(componentId) {
|
|
129
|
-
console.log(`FXViewCategoryController.remove`, `[${this.categoryId}]`, componentId);
|
|
130
|
-
const componentItem = this.componentMap.get(componentId);
|
|
131
|
-
if (!componentItem) {
|
|
132
|
-
console.warn(`Component ${componentId} not found in category ${this.categoryId}`);
|
|
133
|
-
return;
|
|
134
|
-
}
|
|
135
|
-
// 从 Map 中删除
|
|
136
|
-
this.componentMap.delete(componentId);
|
|
137
|
-
// 从优先队列中删除
|
|
138
|
-
this.componentQueue.remove(componentItem);
|
|
139
|
-
this.triggerUpdate();
|
|
140
|
-
}
|
|
141
|
-
/**
|
|
142
|
-
* 移除最后一个组件(可选:用于向后兼容)
|
|
143
|
-
*/
|
|
144
|
-
removeLast() {
|
|
145
|
-
console.log(`FXViewCategoryController.removeLast`, `[${this.categoryId}]`);
|
|
146
|
-
const lastComponent = this.componentQueue.peek();
|
|
147
|
-
if (!lastComponent) {
|
|
148
|
-
console.warn(`No component to remove in category ${this.categoryId}`);
|
|
149
|
-
return;
|
|
150
|
-
}
|
|
151
|
-
this.remove(lastComponent.componentId);
|
|
152
|
-
}
|
|
153
|
-
/**
|
|
154
|
-
* 清空所有组件
|
|
155
|
-
*/
|
|
156
|
-
clearAll() {
|
|
157
|
-
console.log(`FXViewCategoryController.clearAll`, `[${this.categoryId}]`);
|
|
158
|
-
const hadVisibleComponents = Array.from(this.componentMap.values()).some((item) => item.visible);
|
|
159
|
-
this.componentMap.clear();
|
|
160
|
-
this.componentQueue.clear();
|
|
161
|
-
// 只有在有可见组件时才触发更新
|
|
162
|
-
if (hadVisibleComponents) {
|
|
163
|
-
this.triggerUpdate();
|
|
164
|
-
}
|
|
165
|
-
}
|
|
166
|
-
/**
|
|
167
|
-
* 注册更新回调
|
|
168
|
-
* @param updateCallback 更新回调函数
|
|
169
|
-
*/
|
|
170
|
-
registerUpdateCallback(updateCallback) {
|
|
171
|
-
this.updateCallback = updateCallback;
|
|
172
|
-
}
|
|
173
|
-
/**
|
|
174
|
-
* 获取组件列表
|
|
175
|
-
* @returns 组件列表
|
|
176
|
-
*/
|
|
177
|
-
getComponents() {
|
|
178
|
-
return this.componentQueue.getAll();
|
|
179
|
-
}
|
|
180
|
-
/**
|
|
181
|
-
* 获取组件数量
|
|
182
|
-
* @returns 组件数量
|
|
183
|
-
*/
|
|
184
|
-
getComponentCount() {
|
|
185
|
-
return this.componentMap.size;
|
|
186
|
-
}
|
|
187
|
-
/**
|
|
188
|
-
* 获取可见组件数量
|
|
189
|
-
* @returns 可见组件数量
|
|
190
|
-
*/
|
|
191
|
-
getVisibleComponentCount() {
|
|
192
|
-
return Array.from(this.componentMap.values()).filter((item) => item.visible)
|
|
193
|
-
.length;
|
|
194
|
-
}
|
|
195
|
-
/**
|
|
196
|
-
* 检查组件是否存在
|
|
197
|
-
* @param componentId 组件 ID
|
|
198
|
-
* @returns 是否存在
|
|
199
|
-
*/
|
|
200
|
-
hasComponent(componentId) {
|
|
201
|
-
return this.componentMap.has(componentId);
|
|
202
|
-
}
|
|
203
|
-
/**
|
|
204
|
-
* 检查组件是否可见
|
|
205
|
-
* @param componentId 组件 ID
|
|
206
|
-
* @returns 是否可见
|
|
207
|
-
*/
|
|
208
|
-
isVisible(componentId) {
|
|
209
|
-
var _a;
|
|
210
|
-
const component = this.componentMap.get(componentId);
|
|
211
|
-
return (_a = component === null || component === void 0 ? void 0 : component.visible) !== null && _a !== void 0 ? _a : false;
|
|
212
|
-
}
|
|
213
|
-
// ========== 私有方法 ==========
|
|
214
|
-
/**
|
|
215
|
-
* 触发更新
|
|
216
|
-
*/
|
|
217
|
-
triggerUpdate() {
|
|
218
|
-
console.log(`FXViewCategoryController.triggerUpdate`, `[${this.categoryId}]`);
|
|
219
|
-
if (this.updateCallback) {
|
|
220
|
-
this.updateCallback();
|
|
221
|
-
}
|
|
222
|
-
}
|
|
223
|
-
/**
|
|
224
|
-
* 创建组件控制器
|
|
225
|
-
* @param componentId 组件 ID
|
|
226
|
-
* @returns 组件控制器
|
|
227
|
-
*/
|
|
228
|
-
createController(componentId) {
|
|
229
|
-
console.log(`FXViewCategoryController.createController`, `[${this.categoryId}]`, componentId);
|
|
230
|
-
// ✅ 修复:不在闭包中捕获 componentItem,每次都从 Map 获取最新引用
|
|
231
|
-
return {
|
|
232
|
-
show: () => {
|
|
233
|
-
this.show(componentId);
|
|
234
|
-
},
|
|
235
|
-
hide: () => {
|
|
236
|
-
this.hide(componentId);
|
|
237
|
-
},
|
|
238
|
-
remove: () => {
|
|
239
|
-
this.remove(componentId);
|
|
240
|
-
},
|
|
241
|
-
update: (component) => {
|
|
242
|
-
this.update(componentId, component);
|
|
243
|
-
},
|
|
244
|
-
getFxViewId: () => this.fxViewId,
|
|
245
|
-
getCategoryId: () => this.categoryId,
|
|
246
|
-
getComponentId: () => componentId,
|
|
247
|
-
getComponent: () => {
|
|
248
|
-
var _a;
|
|
249
|
-
// ✅ 每次都从 Map 获取最新的组件引用
|
|
250
|
-
return (_a = this.componentMap.get(componentId)) === null || _a === void 0 ? void 0 : _a.component;
|
|
251
|
-
},
|
|
252
|
-
isVisible: () => {
|
|
253
|
-
return this.isVisible(componentId);
|
|
254
|
-
},
|
|
255
|
-
exists: () => {
|
|
256
|
-
return this.hasComponent(componentId);
|
|
257
|
-
},
|
|
258
|
-
};
|
|
259
|
-
}
|
|
260
|
-
/**
|
|
261
|
-
* 自动生成 componentId
|
|
262
|
-
* @returns 生成的 componentId
|
|
263
|
-
*/
|
|
264
|
-
autoComponentId() {
|
|
265
|
-
return `component_${Date.now()}_${Math.random()
|
|
266
|
-
.toString(36)
|
|
267
|
-
.substring(2, 9)}`;
|
|
268
|
-
}
|
|
269
|
-
}
|
|
270
|
-
exports.FXViewCategoryController = FXViewCategoryController;
|