@civilization/deepseek-genui 1.0.1 → 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.
- package/README.md +23 -0
- package/client.js +346 -157
- package/index.js +39 -3
- package/package.json +2 -2
- package/skills/agent-genui/SKILL.md +10 -8
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
|
-
|
|
209
|
+
|
|
210
210
|
'.dgen-table{width:100%;border-collapse:collapse;font-size:12px;text-align:left}',
|
|
211
|
-
'.dgen-table
|
|
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 || '全时段请求热度分布 (
|
|
2261
|
-
h('p', { className: 'dgen-node-desc' },
|
|
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]
|
|
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,
|
|
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
|
-
|
|
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)' } }, '
|
|
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)' } }, '
|
|
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,
|
|
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
|
);
|
|
@@ -2515,7 +2532,7 @@ window.__ModuleLoader__.load({
|
|
|
2515
2532
|
/**
|
|
2516
2533
|
* Component: DiffViewer (Git-Style Split/Unified Code Difference)
|
|
2517
2534
|
*/
|
|
2518
|
-
function DiffViewer({ title, oldHeader, newHeader, diffText, lines }) {
|
|
2535
|
+
function DiffViewer({ title, oldHeader, newHeader, diffText, lines, oldCode, newCode, filename }) {
|
|
2519
2536
|
const parsedLines = useMemo(() => {
|
|
2520
2537
|
if (lines && Array.isArray(lines)) return lines;
|
|
2521
2538
|
if (diffText && typeof diffText === 'string') {
|
|
@@ -2525,13 +2542,21 @@ window.__ModuleLoader__.load({
|
|
|
2525
2542
|
return { type: 'same', content: l.startsWith(' ') ? l.slice(1) : l, oldNum: i + 1, newNum: i + 1 };
|
|
2526
2543
|
});
|
|
2527
2544
|
}
|
|
2545
|
+
if (typeof oldCode === 'string' || typeof newCode === 'string') {
|
|
2546
|
+
const oldList = (oldCode || '').split('\n');
|
|
2547
|
+
const newList = (newCode || '').split('\n');
|
|
2548
|
+
const res = [];
|
|
2549
|
+
oldList.forEach((l, i) => res.push({ type: 'del', content: l, oldNum: i + 1, newNum: null }));
|
|
2550
|
+
newList.forEach((l, i) => res.push({ type: 'add', content: l, oldNum: null, newNum: i + 1 }));
|
|
2551
|
+
return res;
|
|
2552
|
+
}
|
|
2528
2553
|
return [
|
|
2529
2554
|
{ type: 'same', content: 'const server = express();', oldNum: 1, newNum: 1 },
|
|
2530
2555
|
{ type: 'del', content: 'server.use(cors({ origin: "*" })); // ⚠️ 存在通配符安全隐患', oldNum: 2, newNum: null },
|
|
2531
2556
|
{ type: 'add', content: 'server.use(cors({ origin: allowedOrigins, credentials: true })); // ✓ 精确放行白名单', oldNum: null, newNum: 2 },
|
|
2532
2557
|
{ type: 'same', content: 'server.listen(port);', oldNum: 3, newNum: 3 },
|
|
2533
2558
|
];
|
|
2534
|
-
}, [lines, diffText]);
|
|
2559
|
+
}, [lines, diffText, oldCode, newCode]);
|
|
2535
2560
|
|
|
2536
2561
|
return h('div', { className: 'dgen-diff-card' },
|
|
2537
2562
|
h('div', { className: 'dgen-node-card-head' },
|
|
@@ -3026,6 +3051,32 @@ window.__ModuleLoader__.load({
|
|
|
3026
3051
|
}
|
|
3027
3052
|
|
|
3028
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
|
+
|
|
3029
3080
|
const Renderers = {
|
|
3030
3081
|
card(props, context) {
|
|
3031
3082
|
const items = props.items || props.sections || [];
|
|
@@ -3088,11 +3139,16 @@ window.__ModuleLoader__.load({
|
|
|
3088
3139
|
)
|
|
3089
3140
|
))
|
|
3090
3141
|
),
|
|
3091
|
-
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))
|
|
3092
3143
|
);
|
|
3093
3144
|
},
|
|
3094
3145
|
|
|
3095
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
|
+
|
|
3096
3152
|
return h('div', { className: 'dgen-metric-tile' },
|
|
3097
3153
|
props.title && h('span', {
|
|
3098
3154
|
style: {
|
|
@@ -3107,7 +3163,7 @@ window.__ModuleLoader__.load({
|
|
|
3107
3163
|
h('div', { className: 'dgen-metric-box' },
|
|
3108
3164
|
h('span', { className: 'dgen-metric-val' }, props.value ?? '--'),
|
|
3109
3165
|
props.unit && h('span', { className: 'dgen-metric-unit' }, props.unit),
|
|
3110
|
-
props.change && h('span', { className: `dgen-metric-change
|
|
3166
|
+
props.change && h('span', { className: `dgen-metric-change ${trendClass}` }, (isDown ? '↓ ' : '↑ ') + props.change)
|
|
3111
3167
|
),
|
|
3112
3168
|
props.description && h('p', { className: 'dgen-node-desc', style: { fontSize: '11px', color: 'var(--dsw-alias-label-tertiary)', margin: '2px 0 0' } }, props.description)
|
|
3113
3169
|
);
|
|
@@ -3144,13 +3200,23 @@ window.__ModuleLoader__.load({
|
|
|
3144
3200
|
);
|
|
3145
3201
|
},
|
|
3146
3202
|
|
|
3147
|
-
chart(props) {
|
|
3203
|
+
chart(props, context) {
|
|
3148
3204
|
const chartType = props.chartType || 'line';
|
|
3149
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
|
+
};
|
|
3150
3216
|
|
|
3151
|
-
// 1. Line Chart
|
|
3217
|
+
// 1. Line Chart
|
|
3152
3218
|
if (chartType === 'line') {
|
|
3153
|
-
const maxVal = Math.max(...series.map((s) => s.value || 0),
|
|
3219
|
+
const maxVal = Math.max(...series.map((s) => s.value || 0), 10);
|
|
3154
3220
|
const plotW = 280;
|
|
3155
3221
|
const plotH = 80;
|
|
3156
3222
|
const leftX = 45;
|
|
@@ -3158,20 +3224,21 @@ window.__ModuleLoader__.load({
|
|
|
3158
3224
|
|
|
3159
3225
|
const pts = series.map((s, idx) => {
|
|
3160
3226
|
const x = leftX + (idx / Math.max(series.length - 1, 1)) * plotW;
|
|
3161
|
-
const y = baseY - (s.value / maxVal) * plotH;
|
|
3227
|
+
const y = baseY - ((s.value || 0) / maxVal) * plotH;
|
|
3162
3228
|
return `${x},${y}`;
|
|
3163
3229
|
}).join(' ');
|
|
3164
3230
|
|
|
3165
3231
|
return h('div', { className: 'dgen-chart-block' },
|
|
3166
3232
|
props.title && h('h3', { className: 'dgen-node-title' }, props.title),
|
|
3167
|
-
h('
|
|
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' } },
|
|
3168
3235
|
// Grid lines & Y scale
|
|
3169
3236
|
[0, 0.33, 0.66, 1].map((ratio, i) => {
|
|
3170
3237
|
const y = baseY - ratio * plotH;
|
|
3171
3238
|
const val = Math.round(ratio * maxVal);
|
|
3172
3239
|
return h('g', { key: i },
|
|
3173
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 }),
|
|
3174
|
-
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 : ''))
|
|
3175
3242
|
);
|
|
3176
3243
|
}),
|
|
3177
3244
|
// Axes
|
|
@@ -3185,146 +3252,229 @@ window.__ModuleLoader__.load({
|
|
|
3185
3252
|
strokeLinecap: 'round',
|
|
3186
3253
|
points: pts,
|
|
3187
3254
|
}),
|
|
3188
|
-
// Points & X Labels
|
|
3255
|
+
// Points & X Labels (抽样防重叠 + 原生 title 悬浮浮层)
|
|
3189
3256
|
series.map((s, idx) => {
|
|
3190
3257
|
const cx = leftX + (idx / Math.max(series.length - 1, 1)) * plotW;
|
|
3191
|
-
const cy = baseY - (s.value / maxVal) * plotH;
|
|
3258
|
+
const cy = baseY - ((s.value || 0) / maxVal) * plotH;
|
|
3259
|
+
const showLabel = shouldShowXLabel(idx, series.length);
|
|
3192
3260
|
return h('g', { key: idx },
|
|
3193
|
-
h('circle', {
|
|
3194
|
-
|
|
3195
|
-
|
|
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
|
+
)
|
|
3196
3276
|
);
|
|
3197
3277
|
}),
|
|
3198
|
-
h('text', { x: leftX + plotW, y: baseY + 28, textAnchor: 'end', fontSize: 9, fill: 'var(--dsw-alias-label-tertiary)' },
|
|
3278
|
+
xAxisTitle && h('text', { x: leftX + plotW, y: baseY + 28, textAnchor: 'end', fontSize: 9, fill: 'var(--dsw-alias-label-tertiary)' }, xAxisTitle)
|
|
3199
3279
|
)
|
|
3200
3280
|
);
|
|
3201
3281
|
}
|
|
3202
3282
|
|
|
3203
|
-
// 2. Area Chart
|
|
3283
|
+
// 2. Area Chart
|
|
3204
3284
|
if (chartType === 'area') {
|
|
3205
|
-
const maxVal = Math.max(...series.map((s) => s.value || 0),
|
|
3285
|
+
const maxVal = Math.max(...series.map((s) => s.value || 0), 10);
|
|
3206
3286
|
const plotW = 280;
|
|
3207
3287
|
const plotH = 80;
|
|
3208
3288
|
const leftX = 45;
|
|
3209
3289
|
const baseY = 100;
|
|
3290
|
+
const gradId = 'dgen_area_grad_' + Math.abs(Math.random() * 100000 | 0);
|
|
3210
3291
|
|
|
3211
3292
|
const linePts = series.map((s, idx) => {
|
|
3212
3293
|
const x = leftX + (idx / Math.max(series.length - 1, 1)) * plotW;
|
|
3213
|
-
const y = baseY - (s.value / maxVal) * plotH;
|
|
3294
|
+
const y = baseY - ((s.value || 0) / maxVal) * plotH;
|
|
3214
3295
|
return `${x},${y}`;
|
|
3215
3296
|
});
|
|
3216
3297
|
const polyPts = `${leftX},${baseY} ${linePts.join(' ')} ${leftX + plotW},${baseY}`;
|
|
3217
3298
|
|
|
3218
3299
|
return h('div', { className: 'dgen-chart-block' },
|
|
3219
3300
|
props.title && h('h3', { className: 'dgen-node-title' }, props.title),
|
|
3220
|
-
h('
|
|
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
|
+
),
|
|
3221
3309
|
[0, 0.33, 0.66, 1].map((ratio, i) => {
|
|
3222
3310
|
const y = baseY - ratio * plotH;
|
|
3223
3311
|
const val = Math.round(ratio * maxVal);
|
|
3224
3312
|
return h('g', { key: i },
|
|
3225
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 }),
|
|
3226
|
-
h('text', { x: leftX - 6, y: y + 3, textAnchor: 'end', fontSize: 9, fill: 'var(--dsw-alias-label-tertiary)' }, val + '
|
|
3314
|
+
h('text', { x: leftX - 6, y: y + 3, textAnchor: 'end', fontSize: 9, fill: 'var(--dsw-alias-label-tertiary)' }, val + (i === 3 && unit ? unit : ''))
|
|
3227
3315
|
);
|
|
3228
3316
|
}),
|
|
3229
3317
|
h('line', { x1: leftX, y1: baseY - plotH - 5, x2: leftX, y2: baseY, stroke: 'var(--dsw-alias-border-l4)', strokeWidth: 1.2 }),
|
|
3230
3318
|
h('line', { x1: leftX, y1: baseY, x2: leftX + plotW + 10, y2: baseY, stroke: 'var(--dsw-alias-border-l4)', strokeWidth: 1.2 }),
|
|
3231
|
-
h('polygon', { fill:
|
|
3232
|
-
h('polyline', {
|
|
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
|
+
}),
|
|
3233
3327
|
series.map((s, idx) => {
|
|
3234
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);
|
|
3235
3331
|
return h('g', { key: idx },
|
|
3236
|
-
h('
|
|
3237
|
-
|
|
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
|
+
)
|
|
3238
3347
|
);
|
|
3239
3348
|
}),
|
|
3240
|
-
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)
|
|
3241
3350
|
)
|
|
3242
3351
|
);
|
|
3243
3352
|
}
|
|
3244
3353
|
|
|
3245
|
-
// 3. Bar Chart
|
|
3354
|
+
// 3. Bar Chart
|
|
3246
3355
|
if (chartType === 'bar') {
|
|
3247
|
-
const maxVal = Math.max(...series.map((s) => s.value || 0),
|
|
3356
|
+
const maxVal = Math.max(...series.map((s) => s.value || 0), 10);
|
|
3248
3357
|
const plotW = 280;
|
|
3249
3358
|
const plotH = 80;
|
|
3250
3359
|
const leftX = 45;
|
|
3251
3360
|
const baseY = 100;
|
|
3252
|
-
const
|
|
3253
|
-
const slotW = plotW / colCount;
|
|
3254
|
-
const barW = Math.min(slotW * 0.55, 34);
|
|
3361
|
+
const barW = Math.max(Math.min(plotW / (series.length || 1) - 8, 28), 6);
|
|
3255
3362
|
|
|
3256
3363
|
return h('div', { className: 'dgen-chart-block' },
|
|
3257
3364
|
props.title && h('h3', { className: 'dgen-node-title' }, props.title),
|
|
3258
|
-
h('
|
|
3259
|
-
|
|
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) => {
|
|
3260
3368
|
const y = baseY - ratio * plotH;
|
|
3261
3369
|
const val = Math.round(ratio * maxVal);
|
|
3262
3370
|
return h('g', { key: i },
|
|
3263
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 }),
|
|
3264
|
-
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 : ''))
|
|
3265
3373
|
);
|
|
3266
3374
|
}),
|
|
3267
3375
|
h('line', { x1: leftX, y1: baseY - plotH - 5, x2: leftX, y2: baseY, stroke: 'var(--dsw-alias-border-l4)', strokeWidth: 1.2 }),
|
|
3268
3376
|
h('line', { x1: leftX, y1: baseY, x2: leftX + plotW + 10, y2: baseY, stroke: 'var(--dsw-alias-border-l4)', strokeWidth: 1.2 }),
|
|
3269
|
-
series.map((s,
|
|
3270
|
-
const
|
|
3271
|
-
const
|
|
3272
|
-
const
|
|
3273
|
-
const
|
|
3274
|
-
|
|
3275
|
-
|
|
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 },
|
|
3276
3384
|
h('rect', {
|
|
3277
|
-
x
|
|
3278
|
-
y
|
|
3385
|
+
x,
|
|
3386
|
+
y,
|
|
3279
3387
|
width: barW,
|
|
3280
|
-
height:
|
|
3388
|
+
height: hVal,
|
|
3281
3389
|
rx: 3,
|
|
3282
|
-
fill: 'var(--dsw-alias-brand-primary,#3b82f6)',
|
|
3283
|
-
|
|
3284
|
-
|
|
3285
|
-
|
|
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)
|
|
3286
3403
|
);
|
|
3287
3404
|
}),
|
|
3288
|
-
h('text', { x: leftX + plotW, y: baseY +
|
|
3405
|
+
xAxisTitle && h('text', { x: leftX + plotW, y: baseY + 28, textAnchor: 'end', fontSize: 9, fill: 'var(--dsw-alias-label-tertiary)' }, xAxisTitle)
|
|
3289
3406
|
)
|
|
3290
3407
|
);
|
|
3291
3408
|
}
|
|
3292
3409
|
|
|
3293
|
-
// 4. Donut / Pie Chart
|
|
3410
|
+
// 4. Donut / Pie Chart (12 色调色板)
|
|
3294
3411
|
if (chartType === 'donut' || chartType === 'pie') {
|
|
3295
|
-
const
|
|
3296
|
-
|
|
3297
|
-
|
|
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
|
+
});
|
|
3298
3430
|
|
|
3299
3431
|
return h('div', { className: 'dgen-chart-block' },
|
|
3300
3432
|
props.title && h('h3', { className: 'dgen-node-title' }, props.title),
|
|
3301
|
-
h('
|
|
3302
|
-
|
|
3303
|
-
|
|
3304
|
-
|
|
3305
|
-
|
|
3306
|
-
|
|
3307
|
-
|
|
3308
|
-
|
|
3309
|
-
|
|
3310
|
-
|
|
3311
|
-
|
|
3312
|
-
|
|
3313
|
-
|
|
3314
|
-
|
|
3315
|
-
|
|
3316
|
-
|
|
3317
|
-
|
|
3318
|
-
|
|
3319
|
-
|
|
3320
|
-
|
|
3321
|
-
|
|
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
|
+
)
|
|
3322
3469
|
),
|
|
3323
|
-
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' } },
|
|
3324
3471
|
series.map((s, i) =>
|
|
3325
|
-
h('div', { key: i, style: { display: 'flex', alignItems: 'center', gap: '8px' } },
|
|
3326
|
-
h('
|
|
3327
|
-
|
|
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)}%)`)
|
|
3328
3478
|
)
|
|
3329
3479
|
)
|
|
3330
3480
|
)
|
|
@@ -3332,31 +3482,36 @@ window.__ModuleLoader__.load({
|
|
|
3332
3482
|
);
|
|
3333
3483
|
}
|
|
3334
3484
|
|
|
3335
|
-
// 5. Gauge Chart
|
|
3485
|
+
// 5. Gauge Chart (带有平滑过渡)
|
|
3336
3486
|
if (chartType === 'gauge') {
|
|
3337
3487
|
const val = props.value || 0;
|
|
3338
|
-
const
|
|
3488
|
+
const maxVal = props.max || 100;
|
|
3489
|
+
const pct = Math.min(Math.max((val / maxVal) * 100, 0), 100);
|
|
3339
3490
|
|
|
3340
3491
|
return h('div', { className: 'dgen-chart-block', style: { alignItems: 'center', textAlign: 'center' } },
|
|
3341
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),
|
|
3342
3494
|
h('svg', { viewBox: '0 0 140 85', width: 160, height: 95, style: { marginTop: '8px' } },
|
|
3343
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' }),
|
|
3344
3496
|
h('path', {
|
|
3345
3497
|
d: 'M 15 75 A 55 55 0 0 1 125 75',
|
|
3346
3498
|
fill: 'none',
|
|
3347
|
-
stroke: pct >
|
|
3499
|
+
stroke: pct > 85 ? '#38a169' : pct > 60 ? 'var(--dsw-alias-brand-primary,#3b82f6)' : (pct > 30 ? '#d69e2e' : '#e53e3e'),
|
|
3348
3500
|
strokeWidth: 12,
|
|
3349
3501
|
strokeLinecap: 'round',
|
|
3350
3502
|
strokeDasharray: '172.78',
|
|
3351
3503
|
strokeDashoffset: 172.78 * (1 - pct / 100),
|
|
3352
|
-
|
|
3353
|
-
|
|
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}`)
|
|
3354
3509
|
),
|
|
3355
|
-
h('span', { style: { fontSize: '11px', color: 'var(--dsw-alias-label-secondary)' } }, `目标基线: ${props.target
|
|
3510
|
+
props.target && h('span', { style: { fontSize: '11px', color: 'var(--dsw-alias-label-secondary)' } }, `目标基线: ${props.target}${unit}`)
|
|
3356
3511
|
);
|
|
3357
3512
|
}
|
|
3358
3513
|
|
|
3359
|
-
// 6. Scatter Plot
|
|
3514
|
+
// 6. Scatter Plot (自适应 X/Y 轴坐标)
|
|
3360
3515
|
if (chartType === 'scatter') {
|
|
3361
3516
|
const pts = props.points || [];
|
|
3362
3517
|
const leftX = 45;
|
|
@@ -3364,49 +3519,62 @@ window.__ModuleLoader__.load({
|
|
|
3364
3519
|
const plotW = 280;
|
|
3365
3520
|
const plotH = 80;
|
|
3366
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
|
+
|
|
3367
3525
|
return h('div', { className: 'dgen-chart-block' },
|
|
3368
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),
|
|
3369
3528
|
h('svg', { viewBox: '0 0 350 145', style: { width: '100%', height: '160px', marginTop: '6px' } },
|
|
3370
3529
|
[0, 0.25, 0.5, 0.75, 1].map((ratio, i) => {
|
|
3371
3530
|
const y = baseY - ratio * plotH;
|
|
3372
|
-
const val = Math.round(ratio *
|
|
3531
|
+
const val = Math.round(ratio * maxY);
|
|
3373
3532
|
return h('g', { key: i },
|
|
3374
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 }),
|
|
3375
|
-
h('text', { x: leftX - 6, y: y + 3, textAnchor: 'end', fontSize: 9, fill: 'var(--dsw-alias-label-tertiary)' }, val + '
|
|
3534
|
+
h('text', { x: leftX - 6, y: y + 3, textAnchor: 'end', fontSize: 9, fill: 'var(--dsw-alias-label-tertiary)' }, val + (i === 4 && unit ? unit : ''))
|
|
3376
3535
|
);
|
|
3377
3536
|
}),
|
|
3378
3537
|
h('line', { x1: leftX, y1: baseY - plotH - 5, x2: leftX, y2: baseY, stroke: 'var(--dsw-alias-border-l4)', strokeWidth: 1.2 }),
|
|
3379
3538
|
h('line', { x1: leftX, y1: baseY, x2: leftX + plotW + 10, y2: baseY, stroke: 'var(--dsw-alias-border-l4)', strokeWidth: 1.2 }),
|
|
3380
|
-
[0,
|
|
3381
|
-
const
|
|
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;
|
|
3382
3542
|
return h('g', { key: ti },
|
|
3383
3543
|
h('line', { x1: tx, y1: baseY, x2: tx, y2: baseY + 4, stroke: 'var(--dsw-alias-border-l4)' }),
|
|
3384
|
-
h('text', { x: tx, y: baseY + 16, textAnchor: 'middle', fontSize: 9, fill: 'var(--dsw-alias-label-secondary)' }, tVal
|
|
3544
|
+
h('text', { x: tx, y: baseY + 16, textAnchor: 'middle', fontSize: 9, fill: 'var(--dsw-alias-label-secondary)' }, tVal)
|
|
3385
3545
|
);
|
|
3386
3546
|
}),
|
|
3387
|
-
h('text', { x: leftX + plotW, y: baseY + 30, textAnchor: 'end', fontSize: 9, fill: 'var(--dsw-alias-label-tertiary)' },
|
|
3547
|
+
xAxisTitle && h('text', { x: leftX + plotW, y: baseY + 30, textAnchor: 'end', fontSize: 9, fill: 'var(--dsw-alias-label-tertiary)' }, xAxisTitle),
|
|
3388
3548
|
pts.map((p, idx) => {
|
|
3389
|
-
const cx = leftX + (p.x /
|
|
3390
|
-
const cy = baseY - (p.y /
|
|
3549
|
+
const cx = leftX + ((p.x || 0) / maxX) * plotW;
|
|
3550
|
+
const cy = baseY - ((p.y || 0) / maxY) * plotH;
|
|
3391
3551
|
return h('circle', {
|
|
3392
3552
|
key: idx,
|
|
3393
3553
|
cx,
|
|
3394
3554
|
cy,
|
|
3395
3555
|
r: 4.5,
|
|
3396
|
-
fill: 'var(--dsw-alias-brand-primary,#3b82f6)',
|
|
3556
|
+
fill: p.color || 'var(--dsw-alias-brand-primary,#3b82f6)',
|
|
3397
3557
|
stroke: 'var(--dsw-alias-bg-layer-2)',
|
|
3398
3558
|
strokeWidth: 1.5,
|
|
3399
|
-
|
|
3559
|
+
style: { cursor: 'pointer' }
|
|
3560
|
+
},
|
|
3561
|
+
h('title', null, p.label ? `${p.label}: (${p.x}, ${p.y})` : `(${p.x}, ${p.y})`)
|
|
3562
|
+
);
|
|
3400
3563
|
})
|
|
3401
3564
|
)
|
|
3402
3565
|
);
|
|
3403
3566
|
}
|
|
3404
3567
|
|
|
3405
|
-
// 7. Heatmap
|
|
3568
|
+
// 7. Heatmap
|
|
3406
3569
|
if (chartType === 'heatmap') {
|
|
3407
3570
|
return h(HeatmapChart, {
|
|
3408
3571
|
title: props.title,
|
|
3572
|
+
description: props.description,
|
|
3409
3573
|
dataset: props.dataset,
|
|
3574
|
+
xLabels: props.xLabels,
|
|
3575
|
+
yLabels: props.yLabels,
|
|
3576
|
+
summary: props.summary,
|
|
3577
|
+
context
|
|
3410
3578
|
});
|
|
3411
3579
|
}
|
|
3412
3580
|
|
|
@@ -3620,54 +3788,42 @@ window.__ModuleLoader__.load({
|
|
|
3620
3788
|
const nextOrder = sortKey === key && sortOrder === 'asc' ? 'desc' : 'asc';
|
|
3621
3789
|
setSortKey(key);
|
|
3622
3790
|
setSortOrder(nextOrder);
|
|
3623
|
-
if (context?.dispatchEvent) {
|
|
3624
|
-
context.dispatchEvent('sort', { column: key, order: nextOrder }, 'local');
|
|
3625
|
-
}
|
|
3626
3791
|
};
|
|
3627
3792
|
|
|
3793
|
+
const maxHeight = props.maxHeight || (rawRows.length > 8 ? '420px' : 'auto');
|
|
3794
|
+
|
|
3628
3795
|
return h('div', {
|
|
3629
3796
|
className: 'dgen-table-wrap',
|
|
3630
|
-
style: {
|
|
3631
|
-
width: '100%',
|
|
3632
|
-
overflowX: 'auto',
|
|
3633
|
-
border: '1px solid var(--dsw-alias-border-l4, #e2e8f0)',
|
|
3634
|
-
borderRadius: '10px',
|
|
3635
|
-
background: 'var(--dsw-alias-bg-layer-2, #ffffff)'
|
|
3636
|
-
}
|
|
3797
|
+
style: { maxHeight }
|
|
3637
3798
|
},
|
|
3638
|
-
|
|
3799
|
+
props.title && h('div', {
|
|
3639
3800
|
style: {
|
|
3640
3801
|
padding: '10px 14px',
|
|
3641
|
-
fontWeight: 650,
|
|
3642
|
-
fontSize: '13.5px',
|
|
3643
|
-
color: 'var(--dsw-alias-label-primary)',
|
|
3644
3802
|
borderBottom: '1px solid var(--dsw-alias-border-l4)',
|
|
3645
|
-
background: 'color-mix(in srgb, var(--dsw-alias-bg-layer-1)
|
|
3803
|
+
background: 'color-mix(in srgb, var(--dsw-alias-bg-layer-1) 40%, transparent)',
|
|
3804
|
+
display: 'flex',
|
|
3805
|
+
alignItems: 'center',
|
|
3806
|
+
justifyContent: 'space-between'
|
|
3646
3807
|
}
|
|
3647
|
-
}, props.title || props.header),
|
|
3648
|
-
h('table', {
|
|
3649
|
-
className: 'dgen-table',
|
|
3650
|
-
style: { width: '100%', borderCollapse: 'collapse', fontSize: '12.5px', textAlign: 'left' }
|
|
3651
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' },
|
|
3652
3813
|
h('thead', null,
|
|
3653
3814
|
h('tr', null,
|
|
3654
3815
|
normalizedColumns.map((c) =>
|
|
3655
3816
|
h('th', {
|
|
3656
3817
|
key: c.key,
|
|
3657
3818
|
style: {
|
|
3658
|
-
padding: '10px 14px',
|
|
3659
|
-
background: 'color-mix(in srgb, var(--dsw-alias-bg-layer-1) 55%, transparent)',
|
|
3660
|
-
fontWeight: 650,
|
|
3661
|
-
color: 'var(--dsw-alias-label-secondary)',
|
|
3662
|
-
cursor: 'pointer',
|
|
3663
|
-
borderBottom: '1px solid var(--dsw-alias-border-l4)',
|
|
3664
3819
|
textAlign: c.align || 'left',
|
|
3665
3820
|
width: c.width
|
|
3666
3821
|
},
|
|
3667
|
-
onClick: () => handleSort(c.key)
|
|
3822
|
+
onClick: () => handleSort(c.key),
|
|
3823
|
+
title: '点击切换升序/降序'
|
|
3668
3824
|
},
|
|
3669
3825
|
c.label,
|
|
3670
|
-
sortKey === c.key ? (sortOrder === 'asc' ? '
|
|
3826
|
+
sortKey === c.key ? (sortOrder === 'asc' ? ' ▲' : ' ▼') : ''
|
|
3671
3827
|
)
|
|
3672
3828
|
)
|
|
3673
3829
|
)
|
|
@@ -3695,11 +3851,20 @@ window.__ModuleLoader__.load({
|
|
|
3695
3851
|
h('tr', null,
|
|
3696
3852
|
h('td', {
|
|
3697
3853
|
colSpan: Math.max(normalizedColumns.length, 1),
|
|
3698
|
-
style: { textAlign: 'center', padding: '
|
|
3699
|
-
},
|
|
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
|
+
)
|
|
3700
3861
|
)
|
|
3701
3862
|
)
|
|
3702
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} 条`)
|
|
3703
3868
|
)
|
|
3704
3869
|
);
|
|
3705
3870
|
},
|
|
@@ -3719,9 +3884,13 @@ window.__ModuleLoader__.load({
|
|
|
3719
3884
|
|
|
3720
3885
|
return h('form', { className: 'dgen-business-card dgen-form', onSubmit: handleSubmit },
|
|
3721
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),
|
|
3722
3888
|
fields.map((f) => {
|
|
3723
3889
|
return h('div', { key: f.name, className: 'dgen-form-group' },
|
|
3724
|
-
h('label', { className: 'dgen-form-label'
|
|
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
|
+
),
|
|
3725
3894
|
f.type === 'select'
|
|
3726
3895
|
? h('select', {
|
|
3727
3896
|
className: 'dgen-form-input',
|
|
@@ -3731,7 +3900,7 @@ window.__ModuleLoader__.load({
|
|
|
3731
3900
|
(f.options || []).map((opt) => h('option', { key: opt.value, value: opt.value }, opt.label))
|
|
3732
3901
|
)
|
|
3733
3902
|
: f.type === 'radio'
|
|
3734
|
-
? h('div', { style: { display: 'flex', gap: '14px', marginTop: '4px' } },
|
|
3903
|
+
? h('div', { style: { display: 'flex', gap: '14px', marginTop: '4px', flexWrap: 'wrap' } },
|
|
3735
3904
|
(f.options || []).map((opt) =>
|
|
3736
3905
|
h('label', { key: opt.value, style: { fontSize: '12px', display: 'flex', alignItems: 'center', gap: '6px', cursor: 'pointer' } },
|
|
3737
3906
|
h('input', {
|
|
@@ -3746,19 +3915,26 @@ window.__ModuleLoader__.load({
|
|
|
3746
3915
|
)
|
|
3747
3916
|
)
|
|
3748
3917
|
: h('input', {
|
|
3749
|
-
type: 'text',
|
|
3918
|
+
type: f.type === 'number' ? 'number' : (f.type === 'password' ? 'password' : 'text'),
|
|
3750
3919
|
className: 'dgen-form-input',
|
|
3751
3920
|
placeholder: f.placeholder || '',
|
|
3752
3921
|
value: formData[f.name] || '',
|
|
3753
3922
|
onChange: (e) => handleChange(f.name, e.target.value),
|
|
3754
|
-
})
|
|
3923
|
+
}),
|
|
3924
|
+
f.error && h('div', { className: 'dgen-form-error' }, '⚠ ' + f.error)
|
|
3755
3925
|
);
|
|
3756
3926
|
}),
|
|
3757
|
-
h('
|
|
3758
|
-
|
|
3759
|
-
|
|
3760
|
-
|
|
3761
|
-
|
|
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
|
+
)
|
|
3762
3938
|
);
|
|
3763
3939
|
},
|
|
3764
3940
|
|
|
@@ -3781,8 +3957,11 @@ window.__ModuleLoader__.load({
|
|
|
3781
3957
|
|
|
3782
3958
|
return h('div', { className: 'dgen-task-card' },
|
|
3783
3959
|
h('div', { className: 'dgen-node-card-head' },
|
|
3784
|
-
h('
|
|
3785
|
-
|
|
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})`)
|
|
3786
3965
|
),
|
|
3787
3966
|
h('div', { style: { width: '100%', height: '5px', background: 'color-mix(in srgb, var(--dsw-alias-border-l4) 50%, transparent)', borderRadius: '3px', overflow: 'hidden' } },
|
|
3788
3967
|
h('div', { style: { width: `${percent}%`, height: '100%', background: '#38a169', transition: 'width .2s ease' } })
|
|
@@ -3793,14 +3972,19 @@ window.__ModuleLoader__.load({
|
|
|
3793
3972
|
key: it.id,
|
|
3794
3973
|
className: 'dgen-task-item',
|
|
3795
3974
|
style: { cursor: 'pointer' },
|
|
3796
|
-
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'),
|
|
3797
3976
|
},
|
|
3798
3977
|
h('span', { className: `dgen-task-dot dgen-task-${it.status || 'pending'}` }),
|
|
3799
|
-
h('div', { style: { display: 'flex', flexDirection: 'column', flex: 1 } },
|
|
3800
|
-
h('
|
|
3801
|
-
|
|
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)
|
|
3802
3984
|
),
|
|
3803
|
-
h('span', { style: { fontSize: '11px', textTransform: 'capitalize', fontWeight: 600, color: 'var(--dsw-alias-label-secondary)' } },
|
|
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
|
+
)
|
|
3804
3988
|
)
|
|
3805
3989
|
)
|
|
3806
3990
|
)
|
|
@@ -3902,11 +4086,13 @@ window.__ModuleLoader__.load({
|
|
|
3902
4086
|
},
|
|
3903
4087
|
|
|
3904
4088
|
stack(props, context) {
|
|
4089
|
+
const noDiv = props.divider === false || props.noDivider === true;
|
|
3905
4090
|
return h('div', {
|
|
4091
|
+
className: noDiv ? 'dgen-layout-stack-nodiv' : '',
|
|
3906
4092
|
style: {
|
|
3907
4093
|
display: 'flex',
|
|
3908
4094
|
flexDirection: props.direction === 'horizontal' ? 'row' : 'column',
|
|
3909
|
-
gap: props.gap || '
|
|
4095
|
+
gap: props.gap || '12px',
|
|
3910
4096
|
alignItems: props.align || 'stretch',
|
|
3911
4097
|
justifyContent: props.justify || 'flex-start',
|
|
3912
4098
|
width: '100%'
|
|
@@ -3988,6 +4174,9 @@ window.__ModuleLoader__.load({
|
|
|
3988
4174
|
diffViewer(props) {
|
|
3989
4175
|
return h(DiffViewer, props);
|
|
3990
4176
|
},
|
|
4177
|
+
diff(props) {
|
|
4178
|
+
return h(DiffViewer, props);
|
|
4179
|
+
},
|
|
3991
4180
|
|
|
3992
4181
|
jsonViewer(props) {
|
|
3993
4182
|
return h(JsonViewer, props);
|
package/index.js
CHANGED
|
@@ -7,20 +7,21 @@ export const name = 'deepseek-genui';
|
|
|
7
7
|
export const inject = {
|
|
8
8
|
webServer: { optional: true },
|
|
9
9
|
skills: { optional: true },
|
|
10
|
+
systemPrompt: { optional: true },
|
|
10
11
|
};
|
|
11
12
|
|
|
12
13
|
const vendorRoot = fileURLToPath(new URL('./vendor/', import.meta.url));
|
|
13
14
|
|
|
14
15
|
export async function apply(ctx) {
|
|
15
|
-
// 1. 注册 DSH Agent Skill
|
|
16
|
+
// 1. 注册 DSH Agent Skill 认知协议(按需备用)
|
|
16
17
|
try {
|
|
17
18
|
const skillPath = new URL('./skills/agent-genui/SKILL.md', import.meta.url);
|
|
18
19
|
const skillText = await readFile(skillPath, 'utf8');
|
|
19
20
|
const content = skillText.replace(/^---\r?\n[\s\S]*?\r?\n---\r?\n/, '').trim();
|
|
20
21
|
ctx.effect(() => ctx.skills?.register({
|
|
21
22
|
name: 'agent-genui',
|
|
22
|
-
description: '
|
|
23
|
-
whenToUse: '
|
|
23
|
+
description: '图表可视化与交互组件引擎。生成基于 agent-genui 协议的高保真、交互式卡片、图表与架构可视化界面组件(GenUI),聊天对话流将自动就地渲染。',
|
|
24
|
+
whenToUse: '当需要生成数据大屏、指标看板、趋势图表、流程图、架构拓扑、时序图、生命周期状态机、交互表单、方案对比或需要以可视化界面呈现时使用。',
|
|
24
25
|
source: 'bundled',
|
|
25
26
|
content,
|
|
26
27
|
}));
|
|
@@ -28,6 +29,41 @@ export async function apply(ctx) {
|
|
|
28
29
|
// 容错处理:即使读取 skill 异常也不影响其余服务
|
|
29
30
|
}
|
|
30
31
|
|
|
32
|
+
// 2. 向模型注入常驻 Generative UI 认知,免去调用 skill 工具的额外轮次阻塞
|
|
33
|
+
if (ctx.systemPrompt) {
|
|
34
|
+
ctx.effect(() => ctx.systemPrompt.section({
|
|
35
|
+
name: 'agent-genui-guidance',
|
|
36
|
+
order: ctx.systemPrompt.getSectionOrder?.('STRUCTURED_OUTPUT') ?? 9900,
|
|
37
|
+
text: `
|
|
38
|
+
## 可视化交互卡片 (Generative UI) 协议
|
|
39
|
+
当回复中需要展示以下场景时,**优先输出包裹在 \`\`\`agent-genui 代码块中的结构化 JSON**,聊天界面会自动将其就地渲染为高保真活体交互卡片,严禁仅使用纯文本或 ASCII 字符画替代:
|
|
40
|
+
1. **指标与趋势图表**:KPI 指标看板(type: "metric")、数据图表(type: "chart",chartType 支持 "line" | "bar" | "area" | "pie" | "donut" | "heatmap" | "gauge");
|
|
41
|
+
2. **架构拓扑与流程**:服务分层架构(type: "diagram", diagramType: "architecture")、流程图(diagramType: "flowchart")、时序交互图(diagramType: "sequence");
|
|
42
|
+
3. **方案对比决策**:方案多维评分对比与采纳(type: "comparison");
|
|
43
|
+
4. **数据表格与代码变更**:数据列表(type: "table")、代码变更比对(type: "diffViewer" 或 "diff")、任务流水线(type: "taskPlan")。
|
|
44
|
+
|
|
45
|
+
输出格式规范:
|
|
46
|
+
先输出 1-2 句核心分析结论,紧接着输出代码块:
|
|
47
|
+
\`\`\`agent-genui
|
|
48
|
+
{
|
|
49
|
+
"protocol": "agent-genui",
|
|
50
|
+
"version": "1.0",
|
|
51
|
+
"id": "ui_card_id",
|
|
52
|
+
"title": "卡片标题",
|
|
53
|
+
"layout": { "type": "stack", "gap": "md" },
|
|
54
|
+
"children": [
|
|
55
|
+
{
|
|
56
|
+
"id": "node_1",
|
|
57
|
+
"type": "metric",
|
|
58
|
+
"props": { "title": "指标名称", "value": "12,480", "unit": "req/s", "change": "+18.2%", "changeType": "up" }
|
|
59
|
+
}
|
|
60
|
+
]
|
|
61
|
+
}
|
|
62
|
+
\`\`\`
|
|
63
|
+
`.trim(),
|
|
64
|
+
}), 'genui.systemPrompt()');
|
|
65
|
+
}
|
|
66
|
+
|
|
31
67
|
// 2. 托管本地 Mermaid 等离线静态 Vendor 资源
|
|
32
68
|
if (ctx.webServer) {
|
|
33
69
|
ctx.effect(() => ctx.webServer.register({
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@civilization/deepseek-genui",
|
|
3
|
-
"version": "1.0.
|
|
4
|
-
"description": "Enterprise-ready GenUI panel bundle for DeepSeek Harness (DSH 0.2.
|
|
3
|
+
"version": "1.0.3",
|
|
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",
|
|
7
7
|
"author": "civilization-os",
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
name: agent-genui
|
|
3
|
-
description:
|
|
4
|
-
whenToUse:
|
|
3
|
+
description: 图表可视化与交互组件引擎。生成基于 agent-genui 协议的高保真、交互式卡片、图表与架构可视化界面组件(GenUI),聊天对话流将自动就地渲染。
|
|
4
|
+
whenToUse: 当需要生成数据大屏、指标看板、趋势图表、流程图、架构拓扑、时序图、生命周期状态机、交互表单、方案对比或需要以可视化界面呈现时使用。
|
|
5
5
|
source: bundled
|
|
6
6
|
---
|
|
7
7
|
|
|
@@ -9,13 +9,13 @@ source: bundled
|
|
|
9
9
|
|
|
10
10
|
`@civilization/deepseek-genui` 为 DeepSeek Harness (DSH) 提供了原生的 Generative UI 运行时与聊天流内就地渲染能力。
|
|
11
11
|
|
|
12
|
-
当你输出被
|
|
12
|
+
当你输出被 ```agent-genui 代码块包裹的标准 JSON DSL 时,DSH 聊天流会自动拦截该代码块并原地渲染为高保真、可交互的活体卡片(支持图表 Tooltip 悬停、React Flow 拓扑拖拽与缩放、表单填写、方案采纳提交等)。
|
|
13
13
|
|
|
14
14
|
---
|
|
15
15
|
|
|
16
16
|
## 📌 输出规范(格式与约束)
|
|
17
17
|
|
|
18
|
-
在回复用户时,请先输出简明扼要的结论或文字说明,然后**直接输出包裹在
|
|
18
|
+
在回复用户时,请先输出简明扼要的结论或文字说明,然后**直接输出包裹在 ```agent-genui 代码块中的完整 JSON 描述**:
|
|
19
19
|
|
|
20
20
|
```agent-genui
|
|
21
21
|
{
|
|
@@ -237,15 +237,17 @@ source: bundled
|
|
|
237
237
|
|
|
238
238
|
---
|
|
239
239
|
|
|
240
|
-
### 9. 开发者 UI:代码 Diff 对比(`type: "diff"`)
|
|
241
|
-
支持 Git
|
|
240
|
+
### 9. 开发者 UI:代码 Diff 对比(`type: "diffViewer"` 或 `type: "diff"`)
|
|
241
|
+
支持 Git 级文件修改对比(绿底增加、红底删除),支持传入 `diffText` 或 `oldCode` + `newCode`:
|
|
242
242
|
```json
|
|
243
243
|
{
|
|
244
244
|
"id": "diff1",
|
|
245
|
-
"type": "
|
|
245
|
+
"type": "diffViewer",
|
|
246
246
|
"props": {
|
|
247
247
|
"title": "配置变更审查 (Diff Viewer)",
|
|
248
248
|
"filename": "application-prod.yml",
|
|
249
|
+
"oldHeader": "原配置 (v1.0)",
|
|
250
|
+
"newHeader": "新配置 (v1.1)",
|
|
249
251
|
"oldCode": "server:\n port: 8080\n timeout: 30s\n max-connections: 1000",
|
|
250
252
|
"newCode": "server:\n port: 8080\n timeout: 60s\n max-connections: 5000\n enable-keepalive: true"
|
|
251
253
|
}
|
|
@@ -307,6 +309,6 @@ source: bundled
|
|
|
307
309
|
|
|
308
310
|
## 💡 最佳实践
|
|
309
311
|
|
|
310
|
-
1. **直接输出代码块**:在回答用户时,不需要让用户去哪里搜索或配置,直接给出
|
|
312
|
+
1. **直接输出代码块**:在回答用户时,不需要让用户去哪里搜索或配置,直接给出 ```agent-genui 代码块即可。DSH 聊天前端已装配自动渲染拦截器,能将此代码块就地变为交互式卡片。
|
|
311
313
|
2. **组合使用**:可以使用 `layout: { "type": "stack", "gap": "md" }` 或 `layout: { "type": "grid", "gap": "md" }` 组合多个不同组件(例如:顶部 1 个 `metric` 指标,中间 1 个 `chart` 图表,底部 1 个 `table` 数据表或 `comparison` 方案对比)。
|
|
312
314
|
3. **保持 JSON 语法严谨**:属性名必须用双引号包裹,字符串内部的引号要转义,避免末尾逗号(trailing comma)。
|