@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,202 @@
|
|
|
1
|
+
# AnimationText 动画文本
|
|
2
|
+
|
|
3
|
+
> 能力域:内容渲染 | 未从包入口导出:内部组件,请通过上层组件使用 | since 1.0.0
|
|
4
|
+
|
|
5
|
+
按文本增量播放流式动画。 源码位置:src/components/animation-text/animation-text.vue。
|
|
6
|
+
|
|
7
|
+
**关联**:use-animation-text(提供 chunk 拆分与 animationStyle 的 composable)、markdown-content(流式 Markdown 中可与渐显策略配合)
|
|
8
|
+
|
|
9
|
+
---
|
|
10
|
+
|
|
11
|
+
# AnimationText 动画文本
|
|
12
|
+
## 源码事实
|
|
13
|
+
|
|
14
|
+
- **源码位置**:`src/components/animation-text/animation-text.vue`
|
|
15
|
+
- **能力域**:内容渲染
|
|
16
|
+
- **能力说明**:按文本增量播放流式动画。
|
|
17
|
+
|
|
18
|
+
> **能力域**:内容渲染
|
|
19
|
+
|
|
20
|
+
动画文本基础组件,将文本以**淡入(fade-in)**方式渐显。内部由 `useAnimationText` composable 驱动,核心能力是将增量文本拆分为独立 chunk,每个 chunk 单独触发一次淡入动画,适用于流式文本的逐段渐显效果。
|
|
21
|
+
|
|
22
|
+
## 组件结构
|
|
23
|
+
|
|
24
|
+
```
|
|
25
|
+
AnimationText
|
|
26
|
+
└── <span v-for="chunk in chunks" :style="animationStyle">
|
|
27
|
+
{{ chunk }}
|
|
28
|
+
</span>
|
|
29
|
+
|
|
30
|
+
animationStyle = {
|
|
31
|
+
animation: `ai-markdown-fade-in {fadeDuration}ms {easing} forwards`,
|
|
32
|
+
color: 'inherit',
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
@keyframes ai-markdown-fade-in {
|
|
36
|
+
0% { opacity: 0; }
|
|
37
|
+
100% { opacity: 1; }
|
|
38
|
+
}
|
|
39
|
+
```
|
|
40
|
+
|
|
41
|
+
> **注意**:`AnimationText` 组件将 `props.text`(字符串原始值)传给 `useAnimationText`,watch 只触发一次(挂载时),**prop 变化后不会触发新动画**。若需响应式流式效果,请直接使用 `useAnimationText` composable,并传入 `Ref<string>`。
|
|
42
|
+
|
|
43
|
+
## 基础用法
|
|
44
|
+
|
|
45
|
+
挂载时文本以淡入方式显示,适合一次性展示的短文本动画:
|
|
46
|
+
|
|
47
|
+
```vue
|
|
48
|
+
<template>
|
|
49
|
+
<AnimationText text="这是一段带动画效果的文本" />
|
|
50
|
+
</template>
|
|
51
|
+
|
|
52
|
+
<script setup lang="ts">
|
|
53
|
+
import { AnimationText } from '@blueking/chat-x';
|
|
54
|
+
</script>
|
|
55
|
+
```
|
|
56
|
+
|
|
57
|
+
## 流式文本(推荐使用 composable)
|
|
58
|
+
|
|
59
|
+
对于流式输出场景,需直接使用 `useAnimationText` 并传入响应式 `Ref<string>`:
|
|
60
|
+
|
|
61
|
+
```vue
|
|
62
|
+
<template>
|
|
63
|
+
<span
|
|
64
|
+
v-for="(chunk, index) in streamChunks"
|
|
65
|
+
:key="index"
|
|
66
|
+
:style="streamAnimStyle"
|
|
67
|
+
>{{ chunk }}</span
|
|
68
|
+
>
|
|
69
|
+
</template>
|
|
70
|
+
|
|
71
|
+
<script setup lang="ts">
|
|
72
|
+
import { ref, watch } from 'vue';
|
|
73
|
+
|
|
74
|
+
const streamText = ref('');
|
|
75
|
+
const streamChunks = ref<string[]>([]);
|
|
76
|
+
const streamAnimStyle = {
|
|
77
|
+
animation: 'ai-markdown-fade-in 200ms ease-in-out forwards',
|
|
78
|
+
color: 'inherit',
|
|
79
|
+
};
|
|
80
|
+
|
|
81
|
+
// 直接 watch Ref(Vue 自动追踪 .value 变化)
|
|
82
|
+
// ⚠️ 不能写成 watch(() => streamText, ...),那样 getter 每次返回同一个 Ref 引用,永远不触发
|
|
83
|
+
watch(streamText, (newVal, oldVal) => {
|
|
84
|
+
if (!oldVal || !newVal.startsWith(oldVal)) {
|
|
85
|
+
streamChunks.value = [newVal]; // 内容替换 → 整体重置
|
|
86
|
+
} else {
|
|
87
|
+
const chunk = newVal.slice(oldVal.length);
|
|
88
|
+
if (chunk) streamChunks.value = [...streamChunks.value, chunk]; // 追加 → 新 chunk 淡入
|
|
89
|
+
}
|
|
90
|
+
});
|
|
91
|
+
|
|
92
|
+
// 模拟流式追加
|
|
93
|
+
async function receiveStream() {
|
|
94
|
+
streamText.value = '';
|
|
95
|
+
streamChunks.value = [];
|
|
96
|
+
for (const char of '来自 AI 的流式回复内容...') {
|
|
97
|
+
streamText.value += char;
|
|
98
|
+
await new Promise(r => setTimeout(r, 80));
|
|
99
|
+
}
|
|
100
|
+
}
|
|
101
|
+
</script>
|
|
102
|
+
```
|
|
103
|
+
|
|
104
|
+
**效果演示**(点击按钮触发流式输出)
|
|
105
|
+
|
|
106
|
+
## chunk 增量算法
|
|
107
|
+
|
|
108
|
+
`useAnimationText` 内部通过**前缀检测**将文本变化拆分为增量 chunk:
|
|
109
|
+
|
|
110
|
+
```
|
|
111
|
+
新文本以旧文本为前缀(即纯追加)→ 截取增量部分 → 追加新 chunk(触发新动画)
|
|
112
|
+
新文本与旧文本无前缀关系(内容替换)→ 清空所有 chunk → 用完整新文本创建单一 chunk
|
|
113
|
+
```
|
|
114
|
+
|
|
115
|
+
```typescript
|
|
116
|
+
// watch 内部逻辑(简化)
|
|
117
|
+
if (newText === prevText) return; // 无变化,跳过
|
|
118
|
+
|
|
119
|
+
if (prevText && newText.startsWith(prevText)) {
|
|
120
|
+
// 追加模式:只有新增部分触发淡入
|
|
121
|
+
const newChunk = newText.slice(prevText.length);
|
|
122
|
+
chunks.value = [...chunks.value, newChunk];
|
|
123
|
+
} else {
|
|
124
|
+
// 重置模式:内容替换,整体重新淡入
|
|
125
|
+
chunks.value = [newText];
|
|
126
|
+
}
|
|
127
|
+
prevText = newText;
|
|
128
|
+
```
|
|
129
|
+
|
|
130
|
+
| 场景 | 示例 | 行为 |
|
|
131
|
+
| --------------- | ------------------------------------------ | ------------------------------ |
|
|
132
|
+
| 流式追加(SSE) | `"Hello"` → `"Hello Wo"` → `"Hello World"` | 每次增量部分单独淡入 |
|
|
133
|
+
| 内容完全替换 | `"旧文本"` → `"新文本"` | 清空所有 chunk,新文本整体淡入 |
|
|
134
|
+
| 相同内容 | `"文本"` → `"文本"` | 不做任何处理,跳过 |
|
|
135
|
+
|
|
136
|
+
## 自定义动画参数
|
|
137
|
+
|
|
138
|
+
`useAnimationText` 支持通过第二个参数自定义动画时长和缓动:
|
|
139
|
+
|
|
140
|
+
```typescript
|
|
141
|
+
import { ref } from 'vue';
|
|
142
|
+
import { useAnimationText } from '@blueking/chat-x';
|
|
143
|
+
|
|
144
|
+
const text = ref('');
|
|
145
|
+
const { chunks, animationStyle } = useAnimationText(text, {
|
|
146
|
+
fadeDuration: 400, // 动画时长(ms),默认 200
|
|
147
|
+
easing: 'ease-out', // CSS easing,默认 'ease-in-out'
|
|
148
|
+
});
|
|
149
|
+
```
|
|
150
|
+
|
|
151
|
+
生成的 `animationStyle`:
|
|
152
|
+
|
|
153
|
+
```typescript
|
|
154
|
+
// animationStyle 是 computed,格式为:
|
|
155
|
+
{
|
|
156
|
+
animation: `ai-markdown-fade-in ${fadeDuration}ms ${easing} forwards`,
|
|
157
|
+
color: 'inherit',
|
|
158
|
+
}
|
|
159
|
+
```
|
|
160
|
+
|
|
161
|
+
> **关键帧**:`ai-markdown-fade-in` 定义在库的全局样式中,仅做透明度变化(`opacity: 0 → 1`),无位移或缩放。
|
|
162
|
+
|
|
163
|
+
## API
|
|
164
|
+
|
|
165
|
+
### AnimationText Props
|
|
166
|
+
|
|
167
|
+
| 属性名 | 类型 | 必填 | 说明 |
|
|
168
|
+
| ------ | -------- | ---- | ----------------------------------------------- |
|
|
169
|
+
| text | `string` | ✓ | 要显示的文本;仅挂载时触发动画,prop 更新后无效 |
|
|
170
|
+
|
|
171
|
+
### useAnimationText
|
|
172
|
+
|
|
173
|
+
```typescript
|
|
174
|
+
function useAnimationText(
|
|
175
|
+
text: MaybeRef<string>, // 字符串或 Ref<string>,传 Ref 才能响应变化
|
|
176
|
+
options?: AnimationConfig,
|
|
177
|
+
): {
|
|
178
|
+
chunks: Ref<string[]>; // 分割后的文本块数组,v-for 遍历渲染
|
|
179
|
+
animationStyle: ComputedRef<{
|
|
180
|
+
// 应用到每个 <span> 的 inline style
|
|
181
|
+
animation: string;
|
|
182
|
+
color: 'inherit';
|
|
183
|
+
}>;
|
|
184
|
+
};
|
|
185
|
+
|
|
186
|
+
interface AnimationConfig {
|
|
187
|
+
fadeDuration?: number; // 动画时长(ms),默认 200
|
|
188
|
+
easing?: string; // CSS easing,默认 'ease-in-out'
|
|
189
|
+
}
|
|
190
|
+
```
|
|
191
|
+
|
|
192
|
+
## 注意事项
|
|
193
|
+
|
|
194
|
+
1. **`AnimationText` 不响应 prop 更新**:组件内部传的是字符串原始值,若需动态响应,直接用 `watch(myRef, ...)` 手动实现 chunk 逻辑
|
|
195
|
+
2. **流式场景不要使用 `useAnimationText`**:该 composable 内部使用 `watch(() => text, ...)` 的 getter 形式,当传入 `Ref<string>` 时,getter 每次返回同一个 Ref 引用,Vue 无法检测到 `.value` 变化,watch 只触发一次(immediate)。正确做法是直接 `watch(streamText, callback)` 绑定 Ref
|
|
196
|
+
3. **动画 keyframe 依赖全局样式**:使用 `@blueking/chat-x` 时会自动引入;独立使用时需确保 `ai-markdown-fade-in` 已定义
|
|
197
|
+
4. **chunks 只增不减**(追加模式下):流式结束后 chunks 保留所有历史分段,若需复用,手动清空 `chunks.value = []` 再重置文本即可
|
|
198
|
+
|
|
199
|
+
## 关联组件
|
|
200
|
+
|
|
201
|
+
- [useAnimationText](../../composables/use-animation-text.md) — chunk 与动画样式逻辑
|
|
202
|
+
- [MarkdownContent](/components/rendering/markdown-content) — 流式正文渲染时可配合渐显
|