From 2b84a7adf85509b84fa4a2533b90623e1afd2634 Mon Sep 17 00:00:00 2001 From: JOJO <1498581755@qq.com> Date: Thu, 23 Jul 2026 00:21:49 +0800 Subject: [PATCH] =?UTF-8?q?perf(chat):=20=E5=AF=B9=E8=AF=9D=E5=8C=BA=20vir?= =?UTF-8?q?tua=20=E7=AA=97=E5=8F=A3=E5=8C=96=E6=B8=B2=E6=9F=93=EF=BC=8C?= =?UTF-8?q?=E8=A7=A3=E5=86=B3=E6=8C=A4=E5=8E=8B=E5=8D=A1=E9=A1=BF=E4=B8=8E?= =?UTF-8?q?=E5=85=A8=E9=87=8F=E6=B8=B2=E6=9F=93?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - v-for 全量渲染改为 virtua Virtualizer 窗口化,只挂载可视区+buffer 消息块 - 追底引擎 resize 弹簧动画改 instant:拖拽挤压时逐帧瞬时吸底,内容向上生长 - 消息按对象身份(WeakMap)分配稳定 key,支撑 virtua 逐项高度缓存 - 用户气泡随滚动重挂载时补测量/补观察,保证折叠状态正确恢复 - 滚动追踪日志默认关闭(逐scroll事件日志本身是每帧开销),排障可显式开启 - 修复 2 处依赖 DOM 层级的 CSS 结构选择器 - 新增依赖 virtua(~3kB) --- package-lock.json | 31 ++++ package.json | 1 + static/src/components/chat/ChatArea.vue | 147 +++++++++++------- .../styles/components/chat/_chat-area.scss | 6 +- 4 files changed, 130 insertions(+), 55 deletions(-) diff --git a/package-lock.json b/package-lock.json index bdc6ddec..a537e3bc 100644 --- a/package-lock.json +++ b/package-lock.json @@ -35,6 +35,7 @@ "sherpa-onnx": "^1.13.2", "socket.io-client": "^4.7.5", "unified": "^11.0.5", + "virtua": "^0.49.3", "vue": "^3.4.15", "vue-stick-to-bottom": "^1.0.0", "xterm": "^5.3.0" @@ -7463,6 +7464,36 @@ "url": "https://opencollective.com/unified" } }, + "node_modules/virtua": { + "version": "0.49.3", + "resolved": "https://registry.npmjs.org/virtua/-/virtua-0.49.3.tgz", + "integrity": "sha512-k1Yn988Vz/L40uDtEWPjfdVo15Suumh4tU4/z5Srs0elNcU9DgBskqdh3llpHyAlXrCeHWTfcclYvY1uU4MmIg==", + "license": "MIT", + "peerDependencies": { + "react": ">=16.14.0", + "react-dom": ">=16.14.0", + "solid-js": ">=1.0", + "svelte": ">=5.0", + "vue": ">=3.2" + }, + "peerDependenciesMeta": { + "react": { + "optional": true + }, + "react-dom": { + "optional": true + }, + "solid-js": { + "optional": true + }, + "svelte": { + "optional": true + }, + "vue": { + "optional": true + } + } + }, "node_modules/vite": { "version": "5.4.21", "resolved": "https://registry.npmjs.org/vite/-/vite-5.4.21.tgz", diff --git a/package.json b/package.json index 1361df58..89101463 100644 --- a/package.json +++ b/package.json @@ -42,6 +42,7 @@ "sherpa-onnx": "^1.13.2", "socket.io-client": "^4.7.5", "unified": "^11.0.5", + "virtua": "^0.49.3", "vue": "^3.4.15", "vue-stick-to-bottom": "^1.0.0", "xterm": "^5.3.0" diff --git a/static/src/components/chat/ChatArea.vue b/static/src/components/chat/ChatArea.vue index 1edb7e89..2cd68160 100644 --- a/static/src/components/chat/ChatArea.vue +++ b/static/src/components/chat/ChatArea.vue @@ -5,15 +5,24 @@ ref="scrollRef" >
+ + +
-
+
+ +
@@ -682,6 +682,7 @@