@civilization/deepseek-genui 1.0.2 → 1.0.3

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.
Files changed (3) hide show
  1. package/README.md +23 -0
  2. package/client.js +333 -155
  3. package/package.json +1 -1
package/README.md CHANGED
@@ -50,6 +50,29 @@ Agent GenUI(Generative UI)全功能生成式界面运行时与可视化组
50
50
 
51
51
  ---
52
52
 
53
+ ## 🚀 1.0.3 UI 体验与工业级组件细节深度升级
54
+
55
+ 本次更新针对组件库全量进行了精细化 UX 增强与硬编码解耦:
56
+
57
+ 1. **数据表格(Table)增强**:
58
+ - **表头吸顶(Sticky Header)**:表头在纵向滚动时自动吸顶固化(`position: sticky; top: 0`),告别多行数据滚出视口后看不清表头的困扰;
59
+ - **高度保护与条数统计**:支持 `maxHeight` 属性(数据量超大时自适应滚动),底部增设数据统计条(显示当前排序规则与总记录数);
60
+ - **空状态友好兜底**:无数据时居中展示轻量图标与友好文案。
61
+ 2. **可视化图表(Chart)防重叠与交互升级**:
62
+ - **X 轴文本抽样防挤占**:当采样点超过 8 个时,自动采取等距步长抽样展示关键标签(首尾必显),彻底解决高密度数据下文本重叠模糊的问题;
63
+ - **原生悬浮 Tooltip 气泡**:在折线点、柱状条、散点、环形切片上全量接入 `<title>` 原生提示,鼠标悬停即刻透视详细数值与单位;
64
+ - **散点图自适应量程**:X/Y 轴范围自动根据实际数据极值自适应缩放计算,去除写死坐标量程;
65
+ - **面积图渐变 ID 隔离**:生成动态唯一 ID,避免多图同屏渐变串色;
66
+ - **环形图调色板扩充**:色彩池全面扩充至 12 色,满足多维度分类切片需求。
67
+ 3. **关键指标(Metric)红绿语义反转**:
68
+ - 增加 `invertColor: true` / `goodDirection: 'down'` 支持。在服务器延迟下降、错误率下降等正向改善场景下,下降趋势自动标为绿色,符合业务直觉。
69
+ 4. **任务链进展(Task Plan)精细化**:
70
+ - 支持展示每步执行耗时胶囊标签(`duration`,如 `"1.2s"`)以及辅助说明文本(`description`)。
71
+ 5. **表单控件(Form)校验提示**:
72
+ - 支持字段必填红星标识(`required: true`)与字段下方行内错误文本(`error`),进一步夯实人机协同闭环。
73
+
74
+ ---
75
+
53
76
  ## 💬 聊天对话流就地组件替换(Chat In-Place Live Component Rendering)
54
77
 
55
78
  为了让用户在与大模型日常对话时直接获得直观、高保真的可视化与交互体验,插件现已实现 **聊天对话流内原生代码块自动替换** 能力:
package/client.js CHANGED
@@ -206,9 +206,14 @@ window.__ModuleLoader__.load({
206
206
  '.dgen-code-body{padding:14px;margin:0;background:var(--dsw-alias-bg-layer-1);font-family:ui-monospace,SFMono-Regular,Consolas,Monaco,monospace;font-size:12px;line-height:1.6;color:var(--dsw-alias-label-primary);overflow-x:auto}',
207
207
 
208
208
  /* Tables */
209
- '.dgen-table-wrap{width:100%;overflow-x:auto;border-radius:10px;border:1px solid var(--dsw-alias-border-l4);background:var(--dsw-alias-bg-layer-2)}',
209
+
210
210
  '.dgen-table{width:100%;border-collapse:collapse;font-size:12px;text-align:left}',
211
- '.dgen-table th{background:color-mix(in srgb,var(--dsw-alias-bg-layer-1) 55%,transparent);padding:10px 14px;font-weight:650;color:var(--dsw-alias-label-secondary);cursor:pointer;user-select:none;border-bottom:1px solid var(--dsw-alias-border-l4)}',
211
+ '.dgen-table-wrap{width:100%;overflow-x:auto;max-height:460px;overflow-y:auto;border-radius:10px;border:1px solid var(--dsw-alias-border-l4);background:var(--dsw-alias-bg-layer-2);position:relative}',
212
+ '.dgen-table th{position:sticky;top:0;z-index:2;background:var(--dsw-alias-bg-layer-2);padding:10px 14px;font-weight:650;color:var(--dsw-alias-label-secondary);cursor:pointer;user-select:none;border-bottom:1px solid var(--dsw-alias-border-l4);box-shadow:0 1px 0 var(--dsw-alias-border-l4)}',
213
+ '.dgen-table-footer{display:flex;align-items:center;justify-content:space-between;padding:8px 14px;border-top:1px solid var(--dsw-alias-border-l4);background:color-mix(in srgb,var(--dsw-alias-bg-layer-1) 50%,transparent);font-size:11px;color:var(--dsw-alias-label-secondary)}',
214
+ '.dgen-form-error{color:var(--dsw-alias-status-danger,#ef4444);font-size:11px;margin-top:2px;display:flex;align-items:center;gap:4px}',
215
+ '.dgen-task-duration{font-size:10px;font-weight:600;padding:2px 6px;border-radius:4px;background:color-mix(in srgb,var(--dsw-alias-label-secondary) 12%,transparent);color:var(--dsw-alias-label-secondary);font-family:ui-monospace,monospace}',
216
+ '.dgen-code-inline{font-family:ui-monospace,SFMono-Regular,Consolas,monospace;font-size:.9em;padding:1px 5px;border-radius:4px;background:color-mix(in srgb,var(--dsw-alias-brand-primary,#3b82f6) 10%,transparent);color:var(--dsw-alias-brand-primary,#3b82f6);border:1px solid color-mix(in srgb,var(--dsw-alias-brand-primary,#3b82f6) 20%,transparent)}',
212
217
  '.dgen-table th:hover{color:var(--dsw-alias-label-primary)}',
213
218
  '.dgen-table td{padding:10px 14px;border-bottom:1px solid var(--dsw-alias-border-l4);color:var(--dsw-alias-label-primary)}',
214
219
  '.dgen-table tr:last-child td{border-bottom:none}',
@@ -2219,11 +2224,11 @@ window.__ModuleLoader__.load({
2219
2224
  /**
2220
2225
  * Component: HeatmapChart (Full Thermal Matrix with Day/Hour Axes & Tooltip)
2221
2226
  */
2222
- function HeatmapChart({ title, dataset }) {
2227
+ function HeatmapChart({ title, description, dataset, xLabels, yLabels, summary, context }) {
2223
2228
  const [hoveredCell, setHoveredCell] = useState(null);
2224
2229
 
2225
- const WEEKDAYS = ['周一 (Mon)', '周二 (Tue)', '周三 (Wed)', '周四 (Thu)', '周五 (Fri)', '周六 (Sat)', '周日 (Sun)'];
2226
- const TIME_SLOTS = ['00:00', '02:00', '04:00', '06:00', '08:00', '10:00', '12:00', '14:00', '16:00', '18:00', '20:00', '22:00'];
2230
+ const WEEKDAYS = yLabels || ['周一 (Mon)', '周二 (Tue)', '周三 (Wed)', '周四 (Thu)', '周五 (Fri)', '周六 (Sat)', '周日 (Sun)'];
2231
+ const TIME_SLOTS = xLabels || ['00:00', '02:00', '04:00', '06:00', '08:00', '10:00', '12:00', '14:00', '16:00', '18:00', '20:00', '22:00'];
2227
2232
 
2228
2233
  const MATRIX = dataset || [
2229
2234
  [12, 8, 6, 25, 75, 88, 55, 92, 85, 62, 38, 20],
@@ -2254,11 +2259,23 @@ window.__ModuleLoader__.load({
2254
2259
  };
2255
2260
  };
2256
2261
 
2262
+ const handleCellClick = (ri, ci, val) => {
2263
+ if (context && context.dispatchEvent) {
2264
+ context.dispatchEvent('heatmap_cell_click', {
2265
+ row: ri,
2266
+ col: ci,
2267
+ rowLabel: WEEKDAYS[ri] || `Row_${ri}`,
2268
+ colLabel: TIME_SLOTS[ci] || `Col_${ci}`,
2269
+ value: val
2270
+ }, 'action');
2271
+ }
2272
+ };
2273
+
2257
2274
  return h('div', { className: 'dgen-chart-block' },
2258
2275
  h('div', { className: 'dgen-node-card-head' },
2259
2276
  h('div', null,
2260
- h('h3', { className: 'dgen-node-title' }, title || '全时段请求热度分布 (24h Traffic Density)'),
2261
- h('p', { className: 'dgen-node-desc' }, '以周为周期、2 小时为粒度的服务集群 QPS 吞吐热度监控')
2277
+ h('h3', { className: 'dgen-node-title' }, title || '全时段请求热度分布 (Traffic Density)'),
2278
+ h('p', { className: 'dgen-node-desc' }, description || '以时间序列与业务维度矩阵呈现的密度分布')
2262
2279
  ),
2263
2280
  hoveredCell ? h('span', {
2264
2281
  style: {
@@ -2269,7 +2286,7 @@ window.__ModuleLoader__.load({
2269
2286
  background: 'color-mix(in srgb, var(--dsw-alias-brand-primary,#3b82f6) 12%, transparent)',
2270
2287
  color: 'var(--dsw-alias-brand-primary,#3b82f6)'
2271
2288
  }
2272
- }, WEEKDAYS[hoveredCell.r] + ' ' + TIME_SLOTS[hoveredCell.c] + ' · ' + Math.round(hoveredCell.val * 52) + ' QPS (热度 ' + hoveredCell.val + '%)') : null
2289
+ }, (WEEKDAYS[hoveredCell.r] || '') + ' ' + (TIME_SLOTS[hoveredCell.c] || '') + ' · 值: ' + hoveredCell.val) : null
2273
2290
  ),
2274
2291
  h('div', { className: 'dgen-heatmap-wrap' },
2275
2292
  h('div', { className: 'dgen-heatmap-grid' },
@@ -2279,7 +2296,7 @@ window.__ModuleLoader__.load({
2279
2296
  ),
2280
2297
  MATRIX.map((rowVals, ri) =>
2281
2298
  h(React.Fragment, { key: ri },
2282
- h('div', { className: 'dgen-heatmap-ylabel' }, WEEKDAYS[ri].slice(0, 2)),
2299
+ h('div', { className: 'dgen-heatmap-ylabel' }, (WEEKDAYS[ri] || '').slice(0, 3)),
2283
2300
  rowVals.map((val, ci) => {
2284
2301
  const style = getHeatStyle(val);
2285
2302
  return h('div', {
@@ -2288,7 +2305,8 @@ window.__ModuleLoader__.load({
2288
2305
  style,
2289
2306
  onMouseEnter: () => setHoveredCell({ r: ri, c: ci, val }),
2290
2307
  onMouseLeave: () => setHoveredCell(null),
2291
- title: WEEKDAYS[ri] + ' ' + TIME_SLOTS[ci] + ': 热度 ' + val + '%, QPS: ' + Math.round(val * 52)
2308
+ onClick: () => handleCellClick(ri, ci, val),
2309
+ title: (WEEKDAYS[ri] || '') + ' ' + (TIME_SLOTS[ci] || '') + ': ' + val + ' (点击交互)'
2292
2310
  });
2293
2311
  })
2294
2312
  )
@@ -2298,17 +2316,16 @@ window.__ModuleLoader__.load({
2298
2316
  h('div', { className: 'dgen-heatmap-legend' },
2299
2317
  h('div', { style: { display: 'flex', alignItems: 'center', gap: '8px' } },
2300
2318
  h('span', null, '图例:'),
2301
- h('span', { style: { color: 'var(--dsw-alias-label-tertiary)' } }, '低负载 (0 QPS)'),
2319
+ h('span', { style: { color: 'var(--dsw-alias-label-tertiary)' } }, '低'),
2302
2320
  h('div', { className: 'dgen-heatmap-ramp' },
2303
2321
  [10, 30, 50, 75, 95].map((level, i) =>
2304
2322
  h('span', { key: i, className: 'dgen-heatmap-swatch', style: getHeatStyle(level) })
2305
2323
  )
2306
2324
  ),
2307
- h('span', { style: { color: 'var(--dsw-alias-label-tertiary)' } }, '高负载 (> 5,000 QPS)')
2325
+ h('span', { style: { color: 'var(--dsw-alias-label-tertiary)' } }, '高')
2308
2326
  ),
2309
- h('div', { style: { display: 'flex', gap: '14px', fontSize: '11px', color: 'var(--dsw-alias-label-secondary)' } },
2310
- h('span', null, '周总吞吐: 28.4M 请求'),
2311
- h('span', null, '峰值时段: 周三 14:00 (5,200 QPS)')
2327
+ summary && h('div', { style: { display: 'flex', gap: '14px', fontSize: '11px', color: 'var(--dsw-alias-label-secondary)' } },
2328
+ h('span', null, summary)
2312
2329
  )
2313
2330
  )
2314
2331
  );
@@ -3034,6 +3051,32 @@ window.__ModuleLoader__.load({
3034
3051
  }
3035
3052
 
3036
3053
  /** Component Renderers with DSH Unified UI Variables */
3054
+
3055
+ /** Render simple inline markdown (bold, inline-code) */
3056
+ function renderSimpleInline(text) {
3057
+ if (typeof text !== 'string') return text;
3058
+ const parts = [];
3059
+ const regex = /(\*\*.*?\*\*|`.*?`)/g;
3060
+ let lastIdx = 0;
3061
+ let match;
3062
+ while ((match = regex.exec(text)) !== null) {
3063
+ if (match.index > lastIdx) {
3064
+ parts.push(text.slice(lastIdx, match.index));
3065
+ }
3066
+ const m = match[0];
3067
+ if (m.startsWith('**') && m.endsWith('**')) {
3068
+ parts.push(h('strong', { key: 'b_' + match.index, style: { fontWeight: 700, color: 'var(--dsw-alias-label-primary)' } }, m.slice(2, -2)));
3069
+ } else if (m.startsWith('`') && m.endsWith('`')) {
3070
+ parts.push(h('code', { key: 'c_' + match.index, className: 'dgen-code-inline' }, m.slice(1, -1)));
3071
+ }
3072
+ lastIdx = regex.lastIndex;
3073
+ }
3074
+ if (lastIdx < text.length) {
3075
+ parts.push(text.slice(lastIdx));
3076
+ }
3077
+ return parts.length > 0 ? parts : text;
3078
+ }
3079
+
3037
3080
  const Renderers = {
3038
3081
  card(props, context) {
3039
3082
  const items = props.items || props.sections || [];
@@ -3096,11 +3139,16 @@ window.__ModuleLoader__.load({
3096
3139
  )
3097
3140
  ))
3098
3141
  ),
3099
- props.content && h('div', { style: { marginTop: '8px', fontSize: '13px' } }, props.content)
3142
+ props.content && h('div', { style: { marginTop: '8px', fontSize: '13px', lineHeight: 1.6, color: 'var(--dsw-alias-label-primary)' } }, renderSimpleInline(props.content))
3100
3143
  );
3101
3144
  },
3102
3145
 
3103
3146
  metric(props, context) {
3147
+ const isDown = props.changeType === 'down';
3148
+ // 支持反转语义:如延迟/错误率下降是正向好事
3149
+ const isGood = props.invertColor || props.goodDirection === 'down' ? isDown : !isDown;
3150
+ const trendClass = isGood ? 'dgen-metric-up' : 'dgen-metric-down';
3151
+
3104
3152
  return h('div', { className: 'dgen-metric-tile' },
3105
3153
  props.title && h('span', {
3106
3154
  style: {
@@ -3115,7 +3163,7 @@ window.__ModuleLoader__.load({
3115
3163
  h('div', { className: 'dgen-metric-box' },
3116
3164
  h('span', { className: 'dgen-metric-val' }, props.value ?? '--'),
3117
3165
  props.unit && h('span', { className: 'dgen-metric-unit' }, props.unit),
3118
- props.change && h('span', { className: `dgen-metric-change dgen-metric-${props.changeType === 'down' ? 'down' : 'up'}` }, props.change)
3166
+ props.change && h('span', { className: `dgen-metric-change ${trendClass}` }, (isDown ? '↓ ' : '↑ ') + props.change)
3119
3167
  ),
3120
3168
  props.description && h('p', { className: 'dgen-node-desc', style: { fontSize: '11px', color: 'var(--dsw-alias-label-tertiary)', margin: '2px 0 0' } }, props.description)
3121
3169
  );
@@ -3152,13 +3200,23 @@ window.__ModuleLoader__.load({
3152
3200
  );
3153
3201
  },
3154
3202
 
3155
- chart(props) {
3203
+ chart(props, context) {
3156
3204
  const chartType = props.chartType || 'line';
3157
3205
  const series = props.series || [];
3206
+ const unit = props.unit || props.yAxisLabel || '';
3207
+ const xAxisTitle = props.xAxisLabel || props.xLabel || '';
3208
+
3209
+ // 统一 X 轴刻度防重叠抽样计算:点数过多时等距保留 6~8 个关键刻度
3210
+ const shouldShowXLabel = (idx, total) => {
3211
+ if (total <= 7) return true;
3212
+ if (idx === 0 || idx === total - 1) return true;
3213
+ const step = Math.ceil(total / 6);
3214
+ return idx % step === 0;
3215
+ };
3158
3216
 
3159
- // 1. Line Chart with Full Cartesian Coordinates (X-axis ticks, labels, grid)
3217
+ // 1. Line Chart
3160
3218
  if (chartType === 'line') {
3161
- const maxVal = Math.max(...series.map((s) => s.value || 0), 100);
3219
+ const maxVal = Math.max(...series.map((s) => s.value || 0), 10);
3162
3220
  const plotW = 280;
3163
3221
  const plotH = 80;
3164
3222
  const leftX = 45;
@@ -3166,20 +3224,21 @@ window.__ModuleLoader__.load({
3166
3224
 
3167
3225
  const pts = series.map((s, idx) => {
3168
3226
  const x = leftX + (idx / Math.max(series.length - 1, 1)) * plotW;
3169
- const y = baseY - (s.value / maxVal) * plotH;
3227
+ const y = baseY - ((s.value || 0) / maxVal) * plotH;
3170
3228
  return `${x},${y}`;
3171
3229
  }).join(' ');
3172
3230
 
3173
3231
  return h('div', { className: 'dgen-chart-block' },
3174
3232
  props.title && h('h3', { className: 'dgen-node-title' }, props.title),
3175
- h('svg', { viewBox: '0 0 350 135', style: { width: '100%', height: '150px', marginTop: '6px' } },
3233
+ props.description && h('p', { className: 'dgen-node-desc', style: { margin: '0 0 6px' } }, props.description),
3234
+ h('svg', { viewBox: '0 0 350 140', style: { width: '100%', height: '155px', marginTop: '6px' } },
3176
3235
  // Grid lines & Y scale
3177
3236
  [0, 0.33, 0.66, 1].map((ratio, i) => {
3178
3237
  const y = baseY - ratio * plotH;
3179
3238
  const val = Math.round(ratio * maxVal);
3180
3239
  return h('g', { key: i },
3181
3240
  h('line', { x1: leftX, y1: y, x2: leftX + plotW, y2: y, stroke: 'var(--dsw-alias-border-l4)', strokeDasharray: i === 0 ? 'none' : '3 3', strokeWidth: 1 }),
3182
- h('text', { x: leftX - 6, y: y + 3, textAnchor: 'end', fontSize: 9, fill: 'var(--dsw-alias-label-tertiary)' }, val)
3241
+ h('text', { x: leftX - 6, y: y + 3, textAnchor: 'end', fontSize: 9, fill: 'var(--dsw-alias-label-tertiary)' }, val + (i === 3 && unit ? unit : ''))
3183
3242
  );
3184
3243
  }),
3185
3244
  // Axes
@@ -3193,146 +3252,229 @@ window.__ModuleLoader__.load({
3193
3252
  strokeLinecap: 'round',
3194
3253
  points: pts,
3195
3254
  }),
3196
- // Points & X Labels
3255
+ // Points & X Labels (抽样防重叠 + 原生 title 悬浮浮层)
3197
3256
  series.map((s, idx) => {
3198
3257
  const cx = leftX + (idx / Math.max(series.length - 1, 1)) * plotW;
3199
- const cy = baseY - (s.value / maxVal) * plotH;
3258
+ const cy = baseY - ((s.value || 0) / maxVal) * plotH;
3259
+ const showLabel = shouldShowXLabel(idx, series.length);
3200
3260
  return h('g', { key: idx },
3201
- h('circle', { cx, cy, r: 3.5, fill: 'var(--dsw-alias-brand-primary,#3b82f6)', stroke: 'var(--dsw-alias-bg-layer-2)', strokeWidth: 1.5 }),
3202
- h('line', { x1: cx, y1: baseY, x2: cx, y2: baseY + 4, stroke: 'var(--dsw-alias-border-l4)' }),
3203
- h('text', { x: cx, y: baseY + 16, textAnchor: 'middle', fill: 'var(--dsw-alias-label-secondary)', fontSize: 9, fontWeight: 500 }, s.label)
3261
+ h('circle', {
3262
+ cx,
3263
+ cy,
3264
+ r: 3.8,
3265
+ fill: 'var(--dsw-alias-brand-primary,#3b82f6)',
3266
+ stroke: 'var(--dsw-alias-bg-layer-2)',
3267
+ strokeWidth: 1.5,
3268
+ style: { cursor: 'pointer' }
3269
+ },
3270
+ h('title', null, `${s.label}: ${s.value}${unit}`)
3271
+ ),
3272
+ showLabel && h('g', null,
3273
+ h('line', { x1: cx, y1: baseY, x2: cx, y2: baseY + 4, stroke: 'var(--dsw-alias-border-l4)' }),
3274
+ h('text', { x: cx, y: baseY + 16, textAnchor: 'middle', fill: 'var(--dsw-alias-label-secondary)', fontSize: 9, fontWeight: 500 }, s.label)
3275
+ )
3204
3276
  );
3205
3277
  }),
3206
- h('text', { x: leftX + plotW, y: baseY + 28, textAnchor: 'end', fontSize: 9, fill: 'var(--dsw-alias-label-tertiary)' }, '横坐标: 采样时段 (24h)')
3278
+ xAxisTitle && h('text', { x: leftX + plotW, y: baseY + 28, textAnchor: 'end', fontSize: 9, fill: 'var(--dsw-alias-label-tertiary)' }, xAxisTitle)
3207
3279
  )
3208
3280
  );
3209
3281
  }
3210
3282
 
3211
- // 2. Area Chart with Full Cartesian Coordinates (X-axis labels, fill gradient)
3283
+ // 2. Area Chart
3212
3284
  if (chartType === 'area') {
3213
- const maxVal = Math.max(...series.map((s) => s.value || 0), 100);
3285
+ const maxVal = Math.max(...series.map((s) => s.value || 0), 10);
3214
3286
  const plotW = 280;
3215
3287
  const plotH = 80;
3216
3288
  const leftX = 45;
3217
3289
  const baseY = 100;
3290
+ const gradId = 'dgen_area_grad_' + Math.abs(Math.random() * 100000 | 0);
3218
3291
 
3219
3292
  const linePts = series.map((s, idx) => {
3220
3293
  const x = leftX + (idx / Math.max(series.length - 1, 1)) * plotW;
3221
- const y = baseY - (s.value / maxVal) * plotH;
3294
+ const y = baseY - ((s.value || 0) / maxVal) * plotH;
3222
3295
  return `${x},${y}`;
3223
3296
  });
3224
3297
  const polyPts = `${leftX},${baseY} ${linePts.join(' ')} ${leftX + plotW},${baseY}`;
3225
3298
 
3226
3299
  return h('div', { className: 'dgen-chart-block' },
3227
3300
  props.title && h('h3', { className: 'dgen-node-title' }, props.title),
3228
- h('svg', { viewBox: '0 0 350 135', style: { width: '100%', height: '150px', marginTop: '6px' } },
3301
+ props.description && h('p', { className: 'dgen-node-desc', style: { margin: '0 0 6px' } }, props.description),
3302
+ h('svg', { viewBox: '0 0 350 140', style: { width: '100%', height: '155px', marginTop: '6px' } },
3303
+ h('defs', null,
3304
+ h('linearGradient', { id: gradId, x1: '0', y1: '0', x2: '0', y2: '1' },
3305
+ h('stop', { offset: '0%', stopColor: 'var(--dsw-alias-brand-primary,#3b82f6)', stopOpacity: 0.4 }),
3306
+ h('stop', { offset: '100%', stopColor: 'var(--dsw-alias-brand-primary,#3b82f6)', stopOpacity: 0.02 })
3307
+ )
3308
+ ),
3229
3309
  [0, 0.33, 0.66, 1].map((ratio, i) => {
3230
3310
  const y = baseY - ratio * plotH;
3231
3311
  const val = Math.round(ratio * maxVal);
3232
3312
  return h('g', { key: i },
3233
3313
  h('line', { x1: leftX, y1: y, x2: leftX + plotW, y2: y, stroke: 'var(--dsw-alias-border-l4)', strokeDasharray: i === 0 ? 'none' : '3 3', strokeWidth: 1 }),
3234
- h('text', { x: leftX - 6, y: y + 3, textAnchor: 'end', fontSize: 9, fill: 'var(--dsw-alias-label-tertiary)' }, val + 'G')
3314
+ h('text', { x: leftX - 6, y: y + 3, textAnchor: 'end', fontSize: 9, fill: 'var(--dsw-alias-label-tertiary)' }, val + (i === 3 && unit ? unit : ''))
3235
3315
  );
3236
3316
  }),
3237
3317
  h('line', { x1: leftX, y1: baseY - plotH - 5, x2: leftX, y2: baseY, stroke: 'var(--dsw-alias-border-l4)', strokeWidth: 1.2 }),
3238
3318
  h('line', { x1: leftX, y1: baseY, x2: leftX + plotW + 10, y2: baseY, stroke: 'var(--dsw-alias-border-l4)', strokeWidth: 1.2 }),
3239
- h('polygon', { fill: 'color-mix(in srgb, var(--dsw-alias-brand-primary, #3b82f6) 18%, transparent)', points: polyPts }),
3240
- h('polyline', { fill: 'none', stroke: 'var(--dsw-alias-brand-primary,#3b82f6)', strokeWidth: '2.5', points: linePts.join(' ') }),
3319
+ h('polygon', { fill: `url(#${gradId})`, points: polyPts }),
3320
+ h('polyline', {
3321
+ fill: 'none',
3322
+ stroke: 'var(--dsw-alias-brand-primary,#3b82f6)',
3323
+ strokeWidth: '2.2',
3324
+ strokeLinecap: 'round',
3325
+ points: linePts.join(' '),
3326
+ }),
3241
3327
  series.map((s, idx) => {
3242
3328
  const cx = leftX + (idx / Math.max(series.length - 1, 1)) * plotW;
3329
+ const cy = baseY - ((s.value || 0) / maxVal) * plotH;
3330
+ const showLabel = shouldShowXLabel(idx, series.length);
3243
3331
  return h('g', { key: idx },
3244
- h('line', { x1: cx, y1: baseY, x2: cx, y2: baseY + 4, stroke: 'var(--dsw-alias-border-l4)' }),
3245
- h('text', { x: cx, y: baseY + 16, textAnchor: 'middle', fill: 'var(--dsw-alias-label-secondary)', fontSize: 9, fontWeight: 500 }, s.label)
3332
+ h('circle', {
3333
+ cx,
3334
+ cy,
3335
+ r: 3.5,
3336
+ fill: 'var(--dsw-alias-brand-primary,#3b82f6)',
3337
+ stroke: 'var(--dsw-alias-bg-layer-2)',
3338
+ strokeWidth: 1.5,
3339
+ style: { cursor: 'pointer' }
3340
+ },
3341
+ h('title', null, `${s.label}: ${s.value}${unit}`)
3342
+ ),
3343
+ showLabel && h('g', null,
3344
+ h('line', { x1: cx, y1: baseY, x2: cx, y2: baseY + 4, stroke: 'var(--dsw-alias-border-l4)' }),
3345
+ h('text', { x: cx, y: baseY + 16, textAnchor: 'middle', fill: 'var(--dsw-alias-label-secondary)', fontSize: 9, fontWeight: 500 }, s.label)
3346
+ )
3246
3347
  );
3247
3348
  }),
3248
- h('text', { x: leftX + plotW, y: baseY + 28, textAnchor: 'end', fontSize: 9, fill: 'var(--dsw-alias-label-tertiary)' }, '横坐标: 监控时间')
3349
+ xAxisTitle && h('text', { x: leftX + plotW, y: baseY + 28, textAnchor: 'end', fontSize: 9, fill: 'var(--dsw-alias-label-tertiary)' }, xAxisTitle)
3249
3350
  )
3250
3351
  );
3251
3352
  }
3252
3353
 
3253
- // 3. Bar Chart with Vertical Bars & Clear Horizontal X-Axis
3354
+ // 3. Bar Chart
3254
3355
  if (chartType === 'bar') {
3255
- const maxVal = Math.max(...series.map((s) => s.value || 0), 100);
3356
+ const maxVal = Math.max(...series.map((s) => s.value || 0), 10);
3256
3357
  const plotW = 280;
3257
3358
  const plotH = 80;
3258
3359
  const leftX = 45;
3259
3360
  const baseY = 100;
3260
- const colCount = series.length || 1;
3261
- const slotW = plotW / colCount;
3262
- const barW = Math.min(slotW * 0.55, 34);
3361
+ const barW = Math.max(Math.min(plotW / (series.length || 1) - 8, 28), 6);
3263
3362
 
3264
3363
  return h('div', { className: 'dgen-chart-block' },
3265
3364
  props.title && h('h3', { className: 'dgen-node-title' }, props.title),
3266
- h('svg', { viewBox: '0 0 350 145', style: { width: '100%', height: '160px', marginTop: '6px' } },
3267
- [0, 0.25, 0.5, 0.75, 1].map((ratio, i) => {
3365
+ props.description && h('p', { className: 'dgen-node-desc', style: { margin: '0 0 6px' } }, props.description),
3366
+ h('svg', { viewBox: '0 0 350 140', style: { width: '100%', height: '155px', marginTop: '6px' } },
3367
+ [0, 0.33, 0.66, 1].map((ratio, i) => {
3268
3368
  const y = baseY - ratio * plotH;
3269
3369
  const val = Math.round(ratio * maxVal);
3270
3370
  return h('g', { key: i },
3271
3371
  h('line', { x1: leftX, y1: y, x2: leftX + plotW, y2: y, stroke: 'var(--dsw-alias-border-l4)', strokeDasharray: i === 0 ? 'none' : '3 3', strokeWidth: 1 }),
3272
- h('text', { x: leftX - 6, y: y + 3, textAnchor: 'end', fontSize: 9, fill: 'var(--dsw-alias-label-tertiary)' }, val + '%')
3372
+ h('text', { x: leftX - 6, y: y + 3, textAnchor: 'end', fontSize: 9, fill: 'var(--dsw-alias-label-tertiary)' }, val + (i === 3 && unit ? unit : ''))
3273
3373
  );
3274
3374
  }),
3275
3375
  h('line', { x1: leftX, y1: baseY - plotH - 5, x2: leftX, y2: baseY, stroke: 'var(--dsw-alias-border-l4)', strokeWidth: 1.2 }),
3276
3376
  h('line', { x1: leftX, y1: baseY, x2: leftX + plotW + 10, y2: baseY, stroke: 'var(--dsw-alias-border-l4)', strokeWidth: 1.2 }),
3277
- series.map((s, i) => {
3278
- const cx = leftX + i * slotW + slotW / 2;
3279
- const hVal = (s.value / maxVal) * plotH;
3280
- const bx = cx - barW / 2;
3281
- const by = baseY - hVal;
3282
- return h('g', { key: i },
3283
- h('text', { x: cx, y: by - 4, textAnchor: 'middle', fontSize: 9, fontWeight: 600, fill: 'var(--dsw-alias-label-primary)' }, s.value + '%'),
3377
+ series.map((s, idx) => {
3378
+ const slotW = plotW / (series.length || 1);
3379
+ const x = leftX + idx * slotW + (slotW - barW) / 2;
3380
+ const hVal = Math.max(((s.value || 0) / maxVal) * plotH, 2);
3381
+ const y = baseY - hVal;
3382
+ const showLabel = shouldShowXLabel(idx, series.length);
3383
+ return h('g', { key: idx },
3284
3384
  h('rect', {
3285
- x: bx,
3286
- y: by,
3385
+ x,
3386
+ y,
3287
3387
  width: barW,
3288
- height: Math.max(hVal, 2),
3388
+ height: hVal,
3289
3389
  rx: 3,
3290
- fill: 'var(--dsw-alias-brand-primary,#3b82f6)',
3291
- }),
3292
- h('line', { x1: cx, y1: baseY, x2: cx, y2: baseY + 4, stroke: 'var(--dsw-alias-border-l4)' }),
3293
- h('text', { x: cx, y: baseY + 16, textAnchor: 'middle', fontSize: 9, fontWeight: 500, fill: 'var(--dsw-alias-label-secondary)' }, s.label)
3390
+ fill: s.color || 'var(--dsw-alias-brand-primary,#3b82f6)',
3391
+ style: { cursor: 'pointer', transition: 'opacity .15s' }
3392
+ },
3393
+ h('title', null, `${s.label}: ${s.value}${unit}`)
3394
+ ),
3395
+ showLabel && h('text', {
3396
+ x: x + barW / 2,
3397
+ y: baseY + 16,
3398
+ textAnchor: 'middle',
3399
+ fill: 'var(--dsw-alias-label-secondary)',
3400
+ fontSize: 9,
3401
+ fontWeight: 500
3402
+ }, s.label)
3294
3403
  );
3295
3404
  }),
3296
- h('text', { x: leftX + plotW, y: baseY + 32, textAnchor: 'end', fontSize: 9, fill: 'var(--dsw-alias-label-tertiary)' }, '横坐标: 集群业务模块')
3405
+ xAxisTitle && h('text', { x: leftX + plotW, y: baseY + 28, textAnchor: 'end', fontSize: 9, fill: 'var(--dsw-alias-label-tertiary)' }, xAxisTitle)
3297
3406
  )
3298
3407
  );
3299
3408
  }
3300
3409
 
3301
- // 4. Donut / Pie Chart
3410
+ // 4. Donut / Pie Chart (12 色调色板)
3302
3411
  if (chartType === 'donut' || chartType === 'pie') {
3303
- const total = series.reduce((acc, s) => acc + (s.value || 0), 0) || 1;
3304
- const colors = ['#3b82f6', '#38a169', '#d69e2e', '#8b5cf6', '#e53e3e'];
3305
- let cumulativeAngle = 0;
3412
+ const colors = [
3413
+ '#3b82f6', '#10b981', '#f59e0b', '#ef4444', '#8b5cf6',
3414
+ '#06b6d4', '#ec4899', '#6366f1', '#14b8a6', '#f97316',
3415
+ '#84cc16', '#a855f7'
3416
+ ];
3417
+ const total = series.reduce((acc, cur) => acc + (cur.value || 0), 0) || 1;
3418
+ const strokeW = chartType === 'donut' ? 14 : 32;
3419
+ const radius = 32;
3420
+ const circumference = 2 * Math.PI * radius;
3421
+
3422
+ let accumulatedPercent = 0;
3423
+ const slices = series.map((s, i) => {
3424
+ const pct = (s.value || 0) / total;
3425
+ const strokeDasharray = `${pct * circumference} ${circumference}`;
3426
+ const strokeDashoffset = -accumulatedPercent * circumference;
3427
+ accumulatedPercent += pct;
3428
+ return { ...s, color: s.color || colors[i % colors.length], strokeDasharray, strokeDashoffset, pct };
3429
+ });
3306
3430
 
3307
3431
  return h('div', { className: 'dgen-chart-block' },
3308
3432
  props.title && h('h3', { className: 'dgen-node-title' }, props.title),
3309
- h('div', { style: { display: 'flex', alignItems: 'center', justifyContent: 'center', gap: '28px', marginTop: '12px' } },
3310
- h('svg', { viewBox: '0 0 100 100', width: 110, height: 110 },
3311
- series.map((s, i) => {
3312
- const percent = (s.value || 0) / total;
3313
- const strokeDasharray = `${percent * 251.2} 251.2`;
3314
- const strokeDashoffset = -cumulativeAngle * 251.2;
3315
- cumulativeAngle += percent;
3316
- return h('circle', {
3317
- key: i,
3318
- cx: 50,
3319
- cy: 50,
3320
- r: 40,
3321
- fill: 'transparent',
3322
- stroke: colors[i % colors.length],
3323
- strokeWidth: 16,
3324
- strokeDasharray,
3325
- strokeDashoffset,
3326
- transform: 'rotate(-90 50 50)',
3327
- });
3328
- }),
3329
- h('text', { x: 50, y: 54, textAnchor: 'middle', fontSize: 13, fontWeight: 700, fill: 'var(--dsw-alias-label-primary)' }, `${series[0]?.value || 0}%`)
3433
+ props.description && h('p', { className: 'dgen-node-desc', style: { margin: '0 0 6px' } }, props.description),
3434
+ h('div', { style: { display: 'flex', alignItems: 'center', gap: '20px', flexWrap: 'wrap', marginTop: '8px' } },
3435
+ h('div', { style: { position: 'relative', width: '120px', height: '120px', flexShrink: 0 } },
3436
+ h('svg', { viewBox: '0 0 100 100', width: 120, height: 120, style: { transform: 'rotate(-90deg)' } },
3437
+ h('circle', { cx: 50, cy: 50, r: radius, fill: 'none', stroke: 'var(--dsw-alias-border-l4)', strokeWidth: strokeW }),
3438
+ slices.map((sl, i) =>
3439
+ h('circle', {
3440
+ key: i,
3441
+ cx: 50,
3442
+ cy: 50,
3443
+ r: radius,
3444
+ fill: 'none',
3445
+ stroke: sl.color,
3446
+ strokeWidth: strokeW,
3447
+ strokeDasharray: sl.strokeDasharray,
3448
+ strokeDashoffset: sl.strokeDashoffset,
3449
+ style: { transition: 'stroke-dasharray .3s ease' }
3450
+ },
3451
+ h('title', null, `${sl.label}: ${sl.value} (${Math.round(sl.pct * 100)}%)`)
3452
+ )
3453
+ )
3454
+ ),
3455
+ chartType === 'donut' && h('div', {
3456
+ style: {
3457
+ position: 'absolute',
3458
+ inset: 0,
3459
+ display: 'flex',
3460
+ flexDirection: 'column',
3461
+ alignItems: 'center',
3462
+ justifyContent: 'center',
3463
+ pointerEvents: 'none'
3464
+ }
3465
+ },
3466
+ h('span', { style: { fontSize: '11px', color: 'var(--dsw-alias-label-secondary)' } }, props.centerLabel || '总计'),
3467
+ h('span', { style: { fontSize: '14px', fontWeight: 700, color: 'var(--dsw-alias-label-primary)' } }, props.centerValue || total)
3468
+ )
3330
3469
  ),
3331
- h('div', { style: { display: 'flex', flexDirection: 'column', gap: '6px', fontSize: '11px' } },
3470
+ h('div', { style: { display: 'flex', flexDirection: 'column', gap: '6px', fontSize: '11px', flex: 1, minWidth: '130px' } },
3332
3471
  series.map((s, i) =>
3333
- h('div', { key: i, style: { display: 'flex', alignItems: 'center', gap: '8px' } },
3334
- h('span', { style: { width: '8px', height: '8px', borderRadius: '2px', background: colors[i % colors.length] } }),
3335
- h('span', { style: { color: 'var(--dsw-alias-label-secondary)' } }, `${s.label} (${Math.round(((s.value || 0) / total) * 100)}%)`)
3472
+ h('div', { key: i, style: { display: 'flex', alignItems: 'center', justifyContent: 'space-between', gap: '8px' } },
3473
+ h('div', { style: { display: 'flex', alignItems: 'center', gap: '6px' } },
3474
+ h('span', { style: { width: '8px', height: '8px', borderRadius: '2px', background: s.color || colors[i % colors.length] } }),
3475
+ h('span', { style: { color: 'var(--dsw-alias-label-secondary)' } }, s.label)
3476
+ ),
3477
+ h('span', { style: { fontWeight: 600, color: 'var(--dsw-alias-label-primary)', fontVariantNumeric: 'tabular-nums' } }, `${s.value}${unit} (${Math.round(((s.value || 0) / total) * 100)}%)`)
3336
3478
  )
3337
3479
  )
3338
3480
  )
@@ -3340,31 +3482,36 @@ window.__ModuleLoader__.load({
3340
3482
  );
3341
3483
  }
3342
3484
 
3343
- // 5. Gauge Chart
3485
+ // 5. Gauge Chart (带有平滑过渡)
3344
3486
  if (chartType === 'gauge') {
3345
3487
  const val = props.value || 0;
3346
- const pct = Math.min(Math.max(val, 0), 100);
3488
+ const maxVal = props.max || 100;
3489
+ const pct = Math.min(Math.max((val / maxVal) * 100, 0), 100);
3347
3490
 
3348
3491
  return h('div', { className: 'dgen-chart-block', style: { alignItems: 'center', textAlign: 'center' } },
3349
3492
  props.title && h('h3', { className: 'dgen-node-title' }, props.title),
3493
+ props.description && h('p', { className: 'dgen-node-desc', style: { margin: '0 0 6px' } }, props.description),
3350
3494
  h('svg', { viewBox: '0 0 140 85', width: 160, height: 95, style: { marginTop: '8px' } },
3351
3495
  h('path', { d: 'M 15 75 A 55 55 0 0 1 125 75', fill: 'none', stroke: 'color-mix(in srgb, var(--dsw-alias-border-l4) 50%, transparent)', strokeWidth: 12, strokeLinecap: 'round' }),
3352
3496
  h('path', {
3353
3497
  d: 'M 15 75 A 55 55 0 0 1 125 75',
3354
3498
  fill: 'none',
3355
- stroke: pct > 90 ? '#38a169' : pct > 70 ? '#d69e2e' : '#e53e3e',
3499
+ stroke: pct > 85 ? '#38a169' : pct > 60 ? 'var(--dsw-alias-brand-primary,#3b82f6)' : (pct > 30 ? '#d69e2e' : '#e53e3e'),
3356
3500
  strokeWidth: 12,
3357
3501
  strokeLinecap: 'round',
3358
3502
  strokeDasharray: '172.78',
3359
3503
  strokeDashoffset: 172.78 * (1 - pct / 100),
3360
- }),
3361
- h('text', { x: 70, y: 72, textAnchor: 'middle', fontSize: 22, fontWeight: 700, fill: 'var(--dsw-alias-label-primary)' }, `${val}${props.unit || ''}`)
3504
+ style: { transition: 'stroke-dashoffset 0.4s ease' }
3505
+ },
3506
+ h('title', null, `当前值: ${val}/${maxVal} (${Math.round(pct)}%)`)
3507
+ ),
3508
+ h('text', { x: 70, y: 72, textAnchor: 'middle', fontSize: 22, fontWeight: 700, fill: 'var(--dsw-alias-label-primary)' }, `${val}${unit}`)
3362
3509
  ),
3363
- h('span', { style: { fontSize: '11px', color: 'var(--dsw-alias-label-secondary)' } }, `目标基线: ${props.target || 99.9}%`)
3510
+ props.target && h('span', { style: { fontSize: '11px', color: 'var(--dsw-alias-label-secondary)' } }, `目标基线: ${props.target}${unit}`)
3364
3511
  );
3365
3512
  }
3366
3513
 
3367
- // 6. Scatter Plot with Full Cartesian Coordinates (X-axis ticks: 0, 1000, 2000, 3000, 4000)
3514
+ // 6. Scatter Plot (自适应 X/Y 轴坐标)
3368
3515
  if (chartType === 'scatter') {
3369
3516
  const pts = props.points || [];
3370
3517
  const leftX = 45;
@@ -3372,49 +3519,62 @@ window.__ModuleLoader__.load({
3372
3519
  const plotW = 280;
3373
3520
  const plotH = 80;
3374
3521
 
3522
+ const maxX = Math.max(...pts.map((p) => p.x || 0), 100);
3523
+ const maxY = Math.max(...pts.map((p) => p.y || 0), 50);
3524
+
3375
3525
  return h('div', { className: 'dgen-chart-block' },
3376
3526
  props.title && h('h3', { className: 'dgen-node-title' }, props.title),
3527
+ props.description && h('p', { className: 'dgen-node-desc', style: { margin: '0 0 6px' } }, props.description),
3377
3528
  h('svg', { viewBox: '0 0 350 145', style: { width: '100%', height: '160px', marginTop: '6px' } },
3378
3529
  [0, 0.25, 0.5, 0.75, 1].map((ratio, i) => {
3379
3530
  const y = baseY - ratio * plotH;
3380
- const val = Math.round(ratio * 160);
3531
+ const val = Math.round(ratio * maxY);
3381
3532
  return h('g', { key: i },
3382
3533
  h('line', { x1: leftX, y1: y, x2: leftX + plotW, y2: y, stroke: 'var(--dsw-alias-border-l4)', strokeDasharray: i === 0 ? 'none' : '3 3', strokeWidth: 1 }),
3383
- h('text', { x: leftX - 6, y: y + 3, textAnchor: 'end', fontSize: 9, fill: 'var(--dsw-alias-label-tertiary)' }, val + 'ms')
3534
+ h('text', { x: leftX - 6, y: y + 3, textAnchor: 'end', fontSize: 9, fill: 'var(--dsw-alias-label-tertiary)' }, val + (i === 4 && unit ? unit : ''))
3384
3535
  );
3385
3536
  }),
3386
3537
  h('line', { x1: leftX, y1: baseY - plotH - 5, x2: leftX, y2: baseY, stroke: 'var(--dsw-alias-border-l4)', strokeWidth: 1.2 }),
3387
3538
  h('line', { x1: leftX, y1: baseY, x2: leftX + plotW + 10, y2: baseY, stroke: 'var(--dsw-alias-border-l4)', strokeWidth: 1.2 }),
3388
- [0, 1000, 2000, 3000, 4000].map((tVal, ti) => {
3389
- const tx = leftX + (tVal / 4000) * plotW;
3539
+ [0, 0.25, 0.5, 0.75, 1].map((ratio, ti) => {
3540
+ const tVal = Math.round(ratio * maxX);
3541
+ const tx = leftX + ratio * plotW;
3390
3542
  return h('g', { key: ti },
3391
3543
  h('line', { x1: tx, y1: baseY, x2: tx, y2: baseY + 4, stroke: 'var(--dsw-alias-border-l4)' }),
3392
- h('text', { x: tx, y: baseY + 16, textAnchor: 'middle', fontSize: 9, fill: 'var(--dsw-alias-label-secondary)' }, tVal === 0 ? '0' : (tVal / 1000) + 'k')
3544
+ h('text', { x: tx, y: baseY + 16, textAnchor: 'middle', fontSize: 9, fill: 'var(--dsw-alias-label-secondary)' }, tVal)
3393
3545
  );
3394
3546
  }),
3395
- h('text', { x: leftX + plotW, y: baseY + 30, textAnchor: 'end', fontSize: 9, fill: 'var(--dsw-alias-label-tertiary)' }, '横坐标: Prompt 规模 (Tokens)'),
3547
+ xAxisTitle && h('text', { x: leftX + plotW, y: baseY + 30, textAnchor: 'end', fontSize: 9, fill: 'var(--dsw-alias-label-tertiary)' }, xAxisTitle),
3396
3548
  pts.map((p, idx) => {
3397
- const cx = leftX + (p.x / 4000) * plotW;
3398
- const cy = baseY - (p.y / 160) * plotH;
3549
+ const cx = leftX + ((p.x || 0) / maxX) * plotW;
3550
+ const cy = baseY - ((p.y || 0) / maxY) * plotH;
3399
3551
  return h('circle', {
3400
3552
  key: idx,
3401
3553
  cx,
3402
3554
  cy,
3403
3555
  r: 4.5,
3404
- fill: 'var(--dsw-alias-brand-primary,#3b82f6)',
3556
+ fill: p.color || 'var(--dsw-alias-brand-primary,#3b82f6)',
3405
3557
  stroke: 'var(--dsw-alias-bg-layer-2)',
3406
3558
  strokeWidth: 1.5,
3407
- });
3559
+ style: { cursor: 'pointer' }
3560
+ },
3561
+ h('title', null, p.label ? `${p.label}: (${p.x}, ${p.y})` : `(${p.x}, ${p.y})`)
3562
+ );
3408
3563
  })
3409
3564
  )
3410
3565
  );
3411
3566
  }
3412
3567
 
3413
- // 7. Heatmap (Professional Thermal Gradient Matrix with Day & Hour Axes)
3568
+ // 7. Heatmap
3414
3569
  if (chartType === 'heatmap') {
3415
3570
  return h(HeatmapChart, {
3416
3571
  title: props.title,
3572
+ description: props.description,
3417
3573
  dataset: props.dataset,
3574
+ xLabels: props.xLabels,
3575
+ yLabels: props.yLabels,
3576
+ summary: props.summary,
3577
+ context
3418
3578
  });
3419
3579
  }
3420
3580
 
@@ -3628,54 +3788,42 @@ window.__ModuleLoader__.load({
3628
3788
  const nextOrder = sortKey === key && sortOrder === 'asc' ? 'desc' : 'asc';
3629
3789
  setSortKey(key);
3630
3790
  setSortOrder(nextOrder);
3631
- if (context?.dispatchEvent) {
3632
- context.dispatchEvent('sort', { column: key, order: nextOrder }, 'local');
3633
- }
3634
3791
  };
3635
3792
 
3793
+ const maxHeight = props.maxHeight || (rawRows.length > 8 ? '420px' : 'auto');
3794
+
3636
3795
  return h('div', {
3637
3796
  className: 'dgen-table-wrap',
3638
- style: {
3639
- width: '100%',
3640
- overflowX: 'auto',
3641
- border: '1px solid var(--dsw-alias-border-l4, #e2e8f0)',
3642
- borderRadius: '10px',
3643
- background: 'var(--dsw-alias-bg-layer-2, #ffffff)'
3644
- }
3797
+ style: { maxHeight }
3645
3798
  },
3646
- (props.title || props.header) && h('div', {
3799
+ props.title && h('div', {
3647
3800
  style: {
3648
3801
  padding: '10px 14px',
3649
- fontWeight: 650,
3650
- fontSize: '13.5px',
3651
- color: 'var(--dsw-alias-label-primary)',
3652
3802
  borderBottom: '1px solid var(--dsw-alias-border-l4)',
3653
- background: 'color-mix(in srgb, var(--dsw-alias-bg-layer-1) 50%, transparent)'
3803
+ background: 'color-mix(in srgb, var(--dsw-alias-bg-layer-1) 40%, transparent)',
3804
+ display: 'flex',
3805
+ alignItems: 'center',
3806
+ justifyContent: 'space-between'
3654
3807
  }
3655
- }, props.title || props.header),
3656
- h('table', {
3657
- className: 'dgen-table',
3658
- style: { width: '100%', borderCollapse: 'collapse', fontSize: '12.5px', textAlign: 'left' }
3659
3808
  },
3809
+ h('span', { style: { fontWeight: 650, fontSize: '13px', color: 'var(--dsw-alias-label-primary)' } }, props.title),
3810
+ h('span', { style: { fontSize: '11px', color: 'var(--dsw-alias-label-secondary)' } }, `共 ${rawRows.length} 条记录`)
3811
+ ),
3812
+ h('table', { className: 'dgen-table' },
3660
3813
  h('thead', null,
3661
3814
  h('tr', null,
3662
3815
  normalizedColumns.map((c) =>
3663
3816
  h('th', {
3664
3817
  key: c.key,
3665
3818
  style: {
3666
- padding: '10px 14px',
3667
- background: 'color-mix(in srgb, var(--dsw-alias-bg-layer-1) 55%, transparent)',
3668
- fontWeight: 650,
3669
- color: 'var(--dsw-alias-label-secondary)',
3670
- cursor: 'pointer',
3671
- borderBottom: '1px solid var(--dsw-alias-border-l4)',
3672
3819
  textAlign: c.align || 'left',
3673
3820
  width: c.width
3674
3821
  },
3675
- onClick: () => handleSort(c.key)
3822
+ onClick: () => handleSort(c.key),
3823
+ title: '点击切换升序/降序'
3676
3824
  },
3677
3825
  c.label,
3678
- sortKey === c.key ? (sortOrder === 'asc' ? ' ↑' : ' ↓') : ''
3826
+ sortKey === c.key ? (sortOrder === 'asc' ? ' ▲' : ' ▼') : ''
3679
3827
  )
3680
3828
  )
3681
3829
  )
@@ -3703,11 +3851,20 @@ window.__ModuleLoader__.load({
3703
3851
  h('tr', null,
3704
3852
  h('td', {
3705
3853
  colSpan: Math.max(normalizedColumns.length, 1),
3706
- style: { textAlign: 'center', padding: '24px', color: 'var(--dsw-alias-label-tertiary)', fontSize: '13px' }
3707
- }, '暂无数据行')
3854
+ style: { textAlign: 'center', padding: '36px 14px', color: 'var(--dsw-alias-label-tertiary)', fontSize: '12px' }
3855
+ },
3856
+ h('div', { style: { display: 'flex', flexDirection: 'column', alignItems: 'center', gap: '6px' } },
3857
+ h('span', { style: { fontSize: '24px' } }, '📄'),
3858
+ h('span', null, props.emptyText || '暂无数据行记录')
3859
+ )
3860
+ )
3708
3861
  )
3709
3862
  )
3710
3863
  )
3864
+ ),
3865
+ sortedRows.length > 0 && h('div', { className: 'dgen-table-footer' },
3866
+ h('span', null, sortKey ? `按 ${sortKey} (${sortOrder === 'asc' ? '升序' : '降序'}) 排序` : '默认顺序'),
3867
+ h('span', null, `显示 1-${sortedRows.length} 条,共 ${rawRows.length} 条`)
3711
3868
  )
3712
3869
  );
3713
3870
  },
@@ -3727,9 +3884,13 @@ window.__ModuleLoader__.load({
3727
3884
 
3728
3885
  return h('form', { className: 'dgen-business-card dgen-form', onSubmit: handleSubmit },
3729
3886
  props.title && h('h3', { className: 'dgen-node-title' }, props.title),
3887
+ props.description && h('p', { className: 'dgen-node-desc', style: { margin: '0 0 8px' } }, props.description),
3730
3888
  fields.map((f) => {
3731
3889
  return h('div', { key: f.name, className: 'dgen-form-group' },
3732
- h('label', { className: 'dgen-form-label' }, f.label || f.name),
3890
+ h('label', { className: 'dgen-form-label', style: { display: 'flex', alignItems: 'center', gap: '4px' } },
3891
+ f.label || f.name,
3892
+ f.required && h('span', { style: { color: 'var(--dsw-alias-status-danger,#ef4444)' } }, '*')
3893
+ ),
3733
3894
  f.type === 'select'
3734
3895
  ? h('select', {
3735
3896
  className: 'dgen-form-input',
@@ -3739,7 +3900,7 @@ window.__ModuleLoader__.load({
3739
3900
  (f.options || []).map((opt) => h('option', { key: opt.value, value: opt.value }, opt.label))
3740
3901
  )
3741
3902
  : f.type === 'radio'
3742
- ? h('div', { style: { display: 'flex', gap: '14px', marginTop: '4px' } },
3903
+ ? h('div', { style: { display: 'flex', gap: '14px', marginTop: '4px', flexWrap: 'wrap' } },
3743
3904
  (f.options || []).map((opt) =>
3744
3905
  h('label', { key: opt.value, style: { fontSize: '12px', display: 'flex', alignItems: 'center', gap: '6px', cursor: 'pointer' } },
3745
3906
  h('input', {
@@ -3754,19 +3915,26 @@ window.__ModuleLoader__.load({
3754
3915
  )
3755
3916
  )
3756
3917
  : h('input', {
3757
- type: 'text',
3918
+ type: f.type === 'number' ? 'number' : (f.type === 'password' ? 'password' : 'text'),
3758
3919
  className: 'dgen-form-input',
3759
3920
  placeholder: f.placeholder || '',
3760
3921
  value: formData[f.name] || '',
3761
3922
  onChange: (e) => handleChange(f.name, e.target.value),
3762
- })
3923
+ }),
3924
+ f.error && h('div', { className: 'dgen-form-error' }, '⚠ ' + f.error)
3763
3925
  );
3764
3926
  }),
3765
- h('button', {
3766
- type: 'submit',
3767
- className: 'dgen-btn-primary',
3768
- style: { alignSelf: 'flex-start', marginTop: '8px' },
3769
- }, props.submitText || '提交')
3927
+ h('div', { style: { display: 'flex', alignItems: 'center', gap: '10px', marginTop: '8px' } },
3928
+ h('button', {
3929
+ type: 'submit',
3930
+ className: 'dgen-btn-primary',
3931
+ }, props.submitText || '提交保存'),
3932
+ props.resetText && h('button', {
3933
+ type: 'button',
3934
+ className: 'dgen-btn-secondary',
3935
+ onClick: () => setFormData({})
3936
+ }, props.resetText)
3937
+ )
3770
3938
  );
3771
3939
  },
3772
3940
 
@@ -3789,8 +3957,11 @@ window.__ModuleLoader__.load({
3789
3957
 
3790
3958
  return h('div', { className: 'dgen-task-card' },
3791
3959
  h('div', { className: 'dgen-node-card-head' },
3792
- h('h3', { className: 'dgen-node-title' }, 'Agent 任务执行进展'),
3793
- h('span', { className: 'dgen-version-badge' }, `${percent}% 完成`)
3960
+ h('div', { style: { display: 'flex', alignItems: 'center', gap: '8px' } },
3961
+ h('h3', { className: 'dgen-node-title' }, props.title || 'Agent 任务执行进展'),
3962
+ props.subtitle && h('span', { style: { fontSize: '11px', color: 'var(--dsw-alias-label-secondary)' } }, props.subtitle)
3963
+ ),
3964
+ h('span', { className: 'dgen-version-badge' }, `${percent}% 完成 (${completedCount}/${items.length})`)
3794
3965
  ),
3795
3966
  h('div', { style: { width: '100%', height: '5px', background: 'color-mix(in srgb, var(--dsw-alias-border-l4) 50%, transparent)', borderRadius: '3px', overflow: 'hidden' } },
3796
3967
  h('div', { style: { width: `${percent}%`, height: '100%', background: '#38a169', transition: 'width .2s ease' } })
@@ -3801,14 +3972,19 @@ window.__ModuleLoader__.load({
3801
3972
  key: it.id,
3802
3973
  className: 'dgen-task-item',
3803
3974
  style: { cursor: 'pointer' },
3804
- onClick: () => context.dispatchEvent('task_inspect', { stepId: it.id, status: it.status }, 'local'),
3975
+ onClick: () => context.dispatchEvent('task_inspect', { stepId: it.id, status: it.status, label: it.label }, 'local'),
3805
3976
  },
3806
3977
  h('span', { className: `dgen-task-dot dgen-task-${it.status || 'pending'}` }),
3807
- h('div', { style: { display: 'flex', flexDirection: 'column', flex: 1 } },
3808
- h('span', { style: { fontSize: '12px', fontWeight: 600, color: 'var(--dsw-alias-label-primary)' } }, it.label),
3809
- it.details && h('span', { style: { fontSize: '11px', color: 'var(--dsw-alias-label-secondary)' } }, it.details)
3978
+ h('div', { style: { display: 'flex', flexDirection: 'column', flex: 1, gap: '2px' } },
3979
+ h('div', { style: { display: 'flex', alignItems: 'center', gap: '8px' } },
3980
+ h('span', { style: { fontSize: '12px', fontWeight: 650, color: 'var(--dsw-alias-label-primary)' } }, it.label || it.title),
3981
+ it.duration && h('span', { className: 'dgen-task-duration' }, it.duration)
3982
+ ),
3983
+ (it.details || it.description) && h('span', { style: { fontSize: '11px', color: 'var(--dsw-alias-label-secondary)', lineHeight: 1.4 } }, it.details || it.description)
3810
3984
  ),
3811
- h('span', { style: { fontSize: '11px', textTransform: 'capitalize', fontWeight: 600, color: 'var(--dsw-alias-label-secondary)' } }, it.status)
3985
+ h('span', { style: { fontSize: '11px', textTransform: 'capitalize', fontWeight: 600, color: it.status === 'completed' ? '#38a169' : (it.status === 'running' ? 'var(--dsw-alias-brand-primary,#3b82f6)' : (it.status === 'failed' ? '#e53e3e' : 'var(--dsw-alias-label-secondary)')) } },
3986
+ it.status === 'completed' ? '✓ 完成' : (it.status === 'running' ? '● 进行中' : (it.status === 'failed' ? '✕ 失败' : '○ 待就绪'))
3987
+ )
3812
3988
  )
3813
3989
  )
3814
3990
  )
@@ -3910,11 +4086,13 @@ window.__ModuleLoader__.load({
3910
4086
  },
3911
4087
 
3912
4088
  stack(props, context) {
4089
+ const noDiv = props.divider === false || props.noDivider === true;
3913
4090
  return h('div', {
4091
+ className: noDiv ? 'dgen-layout-stack-nodiv' : '',
3914
4092
  style: {
3915
4093
  display: 'flex',
3916
4094
  flexDirection: props.direction === 'horizontal' ? 'row' : 'column',
3917
- gap: props.gap || '10px',
4095
+ gap: props.gap || '12px',
3918
4096
  alignItems: props.align || 'stretch',
3919
4097
  justifyContent: props.justify || 'flex-start',
3920
4098
  width: '100%'
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@civilization/deepseek-genui",
3
- "version": "1.0.2",
3
+ "version": "1.0.3",
4
4
  "description": "Enterprise-ready GenUI panel bundle for DeepSeek Harness (DSH 0.2.2-rc.3) with 7-dimensional component system, offline Mermaid/ReactFlow, and host fault isolation.",
5
5
  "type": "module",
6
6
  "main": "index.js",