(messageId: string, delta: string)
| 134 | * 处理文本块(高频事件,使用 RAF 批量更新) |
| 135 | */ |
| 136 | const handleTextChunk = (messageId: string, delta: string) => { |
| 137 | // 累积文本块 |
| 138 | const chunks = pendingTextChunks.value.get(messageId) || []; |
| 139 | chunks.push(delta); |
| 140 | pendingTextChunks.value.set(messageId, chunks); |
| 141 | |
| 142 | // 批量更新(每帧一次) |
| 143 | if (rafId === null) { |
| 144 | rafId = requestAnimationFrame(() => { |
| 145 | flushTextChunks(); |
| 146 | rafId = null; |
| 147 | }); |
| 148 | } |
| 149 | }; |
| 150 | |
| 151 | /** |
| 152 | * 刷新文本块(批量更新到消息) |
nothing calls this directly
no test coverage detected