修改 手机端 显示名称错位的问题

This commit is contained in:
2025-09-24 13:41:35 +08:00
parent 590f5fdeb5
commit 9229444a2d
7 changed files with 690 additions and 48 deletions

View File

@@ -173,7 +173,7 @@
.chat-header {
height: 50px;
padding: 1px 20px;
padding-left: 22px;
padding-left: 56px;
background: #fff;
border-bottom: 1px solid #e3eaf2;
font-size: 16px;
@@ -181,7 +181,35 @@
color: #0057ff;
box-shadow: 0 1px 3px rgba(0, 0, 0, 0.04);
display: flex;
justify-content: flex-start;
justify-content: space-between;
}
.chat-header .userinfo {
display: flex;
justify-content: center;
align-items: center;
gap: 5px;
color: #666;
font-weight: 400;
font-family: fangsong;
}
.chat-header .userinfo .logout {
color: #666;
font-weight: 400;
font-family: fangsong;
/* text-decoration: underline; */
cursor: pointer
}
.price {
text-decoration: none;
}
.price:hover,
.logout:hover {
color: #999 !important;
}
.chat-header .back {
@@ -472,6 +500,10 @@
display: none;
}
.userinfo-wrapper {
display: none;
}
/* 手机端适配 */
@media (max-width: 768px) {
@@ -484,7 +516,25 @@
}
.sidebar {
display: none;
/* position: absolute;
top: 10px; */
/* display: none; */
width: 240px;
background: #ffffff;
border-right: 1px solid #e3eaf2;
display: flex;
flex-direction: column;
transition: all 0.3s ease;
box-shadow: 8px 0 60px rgba(0, 0, 0, 0.04);
z-index: 10;
position: absolute;
top: 10px;
height: 100%;
}
.sidebar.sidebar.collapsed>.toggle-btn {
position: fixed;
right: 10px !important;
}
.chat-container {
@@ -514,8 +564,83 @@
}
.userinfo-wrapper {
position: relative;
display: flex;
justify-content: center;
align-items: center;
}
/* 按钮样式 */
.userinfo-toggle {
padding: 10px 16px;
border-radius: 50px;
border: none;
background: #0057ff;
color: #fff;
font-weight: 500;
cursor: pointer;
box-shadow: 0 4px 6px rgba(0, 0, 0, 0.2);
transition: background 0.3s;
max-width: 70px;
overflow-x: hidden;
}
.userinfo-toggle:hover {
background: #0057ff;
}
/* 折叠面板 */
.userinfo-panel {
position: absolute;
top: 50px;
right: 0;
width: 100px;
background: #fff;
border-radius: 12px;
padding: 15px 20px;
box-shadow: 0 8px 20px rgba(0, 0, 0, 0.15);
display: flex;
flex-direction: column;
gap: 12px;
opacity: 0;
transform: translateY(-10px);
pointer-events: none;
transition: all 0.3s ease;
z-index: 1000;
}
/* 展开状态 */
.userinfo-panel.show {
opacity: 1;
transform: translateY(0);
pointer-events: auto;
}
/* 面板内部元素 */
.userinfo-panel span,
.userinfo-panel a {
padding: 8px 12px;
border-radius: 8px;
text-decoration: none;
color: #333;
background: #f1f1f1;
text-align: center;
transition: background 0.2s;
}
.userinfo-panel span:hover,
.userinfo-panel a:hover {
background: #e0e0e0;
}
.userinfo {
display: none !important;
}
}
.fourquestion {
display: flex;
flex-direction: row;
@@ -538,7 +663,8 @@
}
.fourquestion .question {
width: 350px;
box-sizing: border-box;
width: 300px;
display: flex;
justify-content: center;
align-items: center;
@@ -649,11 +775,26 @@
display: flex;
justify-content: flex-start;
align-items: center;
width: 100%;
">
<img src="./img/logo.png" class="mobilelogo" alt="">
新能源智能体<span style="font-size:14px">(sataBotAgent)</span>
</div>
<div class="userinfo">
<span class="username"></span>
<span class="logout" onClick="logout()">退出</span>
<a class="logout price" href="./modal.html">服务价格</a>
</div>
<div class="userinfo-wrapper">
<!-- 初始按钮 -->
<button class="userinfo-toggle username" onclick="toggleUserInfo()">用户</button>
<!-- 折叠面板 -->
<div class="userinfo-panel">
<!-- <span class="username">用户名</span> -->
<span class="logout" onclick="logout()">退出</span>
<a class="logout price" href="./modal.html">服务价格</a>
</div>
</div>
</div>
<div class="content">
@@ -762,6 +903,8 @@
// ✅ 先 URL 解码,再 Base64 解码,再 UTF-8 解码
const userId = decodeURIComponent(Number(escape(atob(encodedUserId))));
setCookie("userId", userId);
getUserName(userId);
// const userId = encodedUserId;
let sendParam = {
imageBase64: '',
@@ -769,7 +912,41 @@
sessionId: '',
userPrompt: ''
}
if (isMobile()) {
toggleSidebar();
}
const questions = document.querySelectorAll(".question");
// 获取到用户名称
function getUserName(userId) {
try {
fetch("http://1.95.137.212:30009/user", {
method: "POST",
headers: {
"Content-Type": "application/json"
},
body: JSON.stringify({
userId,
})
}).then(res => res.json()).then(data => {
if (data.code === 0) {
document.querySelectorAll('.username').forEach((e) => {
e.textContent = data.userName;
})
console.log("成功找到该用户:", data.userName, data.userId);
} else {
console.error("未找到该用户:",);
}
})
} catch (err) {
console.error("请求异常:", err);
}
}
questions.forEach(q => {
@@ -808,11 +985,20 @@
}
// getHistory();
function setCookie(name, value, days = 7) {
const d = new Date();
d.setTime(d.getTime() + days * 24 * 60 * 60 * 1000);
const expires = "expires=" + d.toUTCString();
document.cookie = `${name}=${encodeURIComponent(value)}; ${expires}; path=/`;
}
function getCookie(name) {
const match = document.cookie.match(new RegExp('(^| )' + name + '=([^;]+)'));
if (match) return decodeURIComponent(match[2]);
return null;
}
function deleteCookie(name) {
document.cookie = `${name}=; expires=Thu, 01 Jan 1970 00:00:00 UTC; path=/;`;
}
function handleBack() {
RPJavaFragmentInterface.navigateTo("StatusFragment");
@@ -825,6 +1011,10 @@
const random = Math.floor(Math.random() * 1e6).toString().padStart(6, "0");
return timestamp + random; // 一共 16 位
}
function logout() {
deleteCookie('userId');
window.location.href = 'http://ri.satabot.com/#/login?goRemote=1&clear=1';
}
function createSession(userId, sessionId) {
try {
@@ -840,6 +1030,7 @@
})
}).then(res => res.json()).then(data => {
if (data.code === 0) {
hasImage = false;
console.log("会话创建成功:", data.message);
} else {
console.error("创建失败:", data.error);
@@ -872,9 +1063,9 @@
}
function toggleSidebar() {
sidebar.classList.toggle("collapsed");
}
// function toggleSidebar() {
// sidebar.classList.toggle("collapsed");
// }
function scrollToBottom() {
const chatMessages = document.getElementById("chatMessages");
setTimeout(() => {
@@ -882,6 +1073,24 @@
chatMessages.bottom = '0px';
}, 0);
}
const panel = document.querySelector('.userinfo-panel');
const toggleButton = document.querySelector('.userinfo-toggle');
function toggleUserInfo() {
panel.classList.toggle('show');
}
document.addEventListener('click', (e) => {
if (!toggleButton.contains(e.target) && !panel.contains(e.target)) {
panel.classList.remove('show');
}
});
// 阻止点击面板本身关闭
panel.addEventListener('click', (e) => {
e.stopPropagation();
});
function renderChatList(isNew) {
@@ -1260,13 +1469,12 @@
function isWeChat() {
return /MicroMessenger/i.test(navigator.userAgent);
}
function getCookie(name) {
console.log(document.cookie, 8777222)
const value = `; ${document.cookie}`;
const parts = value.split(`; ${name}=`);
if (parts.length === 2) return parts.pop().split(';').shift();
return null;
}
// function getCookie(name) {
// const value = `; ${document.cookie}`;
// const parts = value.split(`; ${name}=`);
// if (parts.length === 2) return parts.pop().split(';').shift();
// return null;
// }
// gotoWeiXin();
function gotoWeiXin() {
console.log(isWeChat(), 8888, navigator.userAgent);
@@ -1291,8 +1499,14 @@
// }else{
// }
if (getCookie("userId")) {
getSessionList();
} else {
deleteCookie('userId');
window.location.href = 'http://ri.satabot.com/#/login?goRemote=1&clear=1';
}
getSessionList();
function getSessionList() {
sendParam.userId = userId;

433
modal.html Normal file
View File

@@ -0,0 +1,433 @@
<!DOCTYPE html>
<html lang="zh-CN">
<head>
<meta charset="utf-8" />
<meta name="viewport" content="width=device-width,initial-scale=1" />
<title>购买服务 - 价格表</title>
<style>
:root {
--bg: #0b1220;
--panel: #0f1a2a;
--cell: #141b2a;
--cell-odd: #0f1624;
--muted: #98a6c0;
--accent: #FF7A2D;
/* 橙色 CTA(你之前用的主色) */
--accent-2: #8C7AFF;
/* 紫色标题 */
--highlight: #39C5FF;
/* 副标题蓝 */
--green: #35d07c;
}
body {
margin: 0;
font-family: "PingFang SC", "Helvetica Neue", Arial, "Microsoft YaHei", sans-serif;
background: var(--bg);
color: #fff;
-webkit-font-smoothing: antialiased;
-moz-osx-font-smoothing: grayscale;
}
.wrap {
max-width: 1200px;
margin: 40px auto;
padding: 24px;
}
.title {
text-align: center;
margin-bottom: 22px;
}
.title h2 {
font-size: 30px;
margin: 0 0 8px;
font-weight: 700;
}
.title p {
margin: 0;
color: var(--highlight);
font-size: 16px;
}
/* 表格容器 */
.pricing-panel {
background: #1e293b;
border-radius: 12px;
padding: 0;
overflow: hidden;
box-shadow: 0 6px 30px rgba(4, 8, 20, 0.6);
}
/* 使用 CSS Grid 来布局:左侧宽列 + 4 列等分 */
.pricing-table {
display: grid;
grid-template-columns: 340px repeat(4, 1fr);
grid-auto-rows: auto;
gap: 0;
align-items: stretch;
}
/* 顶部行:切换 + 每列标题(名称 + 价格) */
.cell {
padding: 22px 20px;
border-left: 1px solid rgba(255, 255, 255, 0.08);
border-bottom: 1px solid rgba(255, 255, 255, 0.02);
background: var(--panel);
}
.cell-left-label {
font-size: 13px;
color: var(--muted);
font-weight: 500;
}
/* 左侧第一格为切换 */
.toggle-cell {
background: #1e293b;
display: flex;
align-items: center;
gap: 12px;
}
.toggle-cell .left-label {
font-size: 14px;
color: var(--muted);
min-width: 50px;
}
/* 开关样式 */
/*.switch {
--w:46px;
--h:24px;
position:relative;
width:var(--w);
height:var(--h);
background:rgba(255,255,255,0.06);
border-radius:999px;
display:inline-block;
vertical-align:middle;
box-shadow: inset 0 1px 0 rgba(255,255,255,0.02);
}
/*.switch input{
display:none;
}
.switch .knob{
position:absolute;
top:2px;
left:2px;
width:20px;
height:20px;
border-radius:50%;
background:#fff;
transform:translateX(0);
transition:all .22s ease;
box-shadow:0 2px 6px rgba(0,0,0,0.5);
}
.switch input:checked + .knob{
transform:translateX(22px);
}
.toggle-cell .year-note{
color:var(--green);
font-size:13px;
}
*/
/* 各 plan 的 header 区域 */
.plan-header {
text-align: center;
background: linear-gradient(180deg, rgba(255, 255, 255, 0.01), rgba(0, 0, 0, 0.03));
display: flex;
flex-direction: column;
justify-content: center;
}
.plan-name {
color: var(--accent-2);
font-weight: 700;
font-size: 18px;
letter-spacing: 0.6px;
text-transform: none;
margin-bottom: 6px;
}
.plan-price {
font-weight: 700;
font-size: 22px;
color: #fff;
}
.plan-price .per {
font-size: 13px;
color: var(--muted);
margin-left: 6px;
font-weight: 500;
}
/* 第二行左侧:USAGE 标题列 */
.usage-cell {
padding: 18px 20px;
background: linear-gradient(180deg, rgba(12, 20, 34, 0.35), rgba(6, 12, 20, 0.2));
display: flex;
flex-direction: column;
gap: 8px;
}
.usage-title {
color: var(--muted);
font-size: 12px;
text-transform: uppercase;
letter-spacing: 1px;
font-weight: 700;
}
.usage-item {
font-size: 14px;
color: #cbd8ef;
}
/* usage 数值列 */
.usage-value {
padding: 18px 20px;
text-align: center;
color: #fff;
font-weight: 600;
font-size: 18px;
background: linear-gradient(180deg, rgba(5, 10, 20, 0.25), rgba(3, 6, 12, 0.12));
}
.cell usage-value-item {
padding: 18px 20px;
text-align: left;
/* 左对齐 */
color: #cbd8ef;
font-weight: 600;
font-size: 15px;
}
/* 去掉第一个单元格左边框 */
.pricing-table>*:first-child {
border-left: none;
}
/* 分隔线视觉调整:在 desktop 显得整齐 */
.pricing-table>.cell+.cell {
/* border-left already handles column separation */
}
/* 右侧列的竖直对齐:保证 header 与 usage 对齐 */
.pricing-table>.plan-header {
min-height: 60px;
display: flex;
align-items: center;
justify-content: center;
flex-direction: column;
}
.faq-section {
margin-top: 40px;
padding: 24px;
background: var(--panel);
/* 用和表格一致的底色 */
border-radius: 12px;
box-shadow: 0 4px 20px rgba(0, 0, 0, 0.4);
}
.faq-title {
font-size: 22px;
margin-bottom: 20px;
color: var(--accent-2);
/* 保持和表格标题统一 */
font-weight: 700;
text-align: center;
}
.faq-item {
margin-bottom: 18px;
}
.faq-item h3 {
font-size: 15px;
color: #fff;
/* 标题直接白色,更简洁 */
margin: 0 0 6px;
font-weight: 600;
}
.faq-item p {
font-size: 14px;
color: var(--muted);
/* 统一淡灰蓝色 */
margin: 0;
line-height: 1.6;
}
.header-colorful-text {
display: inline-block;
/* 必须,保证背景图片显示 */
font-size: 22px;
font-weight: bold;
-webkit-text-fill-color: transparent;
/* Chrome/Safari */
-webkit-background-clip: text;
/* Chrome/Safari */
background-clip: text;
/* Firefox 支持 */
background-size: cover;
background-repeat: no-repeat;
padding: 10px 0 20px 0;
;
}
/* 先给表格四列添加细微分色(可按需移除) */
/* 响应式:窄屏改为纵向堆叠 */
@media (max-width:980px) {
.pricing-table {
display: flex;
flex-direction: column;
/* 改成纵向堆叠 */
}
.pricing-panel {
overflow-x: hidden;
/* 禁止横向滚动 */
}
.cell {
border-left: none !important;
border-bottom: 1px solid rgba(255, 255, 255, 0.08);
}
.plan-header {
flex-direction: row;
justify-content: space-between;
padding: 14px 18px;
flex-wrap: wrap;
}
.usage-cell {
flex-direction: row;
justify-content: space-between;
padding: 12px 18px;
flex-wrap: wrap;
}
.usage-value {
text-align: center;
padding: 12px 18px;
font-size: clamp(13px, 4vw, 18px);
}
}
</style>
</head>
<body>
<div class="wrap">
<div class="title">
<h2>购买服务</h2>
<span class="header-colorful-text"
style="background-image: url('https://jsmaibu.com/upload/images/2025/9/756389b8bc935a9d.jpg');">
灵活,有竞争力的定价和持续增值的服务
</span>
</div>
<div class="pricing-panel" role="table" aria-label="价格表">
<div class="pricing-table">
<!-- 第一行:切换 -->
<div class="cell toggle-cell" style="grid-row:1; grid-column:1;">
<div style="display:flex;align-items:center;gap:12px;">
<span class="left-label">月付</span>
<!-- <label class="switch" title="切换计费周期">
<input type="checkbox" id="billingToggle" aria-label="切换年付/月付">
<span class="knob"></span>
</label>
<span class="left-label" style="opacity:0.95">年付</span>
<div class="year-note">(省 2 个月)</div>
-->
</div>
</div>
<!-- 四列 plan header(第一行) -->
<div class="cell plan-header" style="grid-row:1; grid-column:2;">
<div class="plan-name">Free</div>
<div class="plan-price"><span class="price">¥0</span><span class="per">/月</span></div>
</div>
<div class="cell plan-header" style="grid-row:1; grid-column:3;">
<div class="plan-name">Basic</div>
<div class="plan-price"><span class="price">¥19</span><span class="per">/月</span></div>
</div>
<div class="cell plan-header" style="grid-row:1; grid-column:4;">
<div class="plan-name">Standard</div>
<div class="plan-price"><span class="price">¥59</span><span class="per">/月</span></div>
</div>
<div class="cell plan-header" style="grid-row:1; grid-column:5;">
<div class="plan-name">Pro</div>
<div class="plan-price"><span class="price">¥129</span><span class="per">/月</span></div>
</div>
<div class="cell usage-title-row" style="grid-row:2; grid-column:1 / 6;font-size: 10px;">USAGE
</div>
<!-- 第三行:USAGE 左侧 + 各列 usage -->
<div class="cell usage-value-item"
style="grid-row:3; grid-column:1;background:linear-gradient(180deg, rgba(5,10,20,0.25), rgba(3,6,12,0.12));font-size:14px;">
星点数</div>
<div class="cell usage-value" style="grid-row:3; grid-column:2;">—</div>
<div class="cell usage-value" style="grid-row:3; grid-column:3;">8,000 <span
class="cell-left-label">/月</span></div>
<div class="cell usage-value" style="grid-row:3; grid-column:4;">30,000 <span
class="cell-left-label">/月</span></div>
<div class="cell usage-value" style="grid-row:3; grid-column:5;">75,000 <span
class="cell-left-label">/月</span></div>
</div><!-- /.pricing-table -->
</div><!-- /.pricing-panel -->
<div class="faq-section">
<h2 class="faq-title">常见问题</h2>
<div class="faq-item">
<h3>SataBot Agent是什么?</h3>
<p>SataBot Agent 是一款由人工智能驱动的光伏场景AI应用程序。SataBot Agent AI 能力基于飒沓自研大模型的 AIGC 服务构建。</p>
</div>
<div class="faq-item">
<h3>SataBot Agent 是免费的吗?</h3>
<p>当您注册 SataBot Agent 时,将会免费获得 10 次问答。如果您希望长期使用,请考虑购买我们的服务。</p>
</div>
<div class="faq-item">
<h3>什么是星点?</h3>
<p>星点(Star Points)是 SataBot Agent 内部用于计量您所拥有的 AIGC 服务资源的货币单位。每月 Basic 套餐包含 8000 星点,Standard 套餐包含
30000 星点,Pro 套餐包含 75000 星点,Premium 套餐包含 120000 星点。本月未消耗完星点会过期,下个月套餐生效时自动恢复。</p>
</div>
<div class="faq-item">
<h3>星点消耗是如何计算的?</h3>
<p>根据使用的 AIGC 服务,产生不同的星点消耗。当使用大语言模型问答时,将根据您的提问和模型的回答文本长度计算星点消耗。</p>
</div>
</div>
</div><!-- /.wrap -->
<!-- 可选:简单 JS 让开关切换时改变价格文本(演示用途) -->
</body>
</html>

16
node_modules/.bin/mkdirp generated vendored
View File

@@ -1,16 +0,0 @@
#!/bin/sh
basedir=$(dirname "$(echo "$0" | sed -e 's,\\,/,g')")
case `uname` in
*CYGWIN*|*MINGW*|*MSYS*)
if command -v cygpath > /dev/null 2>&1; then
basedir=`cygpath -w "$basedir"`
fi
;;
esac
if [ -x "$basedir/node" ]; then
exec "$basedir/node" "$basedir/../mkdirp/bin/cmd.js" "$@"
else
exec node "$basedir/../mkdirp/bin/cmd.js" "$@"
fi

1
node_modules/.bin/mkdirp generated vendored Symbolic link
View File

@@ -0,0 +1 @@
../mkdirp/bin/cmd.js

16
node_modules/.bin/openai generated vendored
View File

@@ -1,16 +0,0 @@
#!/bin/sh
basedir=$(dirname "$(echo "$0" | sed -e 's,\\,/,g')")
case `uname` in
*CYGWIN*|*MINGW*|*MSYS*)
if command -v cygpath > /dev/null 2>&1; then
basedir=`cygpath -w "$basedir"`
fi
;;
esac
if [ -x "$basedir/node" ]; then
exec "$basedir/node" "$basedir/../openai/bin/cli" "$@"
else
exec node "$basedir/../openai/bin/cli" "$@"
fi

1
node_modules/.bin/openai generated vendored Symbolic link
View File

@@ -0,0 +1 @@
../openai/bin/cli

0
node_modules/mkdirp/bin/cmd.js generated vendored Normal file → Executable file
View File

0
node_modules/openai/bin/cli generated vendored Normal file → Executable file
View File

View File

@@ -99,6 +99,31 @@ app.get("/test-db", async (req, res) => {
res.send("FAIL");
}
});
app.post("/user", async (req, res) => {
try {
const { userId } = req.body; // 从请求体里拿到 user_id
if (!userId) {
return res.status(400).send("缺少 user_id");
}
// 查询 user_name
const [rows] = await pool.query(
"SELECT user_name FROM sys_user WHERE user_id = ?",
[userId]
);
if (rows.length === 0) {
return res.status(404).send("未找到该用户");
}
res.json({ code:0,userId, userName: rows[0].user_name });
} catch (err) {
console.error(err);
res.status(500).send("服务器错误");
}
});
// 查询用户所有会话列表
app.get("/sessions", async (req, res) => {