微信头像显示

This commit is contained in:
2026-01-16 12:31:54 +08:00
parent b3d03c1871
commit 8f4ba999d8
2 changed files with 30 additions and 20 deletions

View File

@@ -1648,18 +1648,18 @@
// ✅ 先 URL 解码,再 Base64 解码,再 UTF-8 解码
let userId;
if (params.get("nickname")) {
console.log(1)
if (params.get("nickname") || getcookie("nickname")) {
console.log(getcookie("headingimg"), 888888, document.cookie, params.get("nickname"))
document.querySelectorAll('.logout1').forEach(el => {
el.style.display = 'none';
});
console.log(3)
document.querySelectorAll('.username').forEach((e) => {
e.textContent = params.get("nickname");
e.textContent = params.get("nickname") || getcookie("nickname");
})
document.querySelector(".userinfo-wrapper img").src = params.get("headingimg");
document.querySelector(".userinfo-wrapper img").src = getcookie("headimgurl") || params.get("headingimg");
userId = decodeURIComponent(Number(escape(atob(encodedUserId))));
console.log(4)
@@ -1839,7 +1839,7 @@
const questions = document.querySelectorAll(".question");
// 获取到用户名称
function getUserName(userId) {
if (params.get("nickname")) return;
if (params.get("nickname") || getcookie("nickname")) return;
try {
fetch("https://serviceai.satabot.com/user", {
method: "POST",
@@ -1913,6 +1913,13 @@
const expires = "expires=" + d.toUTCString();
document.cookie = `${name}=${encodeURIComponent(value)}; ${expires}; path=/`;
}
function getcookie(name, cookieStr = document.cookie) {
const match = cookieStr.match(
new RegExp('(?:^|; )' + name.replace(/([.$?*|{}()[\]\\/+^])/g, '\\$1') + '=([^;]*)')
);
return match ? decodeURIComponent(match[1]) : null;
}
function getCookie(name) {
const match = document.cookie.match(new RegExp('(^| )' + name + '=([^;]+)'));
if (match) return decodeURIComponent(match[2]);
@@ -2115,14 +2122,6 @@
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) {