v0.16.13: 修复流式渲染失效 Bug + 版本号更新
This commit is contained in:
@@ -115,22 +115,28 @@ export class OllamaAPI {
|
||||
|
||||
for (const line of lines) {
|
||||
if (!line.trim()) continue;
|
||||
let chunk: OllamaStreamChunk;
|
||||
try {
|
||||
const chunk: OllamaStreamChunk = JSON.parse(line);
|
||||
if (onChunk) onChunk(chunk);
|
||||
if (chunk.done) {
|
||||
return;
|
||||
}
|
||||
chunk = JSON.parse(line);
|
||||
} catch {
|
||||
continue; // 跳过无法解析的行(可能是不完整的 JSON)
|
||||
}
|
||||
// onChunk 回调错误不再被静默吞掉,而是向上传播给调用方
|
||||
if (onChunk) onChunk(chunk);
|
||||
if (chunk.done) {
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (buffer.trim()) {
|
||||
let chunk: OllamaStreamChunk;
|
||||
try {
|
||||
const chunk: OllamaStreamChunk = JSON.parse(buffer);
|
||||
if (onChunk) onChunk(chunk);
|
||||
} catch { /* ignore */ }
|
||||
chunk = JSON.parse(buffer);
|
||||
} catch {
|
||||
return; // 末尾 buffer 无法解析,忽略
|
||||
}
|
||||
if (onChunk) onChunk(chunk);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -478,9 +478,11 @@ export function updateLastAssistantMessage(
|
||||
addCodeBlockCopyButtons(contentDiv);
|
||||
} else {
|
||||
// 流式期间:实时 Markdown 渲染 + rAF 节流
|
||||
// R58-fix: 移除对未声明变量 _streamRenderThink/_streamRenderModel 的赋值
|
||||
// 原代码在严格模式下会抛出 ReferenceError,被 chatStream 的空 catch 静默吞掉,
|
||||
// 导致 requestAnimationFrame(_doStreamRender) 永远不会被调用,流式渲染完全失效。
|
||||
// think 和 model 已在上方(model tag)和下方(think block)直接处理,无需传递给 _doStreamRender。
|
||||
_streamRenderContent = safeContent;
|
||||
_streamRenderThink = think;
|
||||
_streamRenderModel = model;
|
||||
if (!_streamRenderPending) {
|
||||
_streamRenderPending = true;
|
||||
requestAnimationFrame(_doStreamRender);
|
||||
|
||||
@@ -28,7 +28,7 @@
|
||||
<div class="header-left">
|
||||
<img class="logo" src="./assets/icons/llama.png" alt="logo" />
|
||||
<span class="app-title">Metona Ollama</span>
|
||||
<span class="app-version">v0.16.12</span>
|
||||
<span class="app-version">v0.16.13</span>
|
||||
<button class="icon-btn help-btn" id="btnHelp" title="使用帮助">
|
||||
<svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2">
|
||||
<circle cx="12" cy="12" r="10"/><path d="M9.09 9a3 3 0 0 1 5.83 1c0 2-3 3-3 3"/>
|
||||
|
||||
Reference in New Issue
Block a user