修改 手机端 显示名称错位的问题
This commit is contained in:
246
index.html
246
index.html
@@ -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;
|
||||
|
||||
Reference in New Issue
Block a user