优化生成标题

This commit is contained in:
2025-11-24 21:40:06 +08:00
parent 7296b7881e
commit a3cb65306a
2 changed files with 76 additions and 42 deletions

View File

@@ -1558,6 +1558,14 @@
});
});
}
function isMobile() {
// 获取UA字符串
const userAgent = navigator.userAgent;
// 匹配主流手机相关关键词,忽略大小写
const mobileRegex = /iPhone|Android|BlackBerry|IEMobile|Opera Mini|RedMi|Huawei|Vivo/i;
// 返回匹配结果
return mobileRegex.test(userAgent);
}
function bindToLogin() {
document.querySelector('.popbox .loading-box').classList.remove('none');
const data = {
@@ -1937,7 +1945,7 @@
panel.classList.remove('show');
}
const chatbox = document.querySelector(".chat-input");
if (!sidebar.contains(e.target) && !chatbox.contains(e.target)) {
if (!sidebar.contains(e.target) && !chatbox.contains(e.target)&& isMobile()) {
if (!sidebar.classList.contains("collapsed")) {
sidebar.classList.add("collapsed");
toggleBtn.style.left = "10px"; // 收起后
@@ -2191,7 +2199,7 @@ function smartRender(msgDiv, text) {
}).catch(err => {
console.log("✅ 流被中断:", err.name);
clearInterval(interval);
// controller.abort();
controller.abort();
controller = null;
@@ -2282,7 +2290,7 @@ function smartRender(msgDiv, text) {
// }
if (obj.content && obj.type !== "title") {
for (const char of obj.content) {
await new Promise(r => setTimeout(r, 2)); // 控制字速
await new Promise(r => setTimeout(r, 5)); // 控制字速
if (isStopped) return;
aiMsg.content += char;
smartRender(msgDiv, aiMsg.content);
@@ -2459,7 +2467,7 @@ function smartRender(msgDiv, text) {
const deleteSession = (sessionId, userId) => {
if (activeChatId == sessionId) {
if (controller) {
// controller.abort();
controller.abort();
controller = null;
if (sendBtnImg.classList.contains('none')) {
sendBtnImg.classList.remove('none');
@@ -2736,7 +2744,7 @@ function smartRender(msgDiv, text) {
}
if (controller) {
// controller.abort();
controller.abort();
controller = null;
if (sendBtnImg.classList.contains('none')) {
sendBtnImg.classList.remove('none');