@blueking/chat-x 0.0.51-beta.5 → 0.0.52-dev.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +15 -8
- package/dist/ag-ui/types/contents.d.ts +2 -0
- package/dist/ag-ui/types/messages.d.ts +6 -1
- package/dist/common/constants.d.ts +2 -0
- package/dist/components/ai-buttons/add-menu-btn/add-menu-btn.vue.d.ts +24 -0
- package/dist/components/chat-content/collapsible-content/collapsible-content.vue.d.ts +28 -0
- package/dist/components/chat-content/file-content/upload-file-item.vue.d.ts +5 -2
- package/dist/components/chat-content/file-content/upload-image-item.vue.d.ts +1 -0
- package/dist/components/chat-content/flow-agent-content/use-flow-node-actions.d.ts +1 -1
- package/dist/components/chat-input/ai-slash-input/ai-slash-input.vue.d.ts +21 -10
- package/dist/components/chat-input/ai-slash-input/command.d.ts +6 -3
- package/dist/components/chat-input/ai-slash-input/constants.d.ts +2 -0
- package/dist/components/chat-input/ai-slash-input/use-menu-trigger.d.ts +17 -0
- package/dist/components/chat-input/build-default-placeholder.d.ts +9 -3
- package/dist/components/chat-input/chat-input.vue.d.ts +30 -18
- package/dist/components/chat-input/input-menu/constants.d.ts +60 -0
- package/dist/components/chat-input/input-menu/index.d.ts +4 -0
- package/dist/components/chat-input/input-menu/input-menu-option.vue.d.ts +14 -0
- package/dist/components/chat-input/input-menu/input-menu-panel.vue.d.ts +17 -0
- package/dist/components/chat-input/input-menu/use-input-menu.d.ts +22 -0
- package/dist/components/chat-input/model-selector/types.d.ts +3 -2
- package/dist/components/chat-message/message-container/message-container.vue.d.ts +1 -1
- package/dist/components/chat-message/user-message/user-message.vue.d.ts +1 -1
- package/dist/components/mention/create-mention-tippy.d.ts +27 -0
- package/dist/components/mention/index.d.ts +4 -0
- package/dist/components/{chat-input/ai-slash-input/ai-prompt-list/ai-prompt-list.vue.d.ts → mention/mention-popover.vue.d.ts} +3 -2
- package/dist/components/{chat-input/ai-slash-input/ai-skill-list/ai-skill-list.vue.d.ts → mention/mention-tag.vue.d.ts} +7 -3
- package/dist/components/{chat-input/ai-slash-input/ai-slash-menu/ai-slash-menu.vue.d.ts → mention/mention-text.vue.d.ts} +3 -3
- package/dist/components/resource-icon/index.d.ts +1 -0
- package/dist/components/resource-icon/resource-icon.vue.d.ts +11 -0
- package/dist/composables/index.d.ts +1 -0
- package/dist/composables/use-artifact-preview.d.ts +5 -2
- package/dist/composables/use-common.d.ts +0 -9
- package/dist/composables/use-global-config.d.ts +4 -0
- package/dist/composables/use-input-mention.d.ts +13 -0
- package/dist/composables/use-message-group.d.ts +1011 -72
- package/dist/icons/index.d.ts +1 -0
- package/dist/icons/input.d.ts +21 -0
- package/dist/icons/menu-item.d.ts +22 -0
- package/dist/index.css +1 -1
- package/dist/index.js +4953 -4429
- package/dist/index.js.map +1 -1
- package/dist/lang/lang.d.ts +13 -3
- package/dist/mcp/generated/docs/activity-message.md +3 -3
- package/dist/mcp/generated/docs/add-menu-btn.md +91 -0
- package/dist/mcp/generated/docs/ai-slash-input.md +72 -26
- package/dist/mcp/generated/docs/assistant-message.md +7 -1
- package/dist/mcp/generated/docs/chat-container.md +45 -6
- package/dist/mcp/generated/docs/chat-input.md +327 -483
- package/dist/mcp/generated/docs/collapsible-content.md +78 -0
- package/dist/mcp/generated/docs/constants.md +36 -3
- package/dist/mcp/generated/docs/execution-summary.md +1 -23
- package/dist/mcp/generated/docs/file-artifact-panel.md +24 -5
- package/dist/mcp/generated/docs/file-content.md +4 -0
- package/dist/mcp/generated/docs/file-upload-btn.md +15 -12
- package/dist/mcp/generated/docs/flow-agent-content.md +10 -12
- package/dist/mcp/generated/docs/input-menu-panel.md +166 -0
- package/dist/mcp/generated/docs/mention-tag.md +83 -0
- package/dist/mcp/generated/docs/mention-text.md +86 -0
- package/dist/mcp/generated/docs/message-container.md +1 -1
- package/dist/mcp/generated/docs/message-render.md +1 -1
- package/dist/mcp/generated/docs/message-tools.md +15 -4
- package/dist/mcp/generated/docs/messages.md +3 -0
- package/dist/mcp/generated/docs/model-selector.md +4 -2
- package/dist/mcp/generated/docs/overflow-tips.md +3 -3
- package/dist/mcp/generated/docs/resource-icon.md +102 -0
- package/dist/mcp/generated/docs/text-content.md +7 -3
- package/dist/mcp/generated/docs/theme.md +27 -35
- package/dist/mcp/generated/docs/use-artifact-preview.md +7 -3
- package/dist/mcp/generated/docs/use-command-selection.md +1 -1
- package/dist/mcp/generated/docs/use-container-scroll.md +2 -1
- package/dist/mcp/generated/docs/use-flow-node-actions.md +8 -15
- package/dist/mcp/generated/docs/use-global-config.md +11 -4
- package/dist/mcp/generated/docs/use-input-mention.md +119 -0
- package/dist/mcp/generated/docs/use-menu-keydown.md +15 -16
- package/dist/mcp/generated/docs/use-message-group.md +3 -6
- package/dist/mcp/generated/docs/user-message.md +39 -17
- package/dist/mcp/generated/index.json +233 -81
- package/dist/types/editor.d.ts +0 -29
- package/dist/types/index.d.ts +1 -0
- package/dist/types/input-menu.d.ts +46 -0
- package/dist/utils/artifact-tags.d.ts +36 -0
- package/dist/utils/collect-message-artifacts.d.ts +14 -0
- package/dist/utils/file.d.ts +3 -3
- package/dist/utils/index.d.ts +2 -1
- package/dist/utils/upload-file.d.ts +6 -1
- package/package.json +3 -2
- package/skills/blueking-chat-x/SKILL.md +143 -0
- package/skills/blueking-chat-x/references/_index.md +153 -0
- package/skills/blueking-chat-x/references/components/activity-layout.md +134 -0
- package/skills/blueking-chat-x/references/components/activity-message.md +486 -0
- package/skills/blueking-chat-x/references/components/add-menu-btn.md +88 -0
- package/skills/blueking-chat-x/references/components/ai-image.md +230 -0
- package/skills/blueking-chat-x/references/components/ai-loading.md +131 -0
- package/skills/blueking-chat-x/references/components/ai-selection.md +439 -0
- package/skills/blueking-chat-x/references/components/ai-slash-input.md +102 -0
- package/skills/blueking-chat-x/references/components/animation-text.md +202 -0
- package/skills/blueking-chat-x/references/components/assistant-message.md +504 -0
- package/skills/blueking-chat-x/references/components/chat-container.md +912 -0
- package/skills/blueking-chat-x/references/components/chat-input.md +614 -0
- package/skills/blueking-chat-x/references/components/cite-content.md +142 -0
- package/skills/blueking-chat-x/references/components/code-content.md +211 -0
- package/skills/blueking-chat-x/references/components/collapsible-content.md +76 -0
- package/skills/blueking-chat-x/references/components/common-error-content.md +73 -0
- package/skills/blueking-chat-x/references/components/content-render.md +233 -0
- package/skills/blueking-chat-x/references/components/delete-tool.md +191 -0
- package/skills/blueking-chat-x/references/components/desc-panel.md +162 -0
- package/skills/blueking-chat-x/references/components/detail-section.md +91 -0
- package/skills/blueking-chat-x/references/components/execution-summary.md +150 -0
- package/skills/blueking-chat-x/references/components/file-artifact-panel.md +307 -0
- package/skills/blueking-chat-x/references/components/file-content.md +340 -0
- package/skills/blueking-chat-x/references/components/file-icon.md +109 -0
- package/skills/blueking-chat-x/references/components/file-upload-btn.md +162 -0
- package/skills/blueking-chat-x/references/components/flow-agent-content.md +266 -0
- package/skills/blueking-chat-x/references/components/flow-agent-node-detail.md +236 -0
- package/skills/blueking-chat-x/references/components/highlight-keyword.md +146 -0
- package/skills/blueking-chat-x/references/components/image-content.md +182 -0
- package/skills/blueking-chat-x/references/components/image-preview-group.md +184 -0
- package/skills/blueking-chat-x/references/components/image-preview.md +226 -0
- package/skills/blueking-chat-x/references/components/info-message.md +144 -0
- package/skills/blueking-chat-x/references/components/input-attachment.md +49 -0
- package/skills/blueking-chat-x/references/components/input-info-alert.md +42 -0
- package/skills/blueking-chat-x/references/components/input-menu-panel.md +162 -0
- package/skills/blueking-chat-x/references/components/interrupt-message.md +212 -0
- package/skills/blueking-chat-x/references/components/key-value-content.md +128 -0
- package/skills/blueking-chat-x/references/components/knowledge-rag-content.md +122 -0
- package/skills/blueking-chat-x/references/components/latex-content.md +200 -0
- package/skills/blueking-chat-x/references/components/loading-message.md +192 -0
- package/skills/blueking-chat-x/references/components/markdown-content.md +232 -0
- package/skills/blueking-chat-x/references/components/mention-tag.md +79 -0
- package/skills/blueking-chat-x/references/components/mention-text.md +83 -0
- package/skills/blueking-chat-x/references/components/mermaid-content.md +189 -0
- package/skills/blueking-chat-x/references/components/message-container.md +645 -0
- package/skills/blueking-chat-x/references/components/message-loading.md +118 -0
- package/skills/blueking-chat-x/references/components/message-render.md +327 -0
- package/skills/blueking-chat-x/references/components/message-time.md +177 -0
- package/skills/blueking-chat-x/references/components/message-tools.md +427 -0
- package/skills/blueking-chat-x/references/components/model-selector.md +157 -0
- package/skills/blueking-chat-x/references/components/preview-toolbar.md +42 -0
- package/skills/blueking-chat-x/references/components/questions-container.md +85 -0
- package/skills/blueking-chat-x/references/components/reasoning-message.md +232 -0
- package/skills/blueking-chat-x/references/components/reference-content.md +135 -0
- package/skills/blueking-chat-x/references/components/reference-doc-content.md +109 -0
- package/skills/blueking-chat-x/references/components/resource-icon.md +98 -0
- package/skills/blueking-chat-x/references/components/scroll-btn.md +159 -0
- package/skills/blueking-chat-x/references/components/selection-footer.md +78 -0
- package/skills/blueking-chat-x/references/components/selection-question.md +88 -0
- package/skills/blueking-chat-x/references/components/shortcut-btn.md +204 -0
- package/skills/blueking-chat-x/references/components/shortcut-btns.md +266 -0
- package/skills/blueking-chat-x/references/components/shortcut-render.md +424 -0
- package/skills/blueking-chat-x/references/components/simple-table.md +101 -0
- package/skills/blueking-chat-x/references/components/text-content.md +80 -0
- package/skills/blueking-chat-x/references/components/tool-approval-card.md +183 -0
- package/skills/blueking-chat-x/references/components/tool-btn.md +317 -0
- package/skills/blueking-chat-x/references/components/tool-message.md +235 -0
- package/skills/blueking-chat-x/references/components/toolcall-render.md +348 -0
- package/skills/blueking-chat-x/references/components/user-feedback.md +233 -0
- package/skills/blueking-chat-x/references/components/user-message.md +444 -0
- package/skills/blueking-chat-x/references/components/user-question-answered-card.md +104 -0
- package/skills/blueking-chat-x/references/components/user-question-card.md +231 -0
- package/skills/blueking-chat-x/references/components/user-question-choice.md +105 -0
- package/skills/blueking-chat-x/references/components/user-question-option.md +42 -0
- package/skills/blueking-chat-x/references/components/vnode-renderer.md +122 -0
- package/skills/blueking-chat-x/references/composables/use-animation-text.md +196 -0
- package/skills/blueking-chat-x/references/composables/use-artifact-preview.md +235 -0
- package/skills/blueking-chat-x/references/composables/use-clipboard.md +203 -0
- package/skills/blueking-chat-x/references/composables/use-command-selection.md +150 -0
- package/skills/blueking-chat-x/references/composables/use-container-scroll.md +57 -0
- package/skills/blueking-chat-x/references/composables/use-custom-tab.md +158 -0
- package/skills/blueking-chat-x/references/composables/use-flow-node-actions.md +164 -0
- package/skills/blueking-chat-x/references/composables/use-full-screen.md +112 -0
- package/skills/blueking-chat-x/references/composables/use-global-config.md +155 -0
- package/skills/blueking-chat-x/references/composables/use-input-mention.md +115 -0
- package/skills/blueking-chat-x/references/composables/use-menu-keydown.md +161 -0
- package/skills/blueking-chat-x/references/composables/use-message-group.md +244 -0
- package/skills/blueking-chat-x/references/composables/use-observer-visible-list.md +188 -0
- package/skills/blueking-chat-x/references/composables/use-parent-scrolling.md +46 -0
- package/skills/blueking-chat-x/references/directives/index.md +61 -0
- package/skills/blueking-chat-x/references/directives/overflow-tips.md +205 -0
- package/skills/blueking-chat-x/references/icons/index.md +185 -0
- package/skills/blueking-chat-x/references/plugins/index.md +56 -0
- package/skills/blueking-chat-x/references/plugins/markdown-container.md +55 -0
- package/skills/blueking-chat-x/references/plugins/markdown-latex.md +205 -0
- package/skills/blueking-chat-x/references/plugins/markdown-mermaid.md +247 -0
- package/skills/blueking-chat-x/references/theme/theme.md +423 -0
- package/skills/blueking-chat-x/references/types/constants.md +340 -0
- package/skills/blueking-chat-x/references/types/index.md +120 -0
- package/skills/blueking-chat-x/references/types/interrupt.md +379 -0
- package/skills/blueking-chat-x/references/types/messages.md +556 -0
- package/skills/blueking-chat-x/references/types/schema.md +91 -0
- package/skills/blueking-chat-x/references/utils/index.md +196 -0
- package/skills/blueking-chat-x/scripts/generate-references.mjs +536 -0
- package/dist/components/chat-input/ai-slash-editor/ai-slash-editor.vue.d.ts +0 -28
- package/dist/components/chat-input/ai-slash-editor/theme.d.ts +0 -24
- package/dist/mcp/generated/docs/ai-prompt-list.md +0 -45
- package/dist/mcp/generated/docs/ai-skill-list.md +0 -75
- package/dist/mcp/generated/docs/ai-slash-editor.md +0 -43
- package/dist/mcp/generated/docs/ai-slash-menu.md +0 -42
|
@@ -0,0 +1,101 @@
|
|
|
1
|
+
# SimpleTable 简易表格
|
|
2
|
+
|
|
3
|
+
> 能力域:Agent 能力 | 未从包入口导出:内部组件,请通过上层组件使用 | since 1.0.0
|
|
4
|
+
|
|
5
|
+
FlowAgent 节点详情中的轻量表格展示组件。 源码位置:src/components/chat-content/flow-agent-content/simple-table.vue。
|
|
6
|
+
|
|
7
|
+
**关联**:flow-agent-node-detail(节点详情中用于展示输入参数、插件输出定义和结构化输出)、detail-section(通常放在详情分段容器内使用)
|
|
8
|
+
|
|
9
|
+
---
|
|
10
|
+
|
|
11
|
+
# SimpleTable 简易表格
|
|
12
|
+
|
|
13
|
+
> **能力域**:Agent 能力
|
|
14
|
+
|
|
15
|
+
`SimpleTable` 是 FlowAgent 节点详情中的轻量只读表格,用于展示参数名、参数值、插件输出定义等结构化信息。组件只根据 `columns` 和 `data` 渲染表格,不提供排序、筛选、分页或编辑能力。
|
|
16
|
+
|
|
17
|
+
通常不需要单独使用,主要由 `FlowAgentNodeDetail` 内部组合。
|
|
18
|
+
|
|
19
|
+
## 源码事实
|
|
20
|
+
|
|
21
|
+
- **源码位置**:`src/components/chat-content/flow-agent-content/simple-table.vue`
|
|
22
|
+
- **能力说明**:FlowAgent 节点详情中的轻量表格展示组件。
|
|
23
|
+
|
|
24
|
+
## 核心能力
|
|
25
|
+
|
|
26
|
+
- **列驱动渲染**:通过 `columns` 决定表头、字段读取 key 和单元格换行策略
|
|
27
|
+
- **空值兜底**:单元格值为 `null` 或 `undefined` 时显示 `--`,`0` 会正常显示为 `0`
|
|
28
|
+
- **空数据占位**:`data` 为空数组时渲染一行 `--`,`colspan` 等于列数
|
|
29
|
+
- **长文本换行**:列配置 `breakAll: true` 后,该列单元格添加 `is-break-all` 样式,适合展示 JSON 或长字符串
|
|
30
|
+
|
|
31
|
+
## 基础用法
|
|
32
|
+
|
|
33
|
+
```vue
|
|
34
|
+
<template>
|
|
35
|
+
<SimpleTable
|
|
36
|
+
:columns="columns"
|
|
37
|
+
:data="data"
|
|
38
|
+
/>
|
|
39
|
+
</template>
|
|
40
|
+
|
|
41
|
+
<script setup lang="ts">
|
|
42
|
+
import SimpleTable from '@blueking/chat-x/src/components/chat-content/flow-agent-content/simple-table.vue';
|
|
43
|
+
|
|
44
|
+
const columns = [
|
|
45
|
+
{ key: 'key', label: '参数名' },
|
|
46
|
+
{ breakAll: true, key: 'value', label: '参数值' },
|
|
47
|
+
];
|
|
48
|
+
|
|
49
|
+
const data = [
|
|
50
|
+
{ key: 'bk_host_id', value: '10001' },
|
|
51
|
+
{ key: 'metadata', value: '{"source":"cmdb","scope":"production"}' },
|
|
52
|
+
];
|
|
53
|
+
</script>
|
|
54
|
+
```
|
|
55
|
+
|
|
56
|
+
**渲染效果**
|
|
57
|
+
|
|
58
|
+
## 空数据
|
|
59
|
+
|
|
60
|
+
当 `data.length === 0` 时,组件渲染一行居中的 `--`,用于表示当前分段没有可展示数据。
|
|
61
|
+
|
|
62
|
+
## API
|
|
63
|
+
|
|
64
|
+
### Props
|
|
65
|
+
|
|
66
|
+
| 属性名 | 类型 | 必填 | 默认值 | 说明 |
|
|
67
|
+
| ------- | ------------------------ | ---- | ------ | ---------------------------- |
|
|
68
|
+
| columns | `SimpleTableColumn[]` | 是 | — | 表格列配置 |
|
|
69
|
+
| data | `Record<string, unknown>[]` | 是 | — | 表格行数据,按列 `key` 取值 |
|
|
70
|
+
|
|
71
|
+
### Emits
|
|
72
|
+
|
|
73
|
+
- 无。
|
|
74
|
+
|
|
75
|
+
### Slots
|
|
76
|
+
|
|
77
|
+
- 无。
|
|
78
|
+
|
|
79
|
+
### Expose
|
|
80
|
+
|
|
81
|
+
- 无。
|
|
82
|
+
|
|
83
|
+
## 类型定义
|
|
84
|
+
|
|
85
|
+
```typescript
|
|
86
|
+
export interface SimpleTableColumn {
|
|
87
|
+
breakAll?: boolean; // 是否对该列单元格启用 word-break: break-all
|
|
88
|
+
key: string; // 从 data 行对象中读取的字段名
|
|
89
|
+
label: string; // 表头文案
|
|
90
|
+
}
|
|
91
|
+
```
|
|
92
|
+
|
|
93
|
+
## 使用建议
|
|
94
|
+
|
|
95
|
+
- 适合详情面板中的短表格,不适合承载复杂数据表能力。
|
|
96
|
+
- 需要展示对象值时,建议在传入前先序列化为字符串;`FlowAgentNodeDetail` 内部会对对象值执行 `JSON.stringify`。
|
|
97
|
+
|
|
98
|
+
## 关联组件
|
|
99
|
+
|
|
100
|
+
- [FlowAgentNodeDetail](./flow-agent-node-detail.md) — 节点详情主体。
|
|
101
|
+
- [DetailSection](./detail-section.md) — 表格常放置在详情分段内。
|
|
@@ -0,0 +1,80 @@
|
|
|
1
|
+
# TextContent 文本内容
|
|
2
|
+
|
|
3
|
+
> 能力域:内容渲染 | 未从包入口导出:内部组件,请通过上层组件使用 | since 1.0.0
|
|
4
|
+
|
|
5
|
+
渲染纯文本内容。 源码位置:src/components/chat-content/text-content/text-content.vue。
|
|
6
|
+
|
|
7
|
+
**关联**:markdown-content(需要富文本时的替代方案)、user-message(用户消息中纯文本内容展示)、mention-text(文档含资源标签时的替代渲染)
|
|
8
|
+
|
|
9
|
+
---
|
|
10
|
+
|
|
11
|
+
# TextContent 文本内容
|
|
12
|
+
## 源码事实
|
|
13
|
+
|
|
14
|
+
- **源码位置**:`src/components/chat-content/text-content/text-content.vue`
|
|
15
|
+
- **能力域**:内容渲染
|
|
16
|
+
- **能力说明**:渲染纯文本内容。
|
|
17
|
+
|
|
18
|
+
> **能力域**:内容渲染
|
|
19
|
+
|
|
20
|
+
纯文本气泡组件,使用 Vue 文本插值渲染 `content`,天然防 XSS。
|
|
21
|
+
|
|
22
|
+
## 组件结构
|
|
23
|
+
|
|
24
|
+
```
|
|
25
|
+
div.ai-text-content
|
|
26
|
+
display: flex; width: fit-content
|
|
27
|
+
padding: 8px 12px; border-radius: 4px
|
|
28
|
+
background-color: #e1ecff(浅蓝色气泡)
|
|
29
|
+
word-break: break-all(无空格长文本按字符换行)
|
|
30
|
+
white-space: pre-wrap(保留 \n 换行与连续空格)
|
|
31
|
+
│
|
|
32
|
+
└── {{ content }}(文本插值,HTML 标签不被解析)
|
|
33
|
+
```
|
|
34
|
+
|
|
35
|
+
> **换行说明**:内容来自输入框,多行文本以 `\n` 承载,因此组件带 `white-space: pre-wrap`——`\n` 会渲染为视觉换行,连续空格与空行也会保留,无需在外层额外加样式。
|
|
36
|
+
|
|
37
|
+
## 基础用法
|
|
38
|
+
|
|
39
|
+
```vue
|
|
40
|
+
<template>
|
|
41
|
+
<TextContent content="这是一条纯文本消息" />
|
|
42
|
+
</template>
|
|
43
|
+
|
|
44
|
+
<script setup lang="ts">
|
|
45
|
+
import { TextContent } from '@blueking/chat-x';
|
|
46
|
+
</script>
|
|
47
|
+
```
|
|
48
|
+
|
|
49
|
+
## 长文本与多行
|
|
50
|
+
|
|
51
|
+
`word-break: break-all` 确保无空格的长字符串(如 URL、哈希值)也能在容器内正常换行;`white-space: pre-wrap` 让 `\n` 直接生效:
|
|
52
|
+
|
|
53
|
+
## XSS 安全
|
|
54
|
+
|
|
55
|
+
`content` 使用 `{{ }}` 文本插值渲染,HTML 标签会被转义,不会执行脚本:
|
|
56
|
+
|
|
57
|
+
## API
|
|
58
|
+
|
|
59
|
+
### Props
|
|
60
|
+
|
|
61
|
+
| 属性名 | 类型 | 必填 | 说明 |
|
|
62
|
+
| ------- | -------- | ---- | ---------------------------------------------- |
|
|
63
|
+
| content | `string` | 是 | 要显示的文本内容;空字符串时气泡仍渲染,无内容 |
|
|
64
|
+
|
|
65
|
+
## 使用场景
|
|
66
|
+
|
|
67
|
+
`TextContent` 为极简的文本气泡,适用于**不需要 Markdown 渲染**的纯文本展示场景。如需富文本,使用 `MarkdownContent` 组件。
|
|
68
|
+
|
|
69
|
+
| 场景 | 推荐组件 |
|
|
70
|
+
| --------------------------------- | ----------------- |
|
|
71
|
+
| 纯文本气泡(用户消息、简单提示) | `TextContent` |
|
|
72
|
+
| 含 `@` 资源标签的用户消息 | `MentionText` |
|
|
73
|
+
| 含 Markdown / 代码块 / 公式的内容 | `MarkdownContent` |
|
|
74
|
+
| 工具调用结果描述 | `DescPanel` |
|
|
75
|
+
|
|
76
|
+
## 关联组件
|
|
77
|
+
|
|
78
|
+
- [MarkdownContent](/components/rendering/markdown-content) — 富文本替代
|
|
79
|
+
- [MentionText](/components/rendering/mention-text) — 含资源标签文档的渲染
|
|
80
|
+
- [UserMessage](/components/message/user-message) — 用户消息气泡
|
|
@@ -0,0 +1,183 @@
|
|
|
1
|
+
# ToolApprovalCard 工具审批卡片
|
|
2
|
+
|
|
3
|
+
> 能力域:Agent 能力 | 未从包入口导出:内部组件,请通过上层组件使用 | since 1.0.0
|
|
4
|
+
|
|
5
|
+
渲染 AIDevToolApproval 中断的审批信息与取消/刷新操作;readonly prop 可用于纯只读展示(outcome.success 回显已改为可交互,不再使用 readonly)。 源码位置:src/components/chat-message/interrupt-message/tool-approval-card.vue。
|
|
6
|
+
|
|
7
|
+
**关联**:interrupt-message(InterruptMessageRender 按 reason 派发渲染)
|
|
8
|
+
|
|
9
|
+
---
|
|
10
|
+
|
|
11
|
+
# ToolApprovalCard 审批卡片
|
|
12
|
+
## 源码事实
|
|
13
|
+
|
|
14
|
+
- **源码位置**:`src/components/chat-message/interrupt-message/tool-approval-card.vue`
|
|
15
|
+
- **能力域**:Agent 能力
|
|
16
|
+
- **能力说明**:渲染 AIDevToolApproval 中断的审批信息与取消操作;`readonly` prop 用于纯只读展示(outcome.success 回显已改为可交互,不再传入 `readonly`)。
|
|
17
|
+
|
|
18
|
+
> **能力域**:Agent 能力
|
|
19
|
+
|
|
20
|
+
AI Dev 第三方工具审批(`InterruptReason.AIDevToolApproval`)专用卡片,由 [InterruptMessageRender](/components/agent/interrupt-message) 按 `reason` 动态挂载。
|
|
21
|
+
|
|
22
|
+
> **通常不需要单独引入**;仅在需要独立预览卡片样式时使用。
|
|
23
|
+
|
|
24
|
+
## 渲染结构
|
|
25
|
+
|
|
26
|
+
```
|
|
27
|
+
ToolApprovalCard
|
|
28
|
+
├── 标题栏:左侧色条 + 单据标题 + 复制图标 + 状态徽章(审批中/已通过/已拒绝/已撤销等)
|
|
29
|
+
├── 字段区:单据编号、提交时间
|
|
30
|
+
├── 处理人:仅 `pending` / `draft` 时展示当前处理人(overflow-tips 省略)
|
|
31
|
+
└── 操作区:查看单据详情(新窗口打开 url)、取消审批(仅 pending / draft 且非 readonly;点击后 loading 防重复提交;分享只读渲染下禁用)
|
|
32
|
+
```
|
|
33
|
+
|
|
34
|
+
**标题栏刷新图标**(仅 `pending` / `draft` 且非 `readonly` 时展示,复制图标右侧):取消审批为后端轮询、状态无法实时返回,用户可点击刷新图标主动拉取单据最新状态,`hover` 显示 tooltip「刷新单据状态」。刷新做 **2s 冷却节流**(冷却中图标置灰不可点);点击「取消审批」也会触发一次 2s 冷却,即取消后需间隔 2s 才能继续刷新。分享只读渲染下刷新图标禁用。
|
|
35
|
+
|
|
36
|
+
操作区第二个按钮的形态随状态变化(`readonly` 时整体隐藏):
|
|
37
|
+
|
|
38
|
+
- **待审批(`pending` / `draft`)**:展示「取消审批」按钮;点击后按钮进入 **loading** 并禁用防重复提交(同步 resume 无法获知结果)。
|
|
39
|
+
- **终态(`approved` / `rejected` / `cancelled` / `revoked` / `expired` / `abandoned`)**:保留「取消审批」按钮但**置灰禁用**,`hover` 显示当前状态无法取消的原因;`cancelled` / `revoked` 态按钮文案为「已取消审批」。
|
|
40
|
+
|
|
41
|
+
置灰按钮的 tooltip 文案映射:
|
|
42
|
+
|
|
43
|
+
| `ticket.status` | 文案 |
|
|
44
|
+
| --------------------- | -------------------------- |
|
|
45
|
+
| `approved` | 该单据已通过,无法取消 |
|
|
46
|
+
| `rejected` | 该单据已被拒绝,无法取消 |
|
|
47
|
+
| `cancelled`、`revoked` | 单据已取消审批 |
|
|
48
|
+
| 其它终态(`expired`、`abandoned`) | 当前状态无法取消审批 |
|
|
49
|
+
|
|
50
|
+
`readonly` 为 `true` 时用于纯只读展示:隐藏刷新图标与第二个操作按钮(取消 / 置灰取消均不展示),不接受交互。注:`outcome.success` 结果回显自 [InterruptMessageRender](/components/agent/interrupt-message) 起已改为**可交互**挂载(`readonly: false`),不再传入 `readonly`;该 prop 仍保留供纯只读预览场景使用。
|
|
51
|
+
|
|
52
|
+
分享只读渲染模式(注入的 `RenderMode.Share`)下,操作按钮与刷新图标**保持可见但禁用**(区别于 `readonly` 的直接隐藏),避免在分享回显场景误触发。该渲染模式由 [ChatContainer](/components/setup/chat-container) 等容器通过 `useRenderModeProvider` 注入,组件内部经 `useRenderModeInject` 读取,业务侧无需手动设置。
|
|
53
|
+
|
|
54
|
+
取消审批与刷新均为同步 `onInterruptResume`,组件无法在回调内获知请求结果:取消点击后按钮立即进入 loading 防止重复取消;刷新做 2s 冷却节流供用户轮询最新状态;待后台刷新使卡片卸载/重建后交互态随实例销毁。
|
|
55
|
+
|
|
56
|
+
状态徽章样式:
|
|
57
|
+
|
|
58
|
+
| `ticket.status` | 视觉 |
|
|
59
|
+
| --------------------------------------- | -------- |
|
|
60
|
+
| `pending`、`draft` | 蓝色审批中 |
|
|
61
|
+
| `approved` | 绿色通过 |
|
|
62
|
+
| `rejected`、`cancelled`、`expired`、`abandoned` | 红色终态 |
|
|
63
|
+
| `revoked` | 橙色已撤销 |
|
|
64
|
+
|
|
65
|
+
## 基础用法(待审批)
|
|
66
|
+
|
|
67
|
+
> `ToolApprovalCard` 为 `InterruptMessageRender` 内部子组件,**未从 `@blueking/chat-x` 包入口导出**。业务侧通过构造 `InterruptMessage` 触发渲染即可;下方为类型与数据结构参考。
|
|
68
|
+
|
|
69
|
+
```vue
|
|
70
|
+
<template>
|
|
71
|
+
<!-- 业务侧推荐:由 MessageRender / MessageContainer 自动渲染 -->
|
|
72
|
+
<InterruptMessageRender
|
|
73
|
+
:content="interruptMessage.content"
|
|
74
|
+
role="interrupt"
|
|
75
|
+
:status="interruptMessage.status"
|
|
76
|
+
:on-interrupt-resume="handleInterruptResume"
|
|
77
|
+
/>
|
|
78
|
+
</template>
|
|
79
|
+
|
|
80
|
+
<script setup lang="ts">
|
|
81
|
+
import {
|
|
82
|
+
InterruptMessageRender,
|
|
83
|
+
APPROVAL_STATUS,
|
|
84
|
+
InterruptReason,
|
|
85
|
+
MessageRole,
|
|
86
|
+
MessageStatus,
|
|
87
|
+
type InterruptMessage,
|
|
88
|
+
type AIDevToolApprovalInterrupt,
|
|
89
|
+
} from '@blueking/chat-x';
|
|
90
|
+
|
|
91
|
+
const interrupt: AIDevToolApprovalInterrupt = {
|
|
92
|
+
id: 'interrupt_1',
|
|
93
|
+
reason: InterruptReason.AIDevToolApproval,
|
|
94
|
+
toolCallId: 'tool_call_1',
|
|
95
|
+
metadata: {
|
|
96
|
+
ticket: {
|
|
97
|
+
approvers: ['张三', '李四'],
|
|
98
|
+
sn: 'REV-2026-04-24-001',
|
|
99
|
+
status: APPROVAL_STATUS.PENDING,
|
|
100
|
+
submit_time: '2026-04-24 14:30:15',
|
|
101
|
+
title: '算法方案评审单',
|
|
102
|
+
url: 'https://example.com/tickets/001',
|
|
103
|
+
},
|
|
104
|
+
},
|
|
105
|
+
};
|
|
106
|
+
|
|
107
|
+
const interruptMessage: InterruptMessage = {
|
|
108
|
+
id: 'msg_1',
|
|
109
|
+
messageId: 'msg_1',
|
|
110
|
+
role: MessageRole.Interrupt,
|
|
111
|
+
status: MessageStatus.Pending,
|
|
112
|
+
content: {
|
|
113
|
+
outcome: { type: 'interrupt', interrupts: [interrupt] },
|
|
114
|
+
},
|
|
115
|
+
};
|
|
116
|
+
|
|
117
|
+
const handleInterruptResume = async (payload, interrupt) => {
|
|
118
|
+
console.log(payload, interrupt.id);
|
|
119
|
+
};
|
|
120
|
+
</script>
|
|
121
|
+
```
|
|
122
|
+
|
|
123
|
+
**渲染效果**(文档站直接挂载 `ToolApprovalCard` 预览卡片 UI)
|
|
124
|
+
|
|
125
|
+
## 已通过 / 已拒绝 / 已撤销
|
|
126
|
+
|
|
127
|
+
```vue
|
|
128
|
+
<div>
|
|
129
|
+
<InterruptMessageRender
|
|
130
|
+
:content="{ outcome: { type: 'interrupt', interrupts: [approvedInterrupt] } }"
|
|
131
|
+
role="interrupt"
|
|
132
|
+
/>
|
|
133
|
+
<InterruptMessageRender
|
|
134
|
+
:content="{ outcome: { type: 'interrupt', interrupts: [rejectedInterrupt] } }"
|
|
135
|
+
role="interrupt"
|
|
136
|
+
/>
|
|
137
|
+
<InterruptMessageRender
|
|
138
|
+
:content="{ outcome: { type: 'interrupt', interrupts: [revokedInterrupt] } }"
|
|
139
|
+
role="interrupt"
|
|
140
|
+
/>
|
|
141
|
+
</div>
|
|
142
|
+
```
|
|
143
|
+
|
|
144
|
+
**渲染效果**
|
|
145
|
+
|
|
146
|
+
## 只读展示(readonly)
|
|
147
|
+
|
|
148
|
+
`readonly` 用于纯只读展示审批单:隐藏刷新图标与「取消审批」按钮,不接受任何交互。注:`outcome.success` 结果回显自 [InterruptMessageRender](/components/agent/interrupt-message) 起已改为**可交互**挂载(不再传 `readonly`),此处仅演示 `readonly` prop 本身的效果:
|
|
149
|
+
|
|
150
|
+
```vue
|
|
151
|
+
<ToolApprovalCard
|
|
152
|
+
:interrupt="approvedInterrupt"
|
|
153
|
+
readonly
|
|
154
|
+
/>
|
|
155
|
+
```
|
|
156
|
+
|
|
157
|
+
**渲染效果**(待审批态下 readonly 不展示刷新图标与「取消审批」按钮)
|
|
158
|
+
|
|
159
|
+
## API
|
|
160
|
+
|
|
161
|
+
### Props
|
|
162
|
+
|
|
163
|
+
| 属性名 | 类型 | 默认值 | 说明 |
|
|
164
|
+
| ----------------- | ---------------------------- | ------ | -------------------------------------------- |
|
|
165
|
+
| interrupt | `AIDevToolApprovalInterrupt` | — | **必填**,含 `metadata.ticket` |
|
|
166
|
+
| onInterruptResume | `OnInterruptResume` | — | 取消审批 / 刷新时触发,签名为 `(payload, interrupt)`,payload 为 `{ operation, payload: { interrupt_id } }`,`operation` 取 `InterruptResumeOperation.ApprovalCancel`(取消)或 `InterruptResumeOperation.ApprovalRefresh`(刷新),两者 payload 结构一致 |
|
|
167
|
+
| readonly | `boolean` | — | 纯只读展示:隐藏取消 / 刷新按钮,不接受交互(`outcome.success` 回显已改为可交互,框架内部不再传入) |
|
|
168
|
+
|
|
169
|
+
### Events / Slots / Expose
|
|
170
|
+
|
|
171
|
+
无。打开链接、复制剪贴板在组件内部完成;取消审批通过 `onInterruptResume({ operation: InterruptResumeOperation.ApprovalCancel, payload: { interrupt_id: interrupt.id } }, interrupt)`、刷新单据通过 `onInterruptResume({ operation: InterruptResumeOperation.ApprovalRefresh, payload: { interrupt_id: interrupt.id } }, interrupt)` 通知业务侧处理。
|
|
172
|
+
|
|
173
|
+
## 依赖
|
|
174
|
+
|
|
175
|
+
- `bkui-vue`:`Button`、`Loading`
|
|
176
|
+
- `useClipboard` — 复制单据
|
|
177
|
+
- `v-overflow-tips` — 处理人超长省略
|
|
178
|
+
|
|
179
|
+
## 关联组件
|
|
180
|
+
|
|
181
|
+
- [InterruptMessage 中断消息](/components/agent/interrupt-message)
|
|
182
|
+
- [中断类型 Interrupt](../../types/interrupt.md)
|
|
183
|
+
- [常量枚举 Constants](../../types/constants.md) — `APPROVAL_STATUS`、`APPROVAL_STATUS_MAP`
|
|
@@ -0,0 +1,317 @@
|
|
|
1
|
+
# ToolBtn 工具按钮
|
|
2
|
+
|
|
3
|
+
> 能力域:工具与反馈 | 未从包入口导出:内部组件,请通过上层组件使用 | since 1.0.0
|
|
4
|
+
|
|
5
|
+
工具栏图标按钮。 源码位置:src/components/ai-buttons/tool-btn/tool-btn.vue。
|
|
6
|
+
|
|
7
|
+
**关联**:message-tools(父级组装多个工具按钮与交互)、delete-tool(删除确认场景内嵌为触发控件)
|
|
8
|
+
|
|
9
|
+
---
|
|
10
|
+
|
|
11
|
+
# ToolBtn 工具按钮
|
|
12
|
+
## 源码事实
|
|
13
|
+
|
|
14
|
+
- **源码位置**:`src/components/ai-buttons/tool-btn/tool-btn.vue`
|
|
15
|
+
- **能力域**:工具与反馈
|
|
16
|
+
- **能力说明**:工具栏图标按钮。
|
|
17
|
+
|
|
18
|
+
> **能力域**:工具与反馈
|
|
19
|
+
|
|
20
|
+
消息工具栏中的单个操作按钮,内置 SVG 图标映射、Tippy 悬浮提示、激活态与禁用态,通常由 `MessageTools` 管理,一般不需要手动使用。
|
|
21
|
+
|
|
22
|
+
## 组件结构
|
|
23
|
+
|
|
24
|
+
```
|
|
25
|
+
div.ai-tool-btn(v-tippy,flex,min-width: 20px,height: 20px,border-radius: 4px)
|
|
26
|
+
color: #a8aab2; background: transparent
|
|
27
|
+
active=true → .is-active(color: var(--ai-tool-btn-active-color))
|
|
28
|
+
disabled=true → .is-disabled(color: #979ba5; cursor: not-allowed)
|
|
29
|
+
:not(.is-disabled):hover → color: #4d4f56; background: #eaebf0
|
|
30
|
+
│
|
|
31
|
+
└── <slot>(默认内容,可完全自定义;优先级最高)
|
|
32
|
+
├── [icon] → <component :is="icon" />(自定义图标组件/VNode,优先级高于内置图标)
|
|
33
|
+
├── [id && id in ToolIconsMap] → <component :is="ToolIconsMap[id]" />(内置 SVG 图标)
|
|
34
|
+
└── [其他] → <div>{{ name }}</div>(文本回退,XSS 安全)
|
|
35
|
+
|
|
36
|
+
Tippy:content=description, theme='ai-chat-box', disabled=true 时 onShow 返回 false 不显示
|
|
37
|
+
click 事件:disabled=true 时被 JS 拦截,不触发 emit
|
|
38
|
+
|
|
39
|
+
激活色(CSS 变量 --ai-tool-btn-active-color):
|
|
40
|
+
id === 'like' 或 'activeLike' → #3a84ff(蓝色)
|
|
41
|
+
其他 id(如 'unlike'、'delete') → #E71818(红色)
|
|
42
|
+
```
|
|
43
|
+
|
|
44
|
+
## 预置图标(ToolIconsMap)
|
|
45
|
+
|
|
46
|
+
| id | 说明 | 备注 |
|
|
47
|
+
| -------------- | -------------- | ------------------------ |
|
|
48
|
+
| `copy` | 复制 | |
|
|
49
|
+
| `cite` | 引用 | |
|
|
50
|
+
| `rebuild` | 重新生成 | |
|
|
51
|
+
| `share` | 分享 | |
|
|
52
|
+
| `like` | 点赞(空心) | 配合 `activeLike` 使用 |
|
|
53
|
+
| `unlike` | 不满意(空心) | 配合 `activeUnLike` 使用 |
|
|
54
|
+
| `delete` | 删除 | |
|
|
55
|
+
| `edit` | 编辑 | |
|
|
56
|
+
| `activeLike` | 点赞(实心) | 激活态填充图标 |
|
|
57
|
+
| `activeUnLike` | 不满意(实心) | 激活态填充图标 |
|
|
58
|
+
|
|
59
|
+
> 未传入 `id`、或 `id` 不在上表时,组件渲染 `<div>{{ name }}</div>` 作为文本回退。也可通过默认插槽完全自定义按钮内容(如全屏图标),此时可不传 `id`。
|
|
60
|
+
|
|
61
|
+
## 基础用法
|
|
62
|
+
|
|
63
|
+
```vue
|
|
64
|
+
<template>
|
|
65
|
+
<div style="display: flex; gap: 6px;">
|
|
66
|
+
<ToolBtn
|
|
67
|
+
id="copy"
|
|
68
|
+
name="复制"
|
|
69
|
+
description="复制消息内容"
|
|
70
|
+
@click="handleClick"
|
|
71
|
+
/>
|
|
72
|
+
<ToolBtn
|
|
73
|
+
id="cite"
|
|
74
|
+
name="引用"
|
|
75
|
+
description="引用此消息"
|
|
76
|
+
@click="handleClick"
|
|
77
|
+
/>
|
|
78
|
+
<ToolBtn
|
|
79
|
+
id="rebuild"
|
|
80
|
+
name="重新生成"
|
|
81
|
+
description="重新生成回答"
|
|
82
|
+
@click="handleClick"
|
|
83
|
+
/>
|
|
84
|
+
<ToolBtn
|
|
85
|
+
id="share"
|
|
86
|
+
name="分享"
|
|
87
|
+
description="分享消息"
|
|
88
|
+
@click="handleClick"
|
|
89
|
+
/>
|
|
90
|
+
<ToolBtn
|
|
91
|
+
id="like"
|
|
92
|
+
name="点赞"
|
|
93
|
+
description="对此回答满意"
|
|
94
|
+
@click="handleClick"
|
|
95
|
+
/>
|
|
96
|
+
<ToolBtn
|
|
97
|
+
id="unlike"
|
|
98
|
+
name="不满意"
|
|
99
|
+
description="对此回答不满意"
|
|
100
|
+
@click="handleClick"
|
|
101
|
+
/>
|
|
102
|
+
<ToolBtn
|
|
103
|
+
id="edit"
|
|
104
|
+
name="编辑"
|
|
105
|
+
description="编辑消息"
|
|
106
|
+
@click="handleClick"
|
|
107
|
+
/>
|
|
108
|
+
<ToolBtn
|
|
109
|
+
id="delete"
|
|
110
|
+
name="删除"
|
|
111
|
+
description="删除消息"
|
|
112
|
+
@click="handleClick"
|
|
113
|
+
/>
|
|
114
|
+
</div>
|
|
115
|
+
</template>
|
|
116
|
+
|
|
117
|
+
<script setup lang="ts">
|
|
118
|
+
import { ToolBtn } from '@blueking/chat-x';
|
|
119
|
+
import type { IToolBtn } from '@blueking/chat-x';
|
|
120
|
+
|
|
121
|
+
const handleClick = (data: IToolBtn & { active?: boolean; disabled?: boolean }, event: MouseEvent) => {
|
|
122
|
+
console.log('点击了:', data.id, data.name);
|
|
123
|
+
};
|
|
124
|
+
</script>
|
|
125
|
+
```
|
|
126
|
+
|
|
127
|
+
## 激活态与图标切换(点赞/踩)
|
|
128
|
+
|
|
129
|
+
`active` 只控制 `.is-active` 背景高亮,不自动切换图标。若需要填充图标,需在 `:id` 绑定中主动切换 `activeLike` / `activeUnLike`:
|
|
130
|
+
|
|
131
|
+
```vue
|
|
132
|
+
<template>
|
|
133
|
+
<div style="display: flex; gap: 6px;">
|
|
134
|
+
<!-- 切换 id 实现图标填充 -->
|
|
135
|
+
<ToolBtn
|
|
136
|
+
:id="activeId === 'like' ? 'activeLike' : 'like'"
|
|
137
|
+
name="点赞"
|
|
138
|
+
description="点赞"
|
|
139
|
+
:active="activeId === 'like'"
|
|
140
|
+
@click="toggleActive"
|
|
141
|
+
/>
|
|
142
|
+
<ToolBtn
|
|
143
|
+
:id="activeId === 'unlike' ? 'activeUnLike' : 'unlike'"
|
|
144
|
+
name="不满意"
|
|
145
|
+
description="不满意"
|
|
146
|
+
:active="activeId === 'unlike'"
|
|
147
|
+
@click="toggleActive"
|
|
148
|
+
/>
|
|
149
|
+
</div>
|
|
150
|
+
</template>
|
|
151
|
+
|
|
152
|
+
<script setup lang="ts">
|
|
153
|
+
import { ref } from 'vue';
|
|
154
|
+
import { ToolBtn } from '@blueking/chat-x';
|
|
155
|
+
import type { IToolBtn } from '@blueking/chat-x';
|
|
156
|
+
|
|
157
|
+
const activeId = ref<string | null>(null);
|
|
158
|
+
|
|
159
|
+
const toggleActive = (data: IToolBtn) => {
|
|
160
|
+
// 规范化 id(activeLike → like)后再比较
|
|
161
|
+
const baseId = data.id.replace(/^active/, '').replace(/^./, c => c.toLowerCase());
|
|
162
|
+
activeId.value = activeId.value === baseId ? null : baseId;
|
|
163
|
+
};
|
|
164
|
+
</script>
|
|
165
|
+
```
|
|
166
|
+
|
|
167
|
+
## 禁用状态
|
|
168
|
+
|
|
169
|
+
`disabled=true` 时:JS 拦截 click 不触发事件 + Tippy 的 `onShow` 返回 `false` 不显示 tooltip:
|
|
170
|
+
|
|
171
|
+
```vue
|
|
172
|
+
<template>
|
|
173
|
+
<div style="display: flex; gap: 6px; align-items: center;">
|
|
174
|
+
<ToolBtn
|
|
175
|
+
id="copy"
|
|
176
|
+
name="复制"
|
|
177
|
+
description="复制"
|
|
178
|
+
:disabled="isDisabled"
|
|
179
|
+
@click="handleClick"
|
|
180
|
+
/>
|
|
181
|
+
<ToolBtn
|
|
182
|
+
id="edit"
|
|
183
|
+
name="编辑"
|
|
184
|
+
description="编辑"
|
|
185
|
+
:disabled="isDisabled"
|
|
186
|
+
@click="handleClick"
|
|
187
|
+
/>
|
|
188
|
+
<button @click="isDisabled = !isDisabled">{{ isDisabled ? '启用' : '禁用' }}</button>
|
|
189
|
+
</div>
|
|
190
|
+
</template>
|
|
191
|
+
```
|
|
192
|
+
|
|
193
|
+
## 未知 ID 的文本回退
|
|
194
|
+
|
|
195
|
+
`id` 不在 `ToolIconsMap` 时渲染 `name` 文本,适用于自定义扩展场景:
|
|
196
|
+
|
|
197
|
+
## 自定义图标(icon 属性)
|
|
198
|
+
|
|
199
|
+
当内置 `ToolIconsMap` 未覆盖所需图标时,可通过 `icon` 传入自定义图标组件或 VNode(如业务新增的「保存」按钮)。`icon` 的渲染优先级高于内置图标,因此即便 `id` 命中内置图标,也会以 `icon` 为准。
|
|
200
|
+
|
|
201
|
+
```vue
|
|
202
|
+
<template>
|
|
203
|
+
<ToolBtn
|
|
204
|
+
id="save"
|
|
205
|
+
name="保存"
|
|
206
|
+
description="保存该回答"
|
|
207
|
+
:icon="DownloadIcon"
|
|
208
|
+
@click="handleClick"
|
|
209
|
+
/>
|
|
210
|
+
</template>
|
|
211
|
+
|
|
212
|
+
<script setup lang="ts">
|
|
213
|
+
import { ToolBtn, DownloadIcon } from '@blueking/chat-x';
|
|
214
|
+
</script>
|
|
215
|
+
```
|
|
216
|
+
|
|
217
|
+
> 优先级从高到低:默认插槽 `>` `icon` 属性 `>` 内置 `ToolIconsMap[id]` `>` `name` 文本回退。
|
|
218
|
+
|
|
219
|
+
## 自定义插槽内容
|
|
220
|
+
|
|
221
|
+
通过默认插槽可完全替换内置图标/文本,适用于预置 `ToolIconsMap` 未覆盖的图标场景(如侧栏全屏按钮):
|
|
222
|
+
|
|
223
|
+
```vue
|
|
224
|
+
<template>
|
|
225
|
+
<ToolBtn
|
|
226
|
+
description="全屏"
|
|
227
|
+
:tippy-options="{ content: '全屏' }"
|
|
228
|
+
@click="handleFullScreen"
|
|
229
|
+
>
|
|
230
|
+
<FullScreenIcon />
|
|
231
|
+
</ToolBtn>
|
|
232
|
+
</template>
|
|
233
|
+
|
|
234
|
+
<script setup lang="ts">
|
|
235
|
+
import { ToolBtn, FullScreenIcon } from '@blueking/chat-x';
|
|
236
|
+
|
|
237
|
+
const handleFullScreen = () => {
|
|
238
|
+
// 进入全屏逻辑
|
|
239
|
+
};
|
|
240
|
+
</script>
|
|
241
|
+
```
|
|
242
|
+
|
|
243
|
+
## API
|
|
244
|
+
|
|
245
|
+
### Props
|
|
246
|
+
|
|
247
|
+
| 属性名 | 类型 | 必填 | 默认值 | 说明 |
|
|
248
|
+
| ------------ | -------------------------------------------------------------------------- | ---- | ------ | ------------------------------------------------------------------------------------------------------------------ |
|
|
249
|
+
| id | `(string & {}) \| ToolIcons` | 否 | — | 按钮标识;命中 `ToolIconsMap` 时渲染对应 SVG 图标,否则渲染 `name` 文本;支持业务自定义任意字符串(如 `save`) |
|
|
250
|
+
| name | `string` | 否 | — | 按钮名称;`id` 无对应图标时作为文本内容渲染 |
|
|
251
|
+
| description | `string` | 否 | — | Tippy tooltip 内容;`disabled=true` 时不显示 tooltip |
|
|
252
|
+
| icon | `Component \| VNode` | 否 | — | 自定义图标组件或 VNode;优先级高于内置 `ToolIconsMap[id]`,低于默认插槽 |
|
|
253
|
+
| active | `boolean` | 否 | — | 激活态;`true` 时追加 `.is-active`(字色由 `id` 决定:`like`/`activeLike` 为蓝色 `#3a84ff`,其他为红色 `#E71818`) |
|
|
254
|
+
| disabled | `boolean` | 否 | — | 禁用态;`true` 时追加 `.is-disabled`,阻止 click 事件,隐藏 tooltip |
|
|
255
|
+
| tippyOptions | `Partial<Omit<TippyOptions, 'getReferenceClientRect' \| 'triggerTarget'>>` | 否 | — | 自定义 Tippy 配置,与内部默认配置合并;可用于控制 `content`、`appendTo`、`placement` 等 |
|
|
256
|
+
|
|
257
|
+
### Events
|
|
258
|
+
|
|
259
|
+
| 事件名 | 参数 | 说明 |
|
|
260
|
+
| ------ | -------------------------------------------------------------------------------- | ------------------------------------------------------------------------------------------- |
|
|
261
|
+
| click | `(data: IToolBtn & { active?: boolean; disabled?: boolean }, event: MouseEvent)` | 点击时触发;`data` 为组件当前全量 props(含 `active`/`disabled`);`disabled=true` 时不触发 |
|
|
262
|
+
|
|
263
|
+
### Slots
|
|
264
|
+
|
|
265
|
+
| 插槽名 | 说明 |
|
|
266
|
+
| ------- | ------------------------------------------------------------------------------------------ |
|
|
267
|
+
| default | 按钮内容;传入时替换默认的图标/文本渲染逻辑,常用于自定义 SVG 图标(如全屏、退出全屏按钮) |
|
|
268
|
+
|
|
269
|
+
## 类型定义
|
|
270
|
+
|
|
271
|
+
```typescript
|
|
272
|
+
import type { Component, VNode } from 'vue';
|
|
273
|
+
|
|
274
|
+
// 来自 @blueking/chat-x 导出
|
|
275
|
+
interface IToolBtn {
|
|
276
|
+
id?: (string & {}) | ToolIcons; // 内置 ID 保留自动补全,同时允许业务自定义任意字符串(如 'save')
|
|
277
|
+
name?: string;
|
|
278
|
+
description?: string;
|
|
279
|
+
icon?: Component | VNode; // 自定义图标,优先级高于内置 ToolIconsMap
|
|
280
|
+
hidden?: boolean; // 按 id 合并时隐藏该按钮(如 { id: 'share', hidden: true } 移除内置项)
|
|
281
|
+
triggerSelection?: boolean; // 标记点击后进入多选态(复用 share 选择流程),确认走 confirmShare
|
|
282
|
+
}
|
|
283
|
+
|
|
284
|
+
// ToolBtn 完整 Props
|
|
285
|
+
type ToolBtnProps = IToolBtn & {
|
|
286
|
+
active?: boolean;
|
|
287
|
+
disabled?: boolean;
|
|
288
|
+
tippyOptions?: Partial<Omit<TippyOptions, 'getReferenceClientRect' | 'triggerTarget'>>;
|
|
289
|
+
};
|
|
290
|
+
|
|
291
|
+
// 预置 ID 枚举
|
|
292
|
+
type ToolIcons =
|
|
293
|
+
| 'copy'
|
|
294
|
+
| 'cite'
|
|
295
|
+
| 'rebuild'
|
|
296
|
+
| 'share'
|
|
297
|
+
| 'like'
|
|
298
|
+
| 'unlike'
|
|
299
|
+
| 'delete'
|
|
300
|
+
| 'edit'
|
|
301
|
+
| 'activeLike'
|
|
302
|
+
| 'activeUnLike';
|
|
303
|
+
```
|
|
304
|
+
|
|
305
|
+
## 注意事项
|
|
306
|
+
|
|
307
|
+
1. **`click` 事件的 `data` 参数**是组件的完整 props 对象(含 `active`、`disabled`),并非单纯的 `IToolBtn`
|
|
308
|
+
2. **`activeLike` / `activeUnLike`**:是单独的填充版图标 ID,并非 `active=true` 时自动切换,需要手动在 `:id` 绑定中控制
|
|
309
|
+
3. **根元素是 `<div>` 而非 `<button>`**:没有原生按钮语义,键盘无障碍访问需外部额外处理
|
|
310
|
+
4. **`description` 可选**:不传时 tooltip 内容为 `undefined`,Tippy 不显示提示
|
|
311
|
+
5. **`disabled` 的 CSS**:`pointer-events: hover` 为无效 CSS 值(应为 `none`),鼠标事件实际由 JS 层拦截,CSS 层仍可触发 hover 样式
|
|
312
|
+
6. **`tippyOptions` 优先级**:`tippyOptions` 中的配置会覆盖内部默认值(包括 `content`、`theme`),但 `onShow` 始终保留内部逻辑(禁用时不显示)。`getReferenceClientRect`、`triggerTarget` 两个字段被 Omit 排除,不可通过此 prop 覆盖;`content` 已可通过 `tippyOptions.content` 覆盖
|
|
313
|
+
|
|
314
|
+
## 关联组件
|
|
315
|
+
|
|
316
|
+
- [MessageTools](/components/feedback/message-tools) — 工具栏容器
|
|
317
|
+
- [DeleteTool](/components/feedback/delete-tool) — 删除确认内嵌触发
|