From e2f3f6c8d89481aea11ee30d607dadce1945545a Mon Sep 17 00:00:00 2001
From: geyun <1556375442@qq.com>
Date: Fri, 7 Nov 2025 16:47:28 +0800
Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E6=94=B9ai=E8=BE=93=E5=87=BA=E6=8C=89?=
=?UTF-8?q?=E5=AD=97=E8=BE=93=E5=87=BA=E7=9A=84=E6=95=88=E6=9E=9C?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
index.html | 25 ++++++++++++++++++++-----
server2.js | 28 ++++++++++++++++++++--------
2 files changed, 40 insertions(+), 13 deletions(-)
diff --git a/index.html b/index.html
index 3673fa6..93cd323 100755
--- a/index.html
+++ b/index.html
@@ -4,6 +4,9 @@
+
+
+
新能源智能体
@@ -16,6 +19,7 @@
display: flex;
background: #f0f6fb;
color: #333;
+ width: 100%;
}
@@ -165,11 +169,14 @@
flex-direction: column;
background: #f9fcff;
justify-content: space-between;
+ width: calc(100% - 240px)
}
.chat-container .content {
height: 70%;
overflow-y: auto;
+ scrollbar-width: none;
+ /* overflow-y: auto; */
}
.chat-header {
@@ -529,7 +536,7 @@
flex-direction: column;
transition: all 0.3s ease;
box-shadow: 8px 0 60px rgba(0, 0, 0, 0.04);
- z-index: 10;
+ z-index: 1000;
position: absolute;
top: 10px;
height: 100%;
@@ -556,6 +563,7 @@
.chat-messages {
padding-bottom: 125px;
+ /* height: 200px */
/* 留出输入框空间 */
}
@@ -574,6 +582,11 @@
align-items: center;
}
+ .chat-container .content {
+ overflow-y: auto;
+ scrollbar-width: none;
+ }
+
/* 按钮样式 */
.userinfo-toggle {
padding: 7px 2px;
@@ -999,10 +1012,11 @@
q.addEventListener("click", () => {
if (q.classList.contains("mainauestion")) {
// q.style.display = 'none';
- if (!isMobile()) {
- document.querySelector('.fourquestionmain').style.display = 'none';
- document.querySelector('.sidequestion').style.display = 'flex';
- }
+ // if (!isMobile()) {
+ document.querySelector('.fourquestionmain').style.display = 'none';
+ document.querySelector('.sidequestion').style.display = 'flex';
+ document.querySelector('.chat-messages').style.height = '100%';
+ // }
}
isPre = true;
@@ -1343,6 +1357,7 @@
// }
if (obj.content && obj.type !== "title") {
for (const char of obj.content) {
+ await new Promise(r => setTimeout(r, 20)); // 控制字速
aiMsg.content += char;
msgDiv.innerHTML = marked.parse(aiMsg.content);
diff --git a/server2.js b/server2.js
index 8953471..b9debad 100755
--- a/server2.js
+++ b/server2.js
@@ -513,10 +513,16 @@ app.post("/analyze", upload.single("file"), async (req, res) => {
{
const delta = chunk.choices[0]?.delta?.content || "";
sceneText += delta;
- if (delta)
- res.write(
- `data: ${JSON.stringify({ type: "scene", content: delta })}\n\n`
- );
+ // if (delta)
+ // res.write(
+ // `data: ${JSON.stringify({ type: "scene", content: delta })}\n\n`
+ // );
+ if (delta) {
+ for (const ch of delta) {
+ res.write(`data: ${JSON.stringify({ type: "scene", content: ch })}\n\n`);
+ await new Promise(r => setTimeout(r, 0)); // 控制渲染节奏
+ }
+ }
}
console.log("====== 图像分析结束 ======")
@@ -563,10 +569,16 @@ app.post("/analyze", upload.single("file"), async (req, res) => {
const delta = chunk.choices[0]?.delta?.content || "";
llmText += delta;
- if (delta)
- res.write(
- `data: ${JSON.stringify({ type: "llm", content: delta})}\n\n`
- );
+ // if (delta)
+ // res.write(
+ // `data: ${JSON.stringify({ type: "llm", content: delta})}\n\n`
+ // );
+ if (delta) {
+ for (const ch of delta) {
+ res.write(`data: ${JSON.stringify({ type: "llm", content: ch })}\n\n`);
+ await new Promise(r => setTimeout(r, 0)); // 控制渲染节奏
+ }
+ }
}