@agions/taroviz 1.1.1 → 1.2.1
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/README.md +324 -53
- package/dist/cjs/index.js +1 -0
- package/dist/esm/index.js +82979 -0
- package/package.json +160 -30
- package/src/__tests__/integration.test.tsx +168 -0
- package/src/adapters/__tests__/index.test.ts +91 -0
- package/src/adapters/h5/__tests__/index.test.ts +156 -0
- package/src/adapters/h5/index.ts +301 -0
- package/src/adapters/harmony/index.ts +274 -0
- package/src/adapters/index.ts +166 -0
- package/src/adapters/swan/index.ts +274 -0
- package/src/adapters/tt/index.ts +274 -0
- package/src/adapters/types.ts +162 -0
- package/src/adapters/weapp/index.ts +237 -0
- package/src/charts/bar/__tests__/index.test.tsx +113 -0
- package/src/charts/bar/index.tsx +18 -0
- package/src/charts/common/BaseChartWrapper.tsx +136 -0
- package/src/charts/funnel/index.tsx +18 -0
- package/src/charts/gauge/index.tsx +18 -0
- package/src/charts/heatmap/index.tsx +18 -0
- package/src/charts/index.ts +21 -0
- package/src/charts/line/__tests__/index.test.tsx +107 -0
- package/src/charts/line/index.tsx +18 -0
- package/src/charts/pie/__tests__/index.test.tsx +112 -0
- package/src/charts/pie/index.tsx +19 -0
- package/src/charts/radar/index.tsx +18 -0
- package/src/charts/scatter/index.tsx +18 -0
- package/src/charts/types.ts +619 -0
- package/src/charts/utils.ts +56 -0
- package/src/core/__tests__/platform.test.ts +48 -0
- package/src/core/animation/AnimationManager.ts +391 -0
- package/src/core/animation/index.ts +20 -0
- package/src/core/animation/types.ts +248 -0
- package/src/core/components/BaseChart.tsx +1313 -0
- package/src/core/components/ErrorBoundary.tsx +458 -0
- package/src/core/echarts.ts +58 -0
- package/src/core/index.ts +22 -0
- package/src/core/types/chart.ts +66 -0
- package/src/core/types/common.ts +224 -0
- package/src/core/types/index.ts +281 -0
- package/src/core/types/platform.ts +325 -0
- package/src/core/utils/__tests__/common.test.ts +52 -0
- package/src/core/utils/__tests__/environment.test.ts +94 -0
- package/src/core/utils/__tests__/i18n.test.ts +247 -0
- package/src/core/utils/__tests__/index.test.ts +219 -0
- package/src/core/utils/__tests__/uuid.test.ts +78 -0
- package/src/core/utils/chartInstances.ts +69 -0
- package/src/core/utils/codeGenerator/CodeGenerator.ts +655 -0
- package/src/core/utils/codeGenerator/index.ts +13 -0
- package/src/core/utils/codeGenerator/types.ts +198 -0
- package/src/core/utils/common.ts +58 -0
- package/src/core/utils/configGenerator/ConfigGenerator.ts +583 -0
- package/src/core/utils/configGenerator/index.ts +13 -0
- package/src/core/utils/configGenerator/types.ts +445 -0
- package/src/core/utils/debug/DebugPanel.tsx +637 -0
- package/src/core/utils/debug/debugger.ts +322 -0
- package/src/core/utils/debug/index.ts +21 -0
- package/src/core/utils/debug/types.ts +142 -0
- package/src/core/utils/i18n.ts +452 -0
- package/src/core/utils/index.ts +162 -0
- package/src/core/utils/performance/PerformanceAnalyzer.ts +586 -0
- package/src/core/utils/performance/index.ts +13 -0
- package/src/core/utils/performance/types.ts +180 -0
- package/src/core/utils/uuid.ts +30 -0
- package/src/editor/ThemeEditor.tsx +449 -0
- package/src/editor/index.ts +10 -0
- package/src/hooks/__tests__/index.test.tsx +333 -0
- package/src/hooks/index.ts +594 -0
- package/src/index.ts +75 -0
- package/src/main.tsx +247 -0
- package/src/react-dom.d.ts +7 -0
- package/src/themes/__tests__/index.test.ts +91 -0
- package/src/themes/index.ts +860 -0
- package/dist/389.index.esm.js +0 -1
- package/dist/389.index.js +0 -1
- package/dist/633.index.esm.js +0 -1
- package/dist/633.index.js +0 -1
- package/dist/967.index.esm.js +0 -1
- package/dist/967.index.js +0 -1
- package/dist/index.esm.js +0 -1
- package/dist/index.js +0 -1
|
@@ -0,0 +1,637 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* TaroViz 调试面板组件
|
|
3
|
+
* 提供图表调试和监控功能
|
|
4
|
+
*/
|
|
5
|
+
import React, { useState, useRef } from 'react';
|
|
6
|
+
|
|
7
|
+
import { DebugPanelOptions, DebugTabType, DebugInfo, DebugPanelEventType } from './types';
|
|
8
|
+
|
|
9
|
+
/**
|
|
10
|
+
* 调试面板组件属性
|
|
11
|
+
*/
|
|
12
|
+
export interface DebugPanelProps {
|
|
13
|
+
/**
|
|
14
|
+
* 调试信息
|
|
15
|
+
*/
|
|
16
|
+
debugInfo: DebugInfo;
|
|
17
|
+
|
|
18
|
+
/**
|
|
19
|
+
* 调试面板选项
|
|
20
|
+
*/
|
|
21
|
+
options?: DebugPanelOptions;
|
|
22
|
+
|
|
23
|
+
/**
|
|
24
|
+
* 事件处理函数
|
|
25
|
+
*/
|
|
26
|
+
onEvent?: (event: { type: DebugPanelEventType; data?: any }) => void;
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
/**
|
|
30
|
+
* 调试面板组件
|
|
31
|
+
*/
|
|
32
|
+
export const DebugPanel: React.FC<DebugPanelProps> = ({ debugInfo, options = {}, onEvent }) => {
|
|
33
|
+
const [isExpanded, setIsExpanded] = useState(options.autoExpand || false);
|
|
34
|
+
const [activeTab, setActiveTab] = useState<DebugTabType>(options.defaultTab || 'instance');
|
|
35
|
+
const panelRef = useRef<HTMLDivElement>(null);
|
|
36
|
+
|
|
37
|
+
const { position = 'bottom-right', width = 400, height = 300 } = options;
|
|
38
|
+
|
|
39
|
+
/**
|
|
40
|
+
* 切换面板展开状态
|
|
41
|
+
*/
|
|
42
|
+
const togglePanel = () => {
|
|
43
|
+
const newState = !isExpanded;
|
|
44
|
+
setIsExpanded(newState);
|
|
45
|
+
onEvent?.({ type: newState ? DebugPanelEventType.PANEL_SHOW : DebugPanelEventType.PANEL_HIDE });
|
|
46
|
+
};
|
|
47
|
+
|
|
48
|
+
/**
|
|
49
|
+
* 切换标签页
|
|
50
|
+
*/
|
|
51
|
+
const switchTab = (tab: DebugTabType) => {
|
|
52
|
+
setActiveTab(tab);
|
|
53
|
+
onEvent?.({ type: DebugPanelEventType.TAB_CHANGE, data: { tab } });
|
|
54
|
+
};
|
|
55
|
+
|
|
56
|
+
/**
|
|
57
|
+
* 渲染标签页内容
|
|
58
|
+
*/
|
|
59
|
+
const renderTabContent = () => {
|
|
60
|
+
switch (activeTab) {
|
|
61
|
+
case 'instance':
|
|
62
|
+
return renderInstanceTab();
|
|
63
|
+
case 'config':
|
|
64
|
+
return renderConfigTab();
|
|
65
|
+
case 'data':
|
|
66
|
+
return renderDataTab();
|
|
67
|
+
case 'performance':
|
|
68
|
+
return renderPerformanceTab();
|
|
69
|
+
case 'events':
|
|
70
|
+
return renderEventsTab();
|
|
71
|
+
case 'errors':
|
|
72
|
+
return renderErrorsTab();
|
|
73
|
+
case 'tools':
|
|
74
|
+
return renderToolsTab();
|
|
75
|
+
default:
|
|
76
|
+
return <div>未知标签页</div>;
|
|
77
|
+
}
|
|
78
|
+
};
|
|
79
|
+
|
|
80
|
+
/**
|
|
81
|
+
* 渲染实例信息标签页
|
|
82
|
+
*/
|
|
83
|
+
const renderInstanceTab = () => {
|
|
84
|
+
const { instance } = debugInfo;
|
|
85
|
+
|
|
86
|
+
return (
|
|
87
|
+
<div style={styles.debugPanelContent}>
|
|
88
|
+
<h3 style={styles.h3}>图表实例信息</h3>
|
|
89
|
+
<div style={styles.debugInfoGrid}>
|
|
90
|
+
<div style={styles.debugInfoItem}>
|
|
91
|
+
<span style={styles.debugInfoLabel}>ID:</span>
|
|
92
|
+
<span style={styles.debugInfoValue}>{instance?.id || 'N/A'}</span>
|
|
93
|
+
</div>
|
|
94
|
+
<div style={styles.debugInfoItem}>
|
|
95
|
+
<span style={styles.debugInfoLabel}>类型:</span>
|
|
96
|
+
<span style={styles.debugInfoValue}>{instance?.type || 'N/A'}</span>
|
|
97
|
+
</div>
|
|
98
|
+
<div style={styles.debugInfoItem}>
|
|
99
|
+
<span style={styles.debugInfoLabel}>版本:</span>
|
|
100
|
+
<span style={styles.debugInfoValue}>{instance?.version || 'N/A'}</span>
|
|
101
|
+
</div>
|
|
102
|
+
<div style={styles.debugInfoItem}>
|
|
103
|
+
<span style={styles.debugInfoLabel}>渲染器:</span>
|
|
104
|
+
<span style={styles.debugInfoValue}>{instance?.renderer || 'N/A'}</span>
|
|
105
|
+
</div>
|
|
106
|
+
<div style={styles.debugInfoItem}>
|
|
107
|
+
<span style={styles.debugInfoLabel}>宽度:</span>
|
|
108
|
+
<span style={styles.debugInfoValue}>{instance?.width || 'N/A'}px</span>
|
|
109
|
+
</div>
|
|
110
|
+
<div style={styles.debugInfoItem}>
|
|
111
|
+
<span style={styles.debugInfoLabel}>高度:</span>
|
|
112
|
+
<span style={styles.debugInfoValue}>{instance?.height || 'N/A'}px</span>
|
|
113
|
+
</div>
|
|
114
|
+
<div style={styles.debugInfoItem}>
|
|
115
|
+
<span style={styles.debugInfoLabel}>平台:</span>
|
|
116
|
+
<span style={styles.debugInfoValue}>{instance?.platform || 'N/A'}</span>
|
|
117
|
+
</div>
|
|
118
|
+
</div>
|
|
119
|
+
</div>
|
|
120
|
+
);
|
|
121
|
+
};
|
|
122
|
+
|
|
123
|
+
/**
|
|
124
|
+
* 渲染配置信息标签页
|
|
125
|
+
*/
|
|
126
|
+
const renderConfigTab = () => {
|
|
127
|
+
const { config } = debugInfo;
|
|
128
|
+
|
|
129
|
+
return (
|
|
130
|
+
<div style={styles.debugPanelContent}>
|
|
131
|
+
<h3 style={styles.h3}>配置信息</h3>
|
|
132
|
+
<div style={styles.debugConfig}>
|
|
133
|
+
<pre style={styles.pre}>{JSON.stringify(config, null, 2)}</pre>
|
|
134
|
+
</div>
|
|
135
|
+
</div>
|
|
136
|
+
);
|
|
137
|
+
};
|
|
138
|
+
|
|
139
|
+
/**
|
|
140
|
+
* 渲染数据信息标签页
|
|
141
|
+
*/
|
|
142
|
+
const renderDataTab = () => {
|
|
143
|
+
const { data } = debugInfo;
|
|
144
|
+
|
|
145
|
+
return (
|
|
146
|
+
<div style={styles.debugPanelContent}>
|
|
147
|
+
<h3 style={styles.h3}>数据信息</h3>
|
|
148
|
+
<div style={styles.debugInfoGrid}>
|
|
149
|
+
<div style={styles.debugInfoItem}>
|
|
150
|
+
<span style={styles.debugInfoLabel}>系列数量:</span>
|
|
151
|
+
<span style={styles.debugInfoValue}>{data?.series?.length || 0}</span>
|
|
152
|
+
</div>
|
|
153
|
+
<div style={styles.debugInfoItem}>
|
|
154
|
+
<span style={styles.debugInfoLabel}>总数据量:</span>
|
|
155
|
+
<span style={styles.debugInfoValue}>{data?.totalDataCount || 0}</span>
|
|
156
|
+
</div>
|
|
157
|
+
<div style={styles.debugInfoItem}>
|
|
158
|
+
<span style={styles.debugInfoLabel}>当前数据量:</span>
|
|
159
|
+
<span style={styles.debugInfoValue}>{data?.currentDataCount || 0}</span>
|
|
160
|
+
</div>
|
|
161
|
+
</div>
|
|
162
|
+
<div style={styles.debugDataSeries}>
|
|
163
|
+
<h4 style={styles.h4}>系列数据</h4>
|
|
164
|
+
{data?.series?.map((series, index) => (
|
|
165
|
+
<div key={index} style={styles.debugDataSeriesItem}>
|
|
166
|
+
<h5 style={styles.h5}>
|
|
167
|
+
系列 {index + 1}: {series.name || '未命名'}
|
|
168
|
+
</h5>
|
|
169
|
+
<pre style={styles.pre}>{JSON.stringify(series.data?.slice(0, 5), null, 2)}...</pre>
|
|
170
|
+
<div style={styles.debugSeriesInfo}>
|
|
171
|
+
<span>数据量: {series.data?.length || 0}</span>
|
|
172
|
+
</div>
|
|
173
|
+
</div>
|
|
174
|
+
))}
|
|
175
|
+
</div>
|
|
176
|
+
</div>
|
|
177
|
+
);
|
|
178
|
+
};
|
|
179
|
+
|
|
180
|
+
/**
|
|
181
|
+
* 渲染性能信息标签页
|
|
182
|
+
*/
|
|
183
|
+
const renderPerformanceTab = () => {
|
|
184
|
+
const { performance } = debugInfo;
|
|
185
|
+
|
|
186
|
+
return (
|
|
187
|
+
<div style={styles.debugPanelContent}>
|
|
188
|
+
<h3 style={styles.h3}>性能信息</h3>
|
|
189
|
+
<div style={styles.debugInfoGrid}>
|
|
190
|
+
<div style={styles.debugInfoItem}>
|
|
191
|
+
<span style={styles.debugInfoLabel}>初始化时间:</span>
|
|
192
|
+
<span style={styles.debugInfoValue}>{performance?.initTime || 0}ms</span>
|
|
193
|
+
</div>
|
|
194
|
+
<div style={styles.debugInfoItem}>
|
|
195
|
+
<span style={styles.debugInfoLabel}>渲染时间:</span>
|
|
196
|
+
<span style={styles.debugInfoValue}>{performance?.renderTime || 0}ms</span>
|
|
197
|
+
</div>
|
|
198
|
+
<div style={styles.debugInfoItem}>
|
|
199
|
+
<span style={styles.debugInfoLabel}>更新时间:</span>
|
|
200
|
+
<span style={styles.debugInfoValue}>{performance?.updateTime || 0}ms</span>
|
|
201
|
+
</div>
|
|
202
|
+
<div style={styles.debugInfoItem}>
|
|
203
|
+
<span style={styles.debugInfoLabel}>数据大小:</span>
|
|
204
|
+
<span style={styles.debugInfoValue}>{performance?.dataSize || 0} bytes</span>
|
|
205
|
+
</div>
|
|
206
|
+
<div style={styles.debugInfoItem}>
|
|
207
|
+
<span style={styles.debugInfoLabel}>帧率:</span>
|
|
208
|
+
<span style={styles.debugInfoValue}>{performance?.frameRate || 0} FPS</span>
|
|
209
|
+
</div>
|
|
210
|
+
</div>
|
|
211
|
+
<div style={styles.debugPerformanceChart}>{/* 这里可以添加性能图表 */}</div>
|
|
212
|
+
</div>
|
|
213
|
+
);
|
|
214
|
+
};
|
|
215
|
+
|
|
216
|
+
/**
|
|
217
|
+
* 渲染事件信息标签页
|
|
218
|
+
*/
|
|
219
|
+
const renderEventsTab = () => {
|
|
220
|
+
const { events } = debugInfo;
|
|
221
|
+
|
|
222
|
+
return (
|
|
223
|
+
<div style={styles.debugPanelContent}>
|
|
224
|
+
<h3 style={styles.h3}>事件信息</h3>
|
|
225
|
+
<div style={styles.debugEventsList}>
|
|
226
|
+
{events
|
|
227
|
+
?.slice()
|
|
228
|
+
.reverse()
|
|
229
|
+
.map((event, index) => (
|
|
230
|
+
<div key={index} style={styles.debugEventItem}>
|
|
231
|
+
<div style={styles.debugEventHeader}>
|
|
232
|
+
<span style={styles.debugEventType}>{event.type}</span>
|
|
233
|
+
<span style={styles.debugEventTime}>
|
|
234
|
+
{new Date(event.timestamp).toLocaleTimeString()}
|
|
235
|
+
</span>
|
|
236
|
+
</div>
|
|
237
|
+
<div style={styles.debugEventParams}>
|
|
238
|
+
<pre style={styles.pre}>{JSON.stringify(event.params, null, 2)}</pre>
|
|
239
|
+
</div>
|
|
240
|
+
</div>
|
|
241
|
+
))}
|
|
242
|
+
{(!events || events.length === 0) && (
|
|
243
|
+
<div style={styles.debugEmptyState}>暂无事件记录</div>
|
|
244
|
+
)}
|
|
245
|
+
</div>
|
|
246
|
+
</div>
|
|
247
|
+
);
|
|
248
|
+
};
|
|
249
|
+
|
|
250
|
+
/**
|
|
251
|
+
* 渲染错误信息标签页
|
|
252
|
+
*/
|
|
253
|
+
const renderErrorsTab = () => {
|
|
254
|
+
const { errors } = debugInfo;
|
|
255
|
+
|
|
256
|
+
return (
|
|
257
|
+
<div style={styles.debugPanelContent}>
|
|
258
|
+
<h3 style={styles.h3}>错误信息</h3>
|
|
259
|
+
<div style={styles.debugErrorsList}>
|
|
260
|
+
{errors
|
|
261
|
+
?.slice()
|
|
262
|
+
.reverse()
|
|
263
|
+
.map((error, index) => (
|
|
264
|
+
<div key={index} style={styles.debugErrorItem}>
|
|
265
|
+
<div style={styles.debugErrorHeader}>
|
|
266
|
+
<span style={styles.debugErrorType}>{error.type}</span>
|
|
267
|
+
<span style={styles.debugErrorTime}>
|
|
268
|
+
{new Date(error.timestamp).toLocaleTimeString()}
|
|
269
|
+
</span>
|
|
270
|
+
</div>
|
|
271
|
+
<div style={styles.debugErrorMessage}>{error.message}</div>
|
|
272
|
+
{error.stack && (
|
|
273
|
+
<div style={styles.debugErrorStack}>
|
|
274
|
+
<pre style={styles.pre}>{error.stack}</pre>
|
|
275
|
+
</div>
|
|
276
|
+
)}
|
|
277
|
+
</div>
|
|
278
|
+
))}
|
|
279
|
+
{(!errors || errors.length === 0) && (
|
|
280
|
+
<div style={styles.debugEmptyState}>暂无错误记录</div>
|
|
281
|
+
)}
|
|
282
|
+
</div>
|
|
283
|
+
</div>
|
|
284
|
+
);
|
|
285
|
+
};
|
|
286
|
+
|
|
287
|
+
/**
|
|
288
|
+
* 渲染工具标签页
|
|
289
|
+
*/
|
|
290
|
+
const renderToolsTab = () => {
|
|
291
|
+
return (
|
|
292
|
+
<div style={styles.debugPanelContent}>
|
|
293
|
+
<h3 style={styles.h3}>调试工具</h3>
|
|
294
|
+
<div style={styles.debugToolsGrid}>
|
|
295
|
+
<button style={styles.debugToolButton}>导出配置</button>
|
|
296
|
+
<button style={styles.debugToolButton}>导出数据</button>
|
|
297
|
+
<button style={styles.debugToolButton}>刷新图表</button>
|
|
298
|
+
<button style={styles.debugToolButton}>清空数据</button>
|
|
299
|
+
<button style={styles.debugToolButton}>性能分析</button>
|
|
300
|
+
<button style={styles.debugToolButton}>重置图表</button>
|
|
301
|
+
</div>
|
|
302
|
+
</div>
|
|
303
|
+
);
|
|
304
|
+
};
|
|
305
|
+
|
|
306
|
+
// 构建面板样式
|
|
307
|
+
const panelStyle: React.CSSProperties = {
|
|
308
|
+
position: 'fixed',
|
|
309
|
+
zIndex: 9999,
|
|
310
|
+
backgroundColor: 'rgba(255, 255, 255, 0.95)',
|
|
311
|
+
border: '1px solid #e0e0e0',
|
|
312
|
+
borderRadius: '4px',
|
|
313
|
+
boxShadow: '0 2px 12px 0 rgba(0, 0, 0, 0.1)',
|
|
314
|
+
fontFamily: 'monospace',
|
|
315
|
+
fontSize: '12px',
|
|
316
|
+
overflow: 'hidden',
|
|
317
|
+
...(position === 'top-left' && {
|
|
318
|
+
top: '10px',
|
|
319
|
+
left: '10px',
|
|
320
|
+
}),
|
|
321
|
+
...(position === 'top-right' && {
|
|
322
|
+
top: '10px',
|
|
323
|
+
right: '10px',
|
|
324
|
+
}),
|
|
325
|
+
...(position === 'bottom-left' && {
|
|
326
|
+
bottom: '10px',
|
|
327
|
+
left: '10px',
|
|
328
|
+
}),
|
|
329
|
+
...(position === 'bottom-right' && {
|
|
330
|
+
bottom: '10px',
|
|
331
|
+
right: '10px',
|
|
332
|
+
}),
|
|
333
|
+
...(isExpanded && {
|
|
334
|
+
width,
|
|
335
|
+
height,
|
|
336
|
+
}),
|
|
337
|
+
...styles.tarovizDebugPanel,
|
|
338
|
+
};
|
|
339
|
+
|
|
340
|
+
return (
|
|
341
|
+
<div ref={panelRef} style={panelStyle}>
|
|
342
|
+
{/* 面板头部 */}
|
|
343
|
+
<div style={styles.debugPanelHeader}>
|
|
344
|
+
<div style={styles.debugPanelTitle}>
|
|
345
|
+
<span style={styles.debugPanelLogo}>🐛</span>
|
|
346
|
+
<span>TaroViz Debug Panel</span>
|
|
347
|
+
</div>
|
|
348
|
+
<button
|
|
349
|
+
style={styles.debugPanelToggle}
|
|
350
|
+
onClick={togglePanel}
|
|
351
|
+
title={isExpanded ? '收起' : '展开'}
|
|
352
|
+
>
|
|
353
|
+
{isExpanded ? '▼' : '▶'}
|
|
354
|
+
</button>
|
|
355
|
+
</div>
|
|
356
|
+
|
|
357
|
+
{/* 面板内容 */}
|
|
358
|
+
{isExpanded && (
|
|
359
|
+
<>
|
|
360
|
+
{/* 标签页导航 */}
|
|
361
|
+
<div style={styles.debugPanelTabs}>
|
|
362
|
+
<button
|
|
363
|
+
style={{ ...styles.debugTab, ...(activeTab === 'instance' && styles.debugTabActive) }}
|
|
364
|
+
onClick={() => switchTab('instance')}
|
|
365
|
+
title="实例信息"
|
|
366
|
+
>
|
|
367
|
+
实例
|
|
368
|
+
</button>
|
|
369
|
+
<button
|
|
370
|
+
style={{ ...styles.debugTab, ...(activeTab === 'config' && styles.debugTabActive) }}
|
|
371
|
+
onClick={() => switchTab('config')}
|
|
372
|
+
title="配置信息"
|
|
373
|
+
>
|
|
374
|
+
配置
|
|
375
|
+
</button>
|
|
376
|
+
<button
|
|
377
|
+
style={{ ...styles.debugTab, ...(activeTab === 'data' && styles.debugTabActive) }}
|
|
378
|
+
onClick={() => switchTab('data')}
|
|
379
|
+
title="数据信息"
|
|
380
|
+
>
|
|
381
|
+
数据
|
|
382
|
+
</button>
|
|
383
|
+
<button
|
|
384
|
+
style={{
|
|
385
|
+
...styles.debugTab,
|
|
386
|
+
...(activeTab === 'performance' && styles.debugTabActive),
|
|
387
|
+
}}
|
|
388
|
+
onClick={() => switchTab('performance')}
|
|
389
|
+
title="性能信息"
|
|
390
|
+
>
|
|
391
|
+
性能
|
|
392
|
+
</button>
|
|
393
|
+
<button
|
|
394
|
+
style={{ ...styles.debugTab, ...(activeTab === 'events' && styles.debugTabActive) }}
|
|
395
|
+
onClick={() => switchTab('events')}
|
|
396
|
+
title="事件信息"
|
|
397
|
+
>
|
|
398
|
+
事件
|
|
399
|
+
</button>
|
|
400
|
+
<button
|
|
401
|
+
style={{ ...styles.debugTab, ...(activeTab === 'errors' && styles.debugTabActive) }}
|
|
402
|
+
onClick={() => switchTab('errors')}
|
|
403
|
+
title="错误信息"
|
|
404
|
+
>
|
|
405
|
+
错误
|
|
406
|
+
</button>
|
|
407
|
+
<button
|
|
408
|
+
style={{ ...styles.debugTab, ...(activeTab === 'tools' && styles.debugTabActive) }}
|
|
409
|
+
onClick={() => switchTab('tools')}
|
|
410
|
+
title="调试工具"
|
|
411
|
+
>
|
|
412
|
+
工具
|
|
413
|
+
</button>
|
|
414
|
+
</div>
|
|
415
|
+
|
|
416
|
+
{/* 标签页内容 */}
|
|
417
|
+
<div style={styles.debugPanelBody}>{renderTabContent()}</div>
|
|
418
|
+
</>
|
|
419
|
+
)}
|
|
420
|
+
</div>
|
|
421
|
+
);
|
|
422
|
+
};
|
|
423
|
+
|
|
424
|
+
// 样式定义
|
|
425
|
+
const styles: Record<string, React.CSSProperties> = {
|
|
426
|
+
tarovizDebugPanel: {
|
|
427
|
+
transition: 'all 0.3s ease',
|
|
428
|
+
},
|
|
429
|
+
debugPanelHeader: {
|
|
430
|
+
display: 'flex',
|
|
431
|
+
justifyContent: 'space-between',
|
|
432
|
+
alignItems: 'center',
|
|
433
|
+
padding: '8px 12px',
|
|
434
|
+
backgroundColor: '#f5f5f5',
|
|
435
|
+
borderBottom: '1px solid #e0e0e0',
|
|
436
|
+
cursor: 'pointer',
|
|
437
|
+
},
|
|
438
|
+
debugPanelTitle: {
|
|
439
|
+
display: 'flex',
|
|
440
|
+
alignItems: 'center',
|
|
441
|
+
gap: '8px',
|
|
442
|
+
fontWeight: 'bold',
|
|
443
|
+
color: '#333',
|
|
444
|
+
},
|
|
445
|
+
debugPanelLogo: {
|
|
446
|
+
fontSize: '14px',
|
|
447
|
+
},
|
|
448
|
+
debugPanelToggle: {
|
|
449
|
+
background: 'none',
|
|
450
|
+
border: 'none',
|
|
451
|
+
fontSize: '12px',
|
|
452
|
+
cursor: 'pointer',
|
|
453
|
+
color: '#666',
|
|
454
|
+
padding: '4px',
|
|
455
|
+
},
|
|
456
|
+
debugPanelTabs: {
|
|
457
|
+
display: 'flex',
|
|
458
|
+
borderBottom: '1px solid #e0e0e0',
|
|
459
|
+
overflowX: 'auto',
|
|
460
|
+
whiteSpace: 'nowrap',
|
|
461
|
+
},
|
|
462
|
+
debugTab: {
|
|
463
|
+
padding: '8px 12px',
|
|
464
|
+
background: 'none',
|
|
465
|
+
border: 'none',
|
|
466
|
+
borderBottom: '2px solid transparent',
|
|
467
|
+
cursor: 'pointer',
|
|
468
|
+
fontSize: '12px',
|
|
469
|
+
color: '#666',
|
|
470
|
+
transition: 'all 0.2s ease',
|
|
471
|
+
},
|
|
472
|
+
debugTabActive: {
|
|
473
|
+
color: '#1890ff',
|
|
474
|
+
borderBottomColor: '#1890ff',
|
|
475
|
+
fontWeight: 'bold',
|
|
476
|
+
},
|
|
477
|
+
debugPanelBody: {
|
|
478
|
+
height: 'calc(100% - 70px)',
|
|
479
|
+
overflow: 'auto',
|
|
480
|
+
},
|
|
481
|
+
debugPanelContent: {
|
|
482
|
+
padding: '12px',
|
|
483
|
+
},
|
|
484
|
+
h3: {
|
|
485
|
+
margin: '0 0 12px 0',
|
|
486
|
+
fontSize: '14px',
|
|
487
|
+
color: '#333',
|
|
488
|
+
},
|
|
489
|
+
h4: {
|
|
490
|
+
margin: '12px 0 8px 0',
|
|
491
|
+
fontSize: '13px',
|
|
492
|
+
color: '#666',
|
|
493
|
+
},
|
|
494
|
+
h5: {
|
|
495
|
+
margin: '8px 0 4px 0',
|
|
496
|
+
fontSize: '12px',
|
|
497
|
+
color: '#666',
|
|
498
|
+
},
|
|
499
|
+
debugInfoGrid: {
|
|
500
|
+
display: 'grid',
|
|
501
|
+
gridTemplateColumns: '1fr 1fr',
|
|
502
|
+
gap: '8px',
|
|
503
|
+
marginBottom: '12px',
|
|
504
|
+
},
|
|
505
|
+
debugInfoItem: {
|
|
506
|
+
display: 'flex',
|
|
507
|
+
justifyContent: 'space-between',
|
|
508
|
+
padding: '4px 8px',
|
|
509
|
+
backgroundColor: '#f9f9f9',
|
|
510
|
+
borderRadius: '4px',
|
|
511
|
+
},
|
|
512
|
+
debugInfoLabel: {
|
|
513
|
+
fontWeight: 'bold',
|
|
514
|
+
color: '#666',
|
|
515
|
+
},
|
|
516
|
+
debugInfoValue: {
|
|
517
|
+
color: '#333',
|
|
518
|
+
},
|
|
519
|
+
debugConfig: {
|
|
520
|
+
backgroundColor: '#f5f5f5',
|
|
521
|
+
padding: '8px',
|
|
522
|
+
borderRadius: '4px',
|
|
523
|
+
overflow: 'auto',
|
|
524
|
+
maxHeight: '200px',
|
|
525
|
+
},
|
|
526
|
+
pre: {
|
|
527
|
+
margin: '0',
|
|
528
|
+
fontSize: '11px',
|
|
529
|
+
overflow: 'auto',
|
|
530
|
+
},
|
|
531
|
+
debugDataSeries: {
|
|
532
|
+
marginTop: '12px',
|
|
533
|
+
},
|
|
534
|
+
debugDataSeriesItem: {
|
|
535
|
+
marginBottom: '12px',
|
|
536
|
+
padding: '8px',
|
|
537
|
+
backgroundColor: '#f9f9f9',
|
|
538
|
+
borderRadius: '4px',
|
|
539
|
+
},
|
|
540
|
+
debugSeriesInfo: {
|
|
541
|
+
marginTop: '4px',
|
|
542
|
+
fontSize: '11px',
|
|
543
|
+
color: '#666',
|
|
544
|
+
},
|
|
545
|
+
debugPerformanceChart: {
|
|
546
|
+
marginTop: '12px',
|
|
547
|
+
height: '120px',
|
|
548
|
+
backgroundColor: '#f9f9f9',
|
|
549
|
+
borderRadius: '4px',
|
|
550
|
+
display: 'flex',
|
|
551
|
+
alignItems: 'center',
|
|
552
|
+
justifyContent: 'center',
|
|
553
|
+
color: '#999',
|
|
554
|
+
},
|
|
555
|
+
debugEventsList: {
|
|
556
|
+
maxHeight: '200px',
|
|
557
|
+
overflow: 'auto',
|
|
558
|
+
},
|
|
559
|
+
debugEventItem: {
|
|
560
|
+
marginBottom: '8px',
|
|
561
|
+
padding: '8px',
|
|
562
|
+
backgroundColor: '#f9f9f9',
|
|
563
|
+
borderRadius: '4px',
|
|
564
|
+
},
|
|
565
|
+
debugEventHeader: {
|
|
566
|
+
display: 'flex',
|
|
567
|
+
justifyContent: 'space-between',
|
|
568
|
+
marginBottom: '4px',
|
|
569
|
+
},
|
|
570
|
+
debugEventType: {
|
|
571
|
+
fontWeight: 'bold',
|
|
572
|
+
color: '#333',
|
|
573
|
+
},
|
|
574
|
+
debugEventTime: {
|
|
575
|
+
fontSize: '10px',
|
|
576
|
+
color: '#999',
|
|
577
|
+
},
|
|
578
|
+
debugEventParams: {
|
|
579
|
+
fontSize: '11px',
|
|
580
|
+
overflow: 'auto',
|
|
581
|
+
maxHeight: '80px',
|
|
582
|
+
},
|
|
583
|
+
debugErrorsList: {
|
|
584
|
+
maxHeight: '200px',
|
|
585
|
+
overflow: 'auto',
|
|
586
|
+
},
|
|
587
|
+
debugErrorItem: {
|
|
588
|
+
marginBottom: '8px',
|
|
589
|
+
padding: '8px',
|
|
590
|
+
backgroundColor: '#fff1f0',
|
|
591
|
+
border: '1px solid #ffccc7',
|
|
592
|
+
borderRadius: '4px',
|
|
593
|
+
},
|
|
594
|
+
debugErrorHeader: {
|
|
595
|
+
display: 'flex',
|
|
596
|
+
justifyContent: 'space-between',
|
|
597
|
+
marginBottom: '4px',
|
|
598
|
+
},
|
|
599
|
+
debugErrorType: {
|
|
600
|
+
fontWeight: 'bold',
|
|
601
|
+
color: '#f5222d',
|
|
602
|
+
},
|
|
603
|
+
debugErrorTime: {
|
|
604
|
+
fontSize: '10px',
|
|
605
|
+
color: '#999',
|
|
606
|
+
},
|
|
607
|
+
debugErrorMessage: {
|
|
608
|
+
color: '#f5222d',
|
|
609
|
+
marginBottom: '4px',
|
|
610
|
+
},
|
|
611
|
+
debugErrorStack: {
|
|
612
|
+
fontSize: '10px',
|
|
613
|
+
maxHeight: '100px',
|
|
614
|
+
overflow: 'auto',
|
|
615
|
+
},
|
|
616
|
+
debugToolsGrid: {
|
|
617
|
+
display: 'grid',
|
|
618
|
+
gridTemplateColumns: '1fr 1fr',
|
|
619
|
+
gap: '8px',
|
|
620
|
+
},
|
|
621
|
+
debugToolButton: {
|
|
622
|
+
padding: '8px 12px',
|
|
623
|
+
backgroundColor: '#f0f0f0',
|
|
624
|
+
border: '1px solid #e0e0e0',
|
|
625
|
+
borderRadius: '4px',
|
|
626
|
+
cursor: 'pointer',
|
|
627
|
+
fontSize: '12px',
|
|
628
|
+
transition: 'all 0.2s ease',
|
|
629
|
+
},
|
|
630
|
+
debugEmptyState: {
|
|
631
|
+
textAlign: 'center',
|
|
632
|
+
color: '#999',
|
|
633
|
+
padding: '16px',
|
|
634
|
+
},
|
|
635
|
+
};
|
|
636
|
+
|
|
637
|
+
export default DebugPanel;
|