From 1513686ed5bfb6e152ecc7a814beea63baedcf7d Mon Sep 17 00:00:00 2001 From: Furrium Network Date: Sun, 9 Aug 2026 12:41:51 +0800 Subject: [PATCH] Update index.html --- index.html | 64 ++++++++++++++++++++++++++++++++++++++++++++++++++---- 1 file changed, 60 insertions(+), 4 deletions(-) diff --git a/index.html b/index.html index 3a4da3b..ab3f13b 100644 --- a/index.html +++ b/index.html @@ -156,6 +156,10 @@ 友链 +
加载中...
@@ -546,7 +550,6 @@ // ============================================================ function renderNav() { - document.getElementById('forumName').textContent = CONFIG.FORUM_NAME || 'Forumlify'; const authBtns = document.getElementById('authButtons'); const userDropdown = document.getElementById('userDropdown'); if (currentUser) { @@ -561,6 +564,17 @@ } } + // 新增:加载论坛名称 + async function loadForumName() { + try { + const data = await apiFetch('/settings'); + const name = data.forum_name || CONFIG.FORUM_NAME || 'Forumlify'; + document.getElementById('forumName').textContent = name; + } catch (e) { + document.getElementById('forumName').textContent = CONFIG.FORUM_NAME || 'Forumlify'; + } + } + function renderFeed() { const container = document.getElementById('postList'); container.innerHTML = '
加载中...
'; @@ -1055,6 +1069,46 @@ }); } + // ============================================================ + // 论坛设置渲染(新增) + // ============================================================ + function renderAdminSettings() { + const container = document.getElementById('adminContent'); + container.innerHTML = ` +

⚙️ 论坛设置

+
+ + + + +
+ `; + + // 加载当前设置 + apiFetch('/settings').then(data => { + document.getElementById('settingsForumName').value = data.forum_name || 'Forumlify'; + }).catch(() => {}); + + // 保存 + document.getElementById('settingsForumSave').addEventListener('click', async () => { + const name = document.getElementById('settingsForumName').value.trim(); + if (!name) { alert('请输入论坛名称'); return; } + try { + await apiFetch('/settings', { + method: 'PUT', + body: JSON.stringify({ forum_name: name }) + }); + document.getElementById('settingsResult').textContent = '✅ 保存成功!'; + document.getElementById('settingsResult').style.color = '#22c55e'; + // 更新导航栏 + document.getElementById('forumName').textContent = name; + } catch (err) { + document.getElementById('settingsResult').textContent = '❌ 保存失败'; + document.getElementById('settingsResult').style.color = '#ef4444'; + } + }); + } + // ============================================================ // 🔄 页面切换 // ============================================================ @@ -1143,6 +1197,8 @@ } } renderNav(); + // 加载论坛名称 + await loadForumName(); renderStats(); renderLinks(); @@ -1393,7 +1449,8 @@ reports: renderAdminReports, users: renderAdminUsers, logs: renderAdminLogs, - links: renderAdminLinks + links: renderAdminLinks, + settings: renderAdminSettings }; if (tabMap[this.dataset.tab]) tabMap[this.dataset.tab](); }); @@ -1406,7 +1463,6 @@ const bio = document.getElementById('settingsBio').value.trim(); if (!username) { alert('用户名不能为空'); return; } try { - // 使用更新用户信息接口 const data = await apiFetch('/users/' + currentUser.id, { method: 'PUT', body: JSON.stringify({ username, bio }) @@ -1445,4 +1501,4 @@ document.addEventListener('DOMContentLoaded', init); - \ No newline at end of file +