From e1b1c4ca1fb4935cd7377a4b0626f74b2df9458a Mon Sep 17 00:00:00 2001 From: geyun <1556375442@qq.com> Date: Sun, 16 Nov 2025 17:01:06 +0800 Subject: [PATCH] =?UTF-8?q?AI=E6=A0=B9=E6=8D=AE=E7=94=A8=E6=88=B7=E7=82=B9?= =?UTF-8?q?=E5=87=BB=E6=AC=A1=E6=95=B0=E6=98=BE=E7=A4=BA=E5=BC=B9=E7=AA=97?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- index.html | 264 ++++++++++++++++++++++++++++++++++++++++++++++++++++- server2.js | 22 +++++ 2 files changed, 282 insertions(+), 4 deletions(-) diff --git a/index.html b/index.html index 1bf8a2b..c717f87 100755 --- a/index.html +++ b/index.html @@ -38,13 +38,18 @@ font-size: 15px; opacity: 0; transition: opacity 0.3s ease; - z-index: 9999; + z-index: 9999999999; } .toast.show { opacity: 1; } + .toast.success { + background-color: #09db45; + } + + /* 侧边栏 */ .sidebar { width: 240px; @@ -55,6 +60,7 @@ transition: all 0.3s ease; box-shadow: 2px 0 5px rgba(0, 0, 0, 0.04); z-index: 10; + height: 100%; } .sidebar.collapsed { @@ -172,7 +178,8 @@ flex-direction: column; background: #f9fcff; justify-content: space-between; - width: calc(100% - 240px) + width: calc(100% - 240px); + height: 100%; } .chat-container .content { @@ -520,6 +527,7 @@ /* 手机端适配 */ @media (max-width: 768px) { + .mobilelogo { display: flex; @@ -543,6 +551,7 @@ position: absolute; top: 10px; height: 100%; + left: 0px; } .sidebar.sidebar.collapsed>.toggle-btn { @@ -752,6 +761,105 @@ display: none; } + @@ -910,6 +1018,51 @@ +
+ +
+ + @@ -1127,10 +1280,10 @@ console.error("请求异常:", err); } } - function showToast(message) { + function showToast(message, type = '') { // 创建元素 const toast = document.createElement("div"); - toast.className = "toast"; + toast.className = `toast${type == "success" ? " success" : ""}`; toast.innerText = message; document.body.appendChild(toast); @@ -1242,6 +1395,34 @@ }); setTimeout(scrollToBottom, 0); } + function setCookie(name, value) { + const d = new Date(); + d.setFullYear(d.getFullYear() + 100); // +100 年 + document.cookie = `${name}=${value};expires=${d.toUTCString()};path=/`; + } + function getCookie(name) { + const cookies = document.cookie.split("; "); + for (let c of cookies) { + const [key, val] = c.split("="); + if (key === name) return val; + } + return null; + } + + function showPop(userId) { + if (!userId) { + console.error("userId 缺失,无法记录点击次数"); + return; + } + const cookieName = `popupClickCount_${userId}`; + let clickCount = parseInt(getCookie(cookieName) || "0", 10); + clickCount++; + setCookie(cookieName, clickCount, 7); + console.log(`用户 ${userId} 当前点击次数:`, clickCount); + if (clickCount == 10) { + document.querySelector(".popbgc").classList.remove("none"); + } + } // 内容 角色 图片 创造时间 function addMessage(content = '', role = "assistant", imgUrl = null, time = null) { const msg = document.createElement("div"); @@ -1391,6 +1572,7 @@ const decoder = new TextDecoder("utf-8"); let buffer = ""; msgDiv.classList.remove("thinking"); + showPop(userId); clearInterval(interval); console.log(isStopped, '是否点击停止') @@ -1749,6 +1931,80 @@ } }); + + \ No newline at end of file diff --git a/server2.js b/server2.js index 4ef0a5a..4a663b7 100755 --- a/server2.js +++ b/server2.js @@ -729,6 +729,28 @@ app.post("/stop", express.json(), (req, res) => { console.log(stopFlags,"消息id"); res.json({ ok: true }); }); +app.post('/submit',async (req, res) => { + const { company, scenes, needs, userId } = req.body; + + console.log("收到数据:", company, scenes, needs, userId); + + if (!company || !needs || !userId) { + return res.status(400).json({ message: "缺少必要字段" }); + } + + try { + const sql = + "INSERT INTO pv_form (company, scenes, needs, userId) VALUES (?, ?, ?, ?)"; + + await pool.query(sql, [company, scenes, needs, userId || null]); + + res.json({ code:200,message: "提交成功!" }); + } catch (err) { + console.error("数据库插入失败:", err); + res.status(500).json({ message: "数据库写入失败" }); + } +}); +