@blueking/chat-x 0.0.25 → 0.0.27
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/dist/ag-ui/types/constants.d.ts +1 -0
- package/dist/ag-ui/types/messages.d.ts +1 -0
- package/dist/common/constants.d.ts +1 -0
- package/dist/components/chat-content/flow-agent-content/flow-agent-content.vue.d.ts +1 -0
- package/dist/components/chat-content/flow-agent-content/flow-agent-node-detail.vue.d.ts +11 -1
- package/dist/components/chat-content/knowledge-rag-content/knowledge-rag-content.vue.d.ts +1 -0
- package/dist/components/chat-content/reference-doc-content/reference-doc-content.vue.d.ts +1 -0
- package/dist/components/execution-summary/execution-summary.vue.d.ts +2 -2
- package/dist/composables/use-custom-tab.d.ts +6 -2
- package/dist/composables/use-message-group.d.ts +72 -3
- package/dist/index.css +1 -1
- package/dist/index.js +1794 -1738
- package/dist/index.js.map +1 -1
- package/dist/lang/lang.d.ts +2 -1
- package/dist/mcp/generated/docs/activity-message.md +2 -0
- package/dist/mcp/generated/docs/chat-container.md +20 -8
- package/dist/mcp/generated/docs/chat-input.md +2 -2
- package/dist/mcp/generated/docs/code-content.md +10 -14
- package/dist/mcp/generated/docs/constants.md +242 -0
- package/dist/mcp/generated/docs/execution-summary.md +4 -4
- package/dist/mcp/generated/docs/markdown-container.md +56 -0
- package/dist/mcp/generated/docs/markdown-latex.md +208 -0
- package/dist/mcp/generated/docs/markdown-mermaid.md +250 -0
- package/dist/mcp/generated/docs/message-container.md +9 -8
- package/dist/mcp/generated/docs/messages.md +475 -0
- package/dist/mcp/generated/docs/theme.md +388 -0
- package/dist/mcp/generated/docs/use-custom-tab.md +2 -1
- package/dist/mcp/generated/docs/use-message-group.md +18 -7
- package/dist/mcp/generated/index.json +1293 -0
- package/dist/types/custom.d.ts +3 -1
- package/package.json +1 -1
|
@@ -0,0 +1,388 @@
|
|
|
1
|
+
<!-- AI SUMMARY -->
|
|
2
|
+
## 快速了解
|
|
3
|
+
|
|
4
|
+
说明通过 SCSS 变量(尺寸、颜色、z-index)与 CSS 类覆盖(chat-input、用户/助手消息、shortcut-btns、ai-markdown-body、tool-btn 等)自定义主题。 含渐变边框 mixin、ai-markdown-fade-in 与弹窗过渡。暗色示例通过根 class 切换。组件随包引入样式,业务侧按需覆写。
|
|
5
|
+
|
|
6
|
+
### 关联组件
|
|
7
|
+
- **chat-container** — 整体布局与侧栏
|
|
8
|
+
- **chat-input** — 输入区与渐变边框
|
|
9
|
+
- **message-container** — 消息区样式上下文
|
|
10
|
+
|
|
11
|
+
---
|
|
12
|
+
<!-- FULL DOC -->
|
|
13
|
+
|
|
14
|
+
# 主题配置
|
|
15
|
+
|
|
16
|
+
> **分类**:theme
|
|
17
|
+
|
|
18
|
+
`@blueking/chat-x` 使用 SCSS 变量和 CSS 类来控制样式,支持通过覆盖变量或样式来自定义主题。
|
|
19
|
+
|
|
20
|
+
## 样式引入
|
|
21
|
+
|
|
22
|
+
组件库的样式会在引入组件时自动加载,无需单独引入:
|
|
23
|
+
|
|
24
|
+
```typescript
|
|
25
|
+
// 引入组件时会自动引入样式
|
|
26
|
+
import { ChatInput, MessageContainer } from '@blueking/chat-x';
|
|
27
|
+
```
|
|
28
|
+
|
|
29
|
+
## SCSS 变量
|
|
30
|
+
|
|
31
|
+
组件库使用以下 SCSS 变量,可以在项目中覆盖:
|
|
32
|
+
|
|
33
|
+
### 尺寸变量
|
|
34
|
+
|
|
35
|
+
```scss
|
|
36
|
+
// 输入框尺寸
|
|
37
|
+
$chat-input-min-width: 350px;
|
|
38
|
+
$chat-input-max-width: 700px;
|
|
39
|
+
```
|
|
40
|
+
|
|
41
|
+
### 颜色变量
|
|
42
|
+
|
|
43
|
+
```scss
|
|
44
|
+
// 主题色
|
|
45
|
+
$primary-color: #3a84ff;
|
|
46
|
+
|
|
47
|
+
// 文字颜色
|
|
48
|
+
$text-color-primary: #313238;
|
|
49
|
+
$text-color-secondary: #4d4f56;
|
|
50
|
+
$text-color-placeholder: #979ba5;
|
|
51
|
+
|
|
52
|
+
// 背景色
|
|
53
|
+
$bg-color-white: #fff;
|
|
54
|
+
$bg-color-light: #f5f7fa;
|
|
55
|
+
$bg-color-hover: #f0f1f5;
|
|
56
|
+
|
|
57
|
+
// 边框色
|
|
58
|
+
$border-color: #dcdee5;
|
|
59
|
+
$border-color-hover: #c4c6cc;
|
|
60
|
+
```
|
|
61
|
+
|
|
62
|
+
### Z-Index 变量
|
|
63
|
+
|
|
64
|
+
组件库使用分层的 z-index 管理:
|
|
65
|
+
|
|
66
|
+
```scss
|
|
67
|
+
// 基础 z-index
|
|
68
|
+
$chat-z-index: 9999;
|
|
69
|
+
|
|
70
|
+
// 编辑器 z-index
|
|
71
|
+
$editor-z-index: $chat-z-index + 1;
|
|
72
|
+
|
|
73
|
+
// 编辑器菜单 z-index
|
|
74
|
+
$editor-menu-z-index: $editor-z-index + 1;
|
|
75
|
+
|
|
76
|
+
// 快捷指令菜单 z-index
|
|
77
|
+
$shortcut-menu-z-index: $editor-menu-z-index + 1;
|
|
78
|
+
|
|
79
|
+
// 划选弹窗 z-index
|
|
80
|
+
$selection-z-index: $shortcut-menu-z-index + 1;
|
|
81
|
+
```
|
|
82
|
+
|
|
83
|
+
## CSS 类覆盖
|
|
84
|
+
|
|
85
|
+
### 输入框样式
|
|
86
|
+
|
|
87
|
+
```scss
|
|
88
|
+
// 覆盖输入框容器样式
|
|
89
|
+
.chat-input-container {
|
|
90
|
+
.chat-input {
|
|
91
|
+
min-height: 120px; // 自定义最小高度
|
|
92
|
+
max-height: 250px; // 自定义最大高度
|
|
93
|
+
background: #fafafa; // 自定义背景色
|
|
94
|
+
|
|
95
|
+
// 覆盖边框渐变
|
|
96
|
+
&::before {
|
|
97
|
+
background: linear-gradient(180deg, #ff6b6b, #ff8e53);
|
|
98
|
+
}
|
|
99
|
+
}
|
|
100
|
+
}
|
|
101
|
+
```
|
|
102
|
+
|
|
103
|
+
### 消息样式
|
|
104
|
+
|
|
105
|
+
```scss
|
|
106
|
+
// 用户消息样式
|
|
107
|
+
.ai-user-message {
|
|
108
|
+
&-content {
|
|
109
|
+
background-color: #d4edda; // 自定义背景色
|
|
110
|
+
border-radius: 8px;
|
|
111
|
+
}
|
|
112
|
+
}
|
|
113
|
+
|
|
114
|
+
// AI 消息样式
|
|
115
|
+
.assistant-message {
|
|
116
|
+
&-content {
|
|
117
|
+
background-color: #f8f9fa;
|
|
118
|
+
border-left: 3px solid #3a84ff;
|
|
119
|
+
padding-left: 12px;
|
|
120
|
+
}
|
|
121
|
+
}
|
|
122
|
+
```
|
|
123
|
+
|
|
124
|
+
### 快捷指令按钮样式
|
|
125
|
+
|
|
126
|
+
```scss
|
|
127
|
+
// 快捷指令按钮
|
|
128
|
+
.shortcut-btns {
|
|
129
|
+
&-item {
|
|
130
|
+
background: linear-gradient(135deg, #667eea, #764ba2);
|
|
131
|
+
color: #fff;
|
|
132
|
+
|
|
133
|
+
&:hover {
|
|
134
|
+
transform: translateY(-2px);
|
|
135
|
+
box-shadow: 0 4px 12px rgba(102, 126, 234, 0.4);
|
|
136
|
+
}
|
|
137
|
+
|
|
138
|
+
// 移除默认渐变边框
|
|
139
|
+
&::before {
|
|
140
|
+
display: none;
|
|
141
|
+
}
|
|
142
|
+
}
|
|
143
|
+
}
|
|
144
|
+
```
|
|
145
|
+
|
|
146
|
+
### 消息工具栏样式
|
|
147
|
+
|
|
148
|
+
```scss
|
|
149
|
+
// 工具按钮
|
|
150
|
+
.tool-btn {
|
|
151
|
+
width: 24px;
|
|
152
|
+
height: 24px;
|
|
153
|
+
font-size: 16px;
|
|
154
|
+
|
|
155
|
+
&:hover {
|
|
156
|
+
background-color: #e1ecff;
|
|
157
|
+
color: #3a84ff;
|
|
158
|
+
}
|
|
159
|
+
}
|
|
160
|
+
```
|
|
161
|
+
|
|
162
|
+
### Markdown 内容样式
|
|
163
|
+
|
|
164
|
+
```scss
|
|
165
|
+
// Markdown 内容
|
|
166
|
+
.ai-markdown-content {
|
|
167
|
+
.ai-markdown-body {
|
|
168
|
+
font-size: 14px;
|
|
169
|
+
line-height: 1.6;
|
|
170
|
+
|
|
171
|
+
// 代码块样式
|
|
172
|
+
pre code.hljs {
|
|
173
|
+
background-color: #1e1e1e;
|
|
174
|
+
border-radius: 8px;
|
|
175
|
+
}
|
|
176
|
+
|
|
177
|
+
// 表格样式
|
|
178
|
+
table {
|
|
179
|
+
border-collapse: collapse;
|
|
180
|
+
|
|
181
|
+
th,
|
|
182
|
+
td {
|
|
183
|
+
border: 1px solid #dcdee5;
|
|
184
|
+
padding: 8px 12px;
|
|
185
|
+
}
|
|
186
|
+
|
|
187
|
+
th {
|
|
188
|
+
background-color: #f5f7fa;
|
|
189
|
+
}
|
|
190
|
+
}
|
|
191
|
+
}
|
|
192
|
+
}
|
|
193
|
+
```
|
|
194
|
+
|
|
195
|
+
## 主题切换示例
|
|
196
|
+
|
|
197
|
+
### 暗色主题
|
|
198
|
+
|
|
199
|
+
```scss
|
|
200
|
+
// 暗色主题变量
|
|
201
|
+
.dark-theme {
|
|
202
|
+
// 输入框
|
|
203
|
+
.chat-input-container .chat-input {
|
|
204
|
+
background: #2d2d2d;
|
|
205
|
+
|
|
206
|
+
&::before {
|
|
207
|
+
background: linear-gradient(180deg, #4a90d9, #357abd);
|
|
208
|
+
}
|
|
209
|
+
}
|
|
210
|
+
|
|
211
|
+
// 用户消息
|
|
212
|
+
.ai-user-message-content {
|
|
213
|
+
background-color: #3d5a80;
|
|
214
|
+
color: #fff;
|
|
215
|
+
}
|
|
216
|
+
|
|
217
|
+
// AI 消息
|
|
218
|
+
.assistant-message {
|
|
219
|
+
color: #e0e0e0;
|
|
220
|
+
}
|
|
221
|
+
|
|
222
|
+
// Markdown 内容
|
|
223
|
+
.ai-markdown-content .ai-markdown-body {
|
|
224
|
+
color: #e0e0e0;
|
|
225
|
+
|
|
226
|
+
h1,
|
|
227
|
+
h2,
|
|
228
|
+
h3,
|
|
229
|
+
h4,
|
|
230
|
+
h5,
|
|
231
|
+
h6 {
|
|
232
|
+
color: #fff;
|
|
233
|
+
}
|
|
234
|
+
|
|
235
|
+
a {
|
|
236
|
+
color: #6cb2eb;
|
|
237
|
+
}
|
|
238
|
+
|
|
239
|
+
code {
|
|
240
|
+
background-color: #3d3d3d;
|
|
241
|
+
color: #e0e0e0;
|
|
242
|
+
}
|
|
243
|
+
}
|
|
244
|
+
|
|
245
|
+
// 快捷指令
|
|
246
|
+
.shortcut-btns-item {
|
|
247
|
+
background: #3d3d3d;
|
|
248
|
+
color: #e0e0e0;
|
|
249
|
+
|
|
250
|
+
&::before {
|
|
251
|
+
background: linear-gradient(105deg, #4a90d940, #9b59b640);
|
|
252
|
+
}
|
|
253
|
+
}
|
|
254
|
+
|
|
255
|
+
// 工具按钮
|
|
256
|
+
.tool-btn {
|
|
257
|
+
color: #9e9e9e;
|
|
258
|
+
|
|
259
|
+
&:hover {
|
|
260
|
+
background-color: #424242;
|
|
261
|
+
color: #fff;
|
|
262
|
+
}
|
|
263
|
+
}
|
|
264
|
+
}
|
|
265
|
+
```
|
|
266
|
+
|
|
267
|
+
### 使用暗色主题
|
|
268
|
+
|
|
269
|
+
```vue
|
|
270
|
+
<template>
|
|
271
|
+
<div :class="{ 'dark-theme': isDark }">
|
|
272
|
+
<ChatInput v-model="input" />
|
|
273
|
+
<MessageContainer :messages="messages" />
|
|
274
|
+
</div>
|
|
275
|
+
</template>
|
|
276
|
+
|
|
277
|
+
<script setup lang="ts">
|
|
278
|
+
import { ref } from 'vue';
|
|
279
|
+
import { ChatInput, MessageContainer } from '@blueking/chat-x';
|
|
280
|
+
|
|
281
|
+
const isDark = ref(false);
|
|
282
|
+
const input = ref('');
|
|
283
|
+
const messages = ref([]);
|
|
284
|
+
</script>
|
|
285
|
+
```
|
|
286
|
+
|
|
287
|
+
## 渐变边框
|
|
288
|
+
|
|
289
|
+
组件库使用 CSS mask 实现渐变边框效果:
|
|
290
|
+
|
|
291
|
+
```scss
|
|
292
|
+
// 渐变边框 mixin
|
|
293
|
+
@mixin linear-gradient-border($angle: 105deg, $start-color: #235dfa40, $end-color: #bc81ef40) {
|
|
294
|
+
content: '';
|
|
295
|
+
position: absolute;
|
|
296
|
+
inset: 0;
|
|
297
|
+
padding: 1px;
|
|
298
|
+
background: linear-gradient($angle, $start-color, $end-color);
|
|
299
|
+
mask:
|
|
300
|
+
linear-gradient(#fff 0 0) content-box,
|
|
301
|
+
linear-gradient(#fff 0 0);
|
|
302
|
+
mask-composite: xor;
|
|
303
|
+
mask-composite: exclude;
|
|
304
|
+
border-radius: inherit;
|
|
305
|
+
pointer-events: none;
|
|
306
|
+
}
|
|
307
|
+
```
|
|
308
|
+
|
|
309
|
+
使用示例:
|
|
310
|
+
|
|
311
|
+
```scss
|
|
312
|
+
.custom-card {
|
|
313
|
+
position: relative;
|
|
314
|
+
border-radius: 8px;
|
|
315
|
+
|
|
316
|
+
&::before {
|
|
317
|
+
@include linear-gradient-border(180deg, #6cbaff, #3a84ff);
|
|
318
|
+
}
|
|
319
|
+
}
|
|
320
|
+
```
|
|
321
|
+
|
|
322
|
+
## 动画效果
|
|
323
|
+
|
|
324
|
+
### 淡入动画
|
|
325
|
+
|
|
326
|
+
```scss
|
|
327
|
+
// 全局淡入动画
|
|
328
|
+
@keyframes ai-markdown-fade-in {
|
|
329
|
+
from {
|
|
330
|
+
opacity: 0;
|
|
331
|
+
}
|
|
332
|
+
to {
|
|
333
|
+
opacity: 1;
|
|
334
|
+
}
|
|
335
|
+
}
|
|
336
|
+
|
|
337
|
+
.ai-blueking-markdown-fade-in {
|
|
338
|
+
animation: ai-markdown-fade-in 0.2s ease-out forwards;
|
|
339
|
+
}
|
|
340
|
+
```
|
|
341
|
+
|
|
342
|
+
### 弹窗过渡
|
|
343
|
+
|
|
344
|
+
```scss
|
|
345
|
+
// 选择弹窗过渡
|
|
346
|
+
.ai-fade-enter-active,
|
|
347
|
+
.ai-fade-leave-active {
|
|
348
|
+
transition:
|
|
349
|
+
opacity 0.2s ease,
|
|
350
|
+
transform 0.2s ease;
|
|
351
|
+
}
|
|
352
|
+
|
|
353
|
+
.ai-fade-enter-from,
|
|
354
|
+
.ai-fade-leave-to {
|
|
355
|
+
opacity: 0;
|
|
356
|
+
transform: translateY(4px);
|
|
357
|
+
}
|
|
358
|
+
```
|
|
359
|
+
|
|
360
|
+
## 响应式设计
|
|
361
|
+
|
|
362
|
+
```scss
|
|
363
|
+
// 移动端适配
|
|
364
|
+
@media (max-width: 768px) {
|
|
365
|
+
.chat-input-container .chat-input {
|
|
366
|
+
min-width: 100%;
|
|
367
|
+
max-width: 100%;
|
|
368
|
+
}
|
|
369
|
+
|
|
370
|
+
.shortcut-btns {
|
|
371
|
+
min-width: 100%;
|
|
372
|
+
max-width: 100%;
|
|
373
|
+
}
|
|
374
|
+
}
|
|
375
|
+
```
|
|
376
|
+
|
|
377
|
+
## 注意事项
|
|
378
|
+
|
|
379
|
+
1. **样式优先级**:覆盖样式时可能需要使用更高优先级的选择器
|
|
380
|
+
2. **变量位置**:SCSS 变量需要在组件样式之前定义
|
|
381
|
+
3. **构建配置**:确保项目配置支持 SCSS 处理
|
|
382
|
+
4. **组件隔离**:使用 scoped 样式时,深度选择器 `::v-deep` 或 `:deep()` 可能需要
|
|
383
|
+
|
|
384
|
+
## 关联组件
|
|
385
|
+
|
|
386
|
+
- [ChatContainer](../components/molecular/chat-container.md) — 布局与主题根节点
|
|
387
|
+
- [ChatInput](../components/molecular/chat-input.md) — 输入区变量与类名
|
|
388
|
+
- [MessageContainer](../components/molecular/message-container.md) — 消息列表区域
|
|
@@ -111,7 +111,8 @@ tabManager?.removeCustomTab('node-detail-123');
|
|
|
111
111
|
interface CustomTab<T = Record<string, unknown>> {
|
|
112
112
|
label: string;
|
|
113
113
|
name: string;
|
|
114
|
-
|
|
114
|
+
/** 可与 `component` / `props` 并列;用于侧栏「在对话中定位」与主消息 `message.uid` 对齐 */
|
|
115
|
+
data?: T & { messageUid?: string };
|
|
115
116
|
}
|
|
116
117
|
```
|
|
117
118
|
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
<!-- AI SUMMARY -->
|
|
2
2
|
## 快速了解
|
|
3
3
|
|
|
4
|
-
useMessageGroup 接收 keyword、messages、selectedUserMessages,通过 watchEffect 产出 messageGroups(User/Assistant/Tool 合并、末尾 Loading
|
|
4
|
+
useMessageGroup 接收 keyword、messages、selectedUserMessages,通过 watchEffect 产出 messageGroups(User/Assistant/Tool 合并、末尾 Loading 注入且占位 id 为 LOADING_MESSAGE_ID、pause 与分享勾选等)。 executionGroups 供侧边执行摘要过滤,并暴露 isShareMode、全选与 onConfirmShare。 ChatContainer 组装后传给 MessageContainer;ExecutionSummary 消费 executionGroups。
|
|
5
5
|
|
|
6
6
|
### 关联组件
|
|
7
7
|
- **chat-container** — 调用并传入 MessageContainer
|
|
@@ -39,6 +39,8 @@ function useMessageGroup(options: {
|
|
|
39
39
|
|
|
40
40
|
`watchEffect` 遍历 `messages` 数组,按以下规则分组:
|
|
41
41
|
|
|
42
|
+
**消息 `uid`:** 若某条消息缺少 `uid`,分组前会自动为其生成并写入 `uid`(与 `MessageGroup.uid` 及 DOM 定位约定配合)。
|
|
43
|
+
|
|
42
44
|
```
|
|
43
45
|
messages 原始数组(按顺序处理)
|
|
44
46
|
│
|
|
@@ -58,18 +60,27 @@ role=user role=tool 其他 role
|
|
|
58
60
|
⑤ 末尾为 user 消息 → 追加 Loading 消息组
|
|
59
61
|
```
|
|
60
62
|
|
|
63
|
+
注入的占位 Loading 消息使用固定 id:`LOADING_MESSAGE_ID`(`'__loading__'`,定义于 `common/constants`)。`ChatContainer` 据此判断是否在「请求中」阶段,并向 `ChatInput` / `MessageContainer` 下传 `MessageStatus.Fetching`,与流式中的停止、防重复发送行为对齐。
|
|
64
|
+
|
|
61
65
|
### Tool 消息处理
|
|
62
66
|
|
|
63
67
|
`role: 'tool'` 消息不会独立渲染,而是通过 `toolCallId` 注入到对应 AssistantMessage 的 `toolCall.toolMessage` 字段:
|
|
64
68
|
|
|
65
69
|
```typescript
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
toolCall
|
|
70
|
+
const toolMessage = messages.find(
|
|
71
|
+
m => m.role === 'assistant' && m.toolCalls?.some(t => t.id === message.toolCallId),
|
|
72
|
+
);
|
|
73
|
+
if (toolMessage) {
|
|
74
|
+
const toolCall = toolMessage.toolCalls?.find(t => t.id === message.toolCallId);
|
|
75
|
+
if (toolCall) {
|
|
76
|
+
toolCall.toolMessage = message;
|
|
77
|
+
}
|
|
78
|
+
// 同步 assistant 状态(错误等)
|
|
79
|
+
}
|
|
71
80
|
```
|
|
72
81
|
|
|
82
|
+
若找不到对应 `toolCall`(例如数据不一致),**跳过注入**,避免非空断言导致的运行时异常。
|
|
83
|
+
|
|
73
84
|
### pause 字段
|
|
74
85
|
|
|
75
86
|
每个 Assistant 消息组计算 `pause` 属性:
|
|
@@ -157,7 +168,7 @@ const { messageGroups, executionGroups, isShareMode, isAllSelected, onToggleShar
|
|
|
157
168
|
import { type MessageGroup } from '@blueking/chat-x';
|
|
158
169
|
|
|
159
170
|
interface MessageGroup {
|
|
160
|
-
|
|
171
|
+
uid: string;
|
|
161
172
|
type: MessageRole;
|
|
162
173
|
messages: Message[];
|
|
163
174
|
checked: boolean;
|