modified app chat forum theme

This commit is contained in:
2026-02-27 14:48:37 +08:00
parent 3449f01500
commit 7976f11cf4
3 changed files with 70 additions and 6 deletions

View File

@@ -838,12 +838,19 @@ async function showProfile(uid) {
const p = d.profile;
let badges = p.badges.map(b => `<span class="inline-flex items-center gap-1 px-2 py-1 bg-slate-50 rounded-lg text-xs" title="${b.desc}">${b.icon} ${b.name}</span>`).join('');
let posts = p.recent_posts.map(pp => `<div class="text-sm py-1.5 border-b border-slate-50 cursor-pointer hover:text-primary" onclick="document.getElementById('profile-modal').classList.add('hidden');openPost(${pp.id})">${esc(pp.title)}</div>`).join('');
let friendBtn = '';
if (CU && CU.id !== parseInt(uid)) {
friendBtn = `<button id="addFriendBtn" onclick="forumAddFriend(${uid},this)" class="px-3 py-1.5 text-xs bg-primary text-white rounded-lg hover:bg-blue-600 transition-colors">加好友</button>`;
}
document.getElementById('profile-content').innerHTML = `
<div class="flex items-center gap-4 mb-5">
<div class="w-16 h-16 bg-primary/10 rounded-full flex items-center justify-center text-primary text-2xl font-bold">${esc(p.name.charAt(0))}</div>
<div><div class="flex items-center gap-2"><span class="text-xl font-bold">${esc(p.name)}</span><span class="level-badge level-${p.level}">Lv.${p.level} ${p.level_title}</span></div>
<div class="text-sm text-slate-500 mt-1">${p.points} 积分</div></div>
<button onclick="document.getElementById('profile-modal').classList.add('hidden')" class="ml-auto text-slate-400 hover:text-slate-600 text-xl">✕</button>
<div class="ml-auto flex items-center gap-2">
${friendBtn}
<button onclick="document.getElementById('profile-modal').classList.add('hidden')" class="text-slate-400 hover:text-slate-600 text-xl">✕</button>
</div>
</div>
<div class="grid grid-cols-3 gap-3 mb-5">
<div class="text-center p-3 bg-blue-50 rounded-lg"><div class="text-xl font-bold text-blue-600">${p.posts_count}</div><div class="text-xs text-slate-500">帖子</div></div>
@@ -854,6 +861,21 @@ async function showProfile(uid) {
${posts?`<div><div class="text-sm font-bold text-slate-700 mb-2">📝 最近帖子</div>${posts}</div>`:''}`;
}
async function forumAddFriend(userId, btn) {
try {
const res = await fetch('/api/friend/add', {method:'POST', headers:{'Content-Type':'application/json'}, body: JSON.stringify({friend_id: userId})});
const data = await res.json();
if (data.success) {
btn.textContent = '已发送';
btn.disabled = true;
btn.classList.replace('bg-primary', 'bg-slate-400');
btn.classList.remove('hover:bg-blue-600');
} else {
alert(data.message || '操作失败');
}
} catch(e) { alert('操作失败'); }
}
// ===== 侧边栏 =====
async function loadSidebar() {
// 热门帖子