From 28655b80d920efed00f9a842035399a2bb7ac42d Mon Sep 17 00:00:00 2001 From: thzxx <1440196015@qq.com> Date: Thu, 30 Jul 2026 21:10:00 +0800 Subject: [PATCH] =?UTF-8?q?v0.16.13:=20=E4=BF=AE=E5=A4=8D=E6=B5=81?= =?UTF-8?q?=E5=BC=8F=E6=B8=B2=E6=9F=93=E5=A4=B1=E6=95=88=20Bug=20+=20?= =?UTF-8?q?=E7=89=88=E6=9C=AC=E5=8F=B7=E6=9B=B4=E6=96=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- README.md | 6 +++--- package-lock.json | 4 ++-- package.json | 2 +- src/main/menu.ts | 2 +- src/renderer/api/ollama.ts | 22 ++++++++++++++-------- src/renderer/components/chat-area.ts | 6 ++++-- src/renderer/index.html | 2 +- 7 files changed, 26 insertions(+), 18 deletions(-) diff --git a/README.md b/README.md index 350ee38..de155c5 100644 --- a/README.md +++ b/README.md @@ -14,7 +14,7 @@
-
+
@@ -245,7 +245,7 @@ npm start
ELECTRON_MIRROR=https://npmmirror.com/mirrors/electron/ npm run dist
```
-产出:`release/Metona Ollama Setup v0.16.12.exe`
+产出:`release/Metona Ollama Setup v0.16.13.exe`
## 🛠️ 常用命令
@@ -485,7 +485,7 @@ npm start
ELECTRON_MIRROR=https://npmmirror.com/mirrors/electron/ npm run dist
```
-Output: `release/Metona Ollama Setup v0.16.12.exe`
+Output: `release/Metona Ollama Setup v0.16.13.exe`
## 🛠️ Common Commands
diff --git a/package-lock.json b/package-lock.json
index 701212d..b3562a1 100644
--- a/package-lock.json
+++ b/package-lock.json
@@ -1,12 +1,12 @@
{
"name": "metona-ollama-desktop",
- "version": "0.16.12",
+ "version": "0.16.13",
"lockfileVersion": 3,
"requires": true,
"packages": {
"": {
"name": "metona-ollama-desktop",
- "version": "0.16.12",
+ "version": "0.16.13",
"license": "MIT",
"dependencies": {
"ffmpeg-static": "^5.2.0",
diff --git a/package.json b/package.json
index 6155c54..9ed4bb7 100644
--- a/package.json
+++ b/package.json
@@ -1,6 +1,6 @@
{
"name": "metona-ollama-desktop",
- "version": "0.16.12",
+ "version": "0.16.13",
"description": "Metona Ollama - TypeScript + Electron 桌面 AI 聊天客户端",
"main": "dist/main/main.js",
"author": "thzxx",
diff --git a/src/main/menu.ts b/src/main/menu.ts
index 58d4f63..d16269c 100644
--- a/src/main/menu.ts
+++ b/src/main/menu.ts
@@ -101,7 +101,7 @@ export function createMenu(): void {
dialog.showMessageBox(mainWindow!, {
type: 'info',
title: '关于 Metona Ollama',
- message: 'Metona Ollama Desktop v0.16.12',
+ message: 'Metona Ollama Desktop v0.16.13',
detail: 'TypeScript + Electron Ollama AI 聊天客户端\n\nhttps://gitee.com/thzxx/metona-ollama',
icon: getIconPath()
});
diff --git a/src/renderer/api/ollama.ts b/src/renderer/api/ollama.ts
index cc200b2..8a2614d 100644
--- a/src/renderer/api/ollama.ts
+++ b/src/renderer/api/ollama.ts
@@ -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);
}
}
diff --git a/src/renderer/components/chat-area.ts b/src/renderer/components/chat-area.ts
index 7eb463e..805ac50 100644
--- a/src/renderer/components/chat-area.ts
+++ b/src/renderer/components/chat-area.ts
@@ -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);
diff --git a/src/renderer/index.html b/src/renderer/index.html
index 6f2677b..9f11767 100644
--- a/src/renderer/index.html
+++ b/src/renderer/index.html
@@ -28,7 +28,7 @@