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)); // 控制渲染节奏 + } + } }