Files
forumlify/components/AdminPage.js
T
lezi-fun 4ee38f6486 feat: align with upstream — pin posts, edit marker, custom CSS, UX fixes
- Pin/unpin posts (PUT /api/posts/:id/pin, admin) with notification to author
- is_pinned/pinned_at in schema; 📌 badge on feed + detail; admin pin button
- Edited marker (已编辑) on feed + detail; edit button + modal for authors
- Custom CSS: upload/delete API + admin tab + global loader (style.css override)
- Fix: duplicate post title on detail page (remove card title, keep header)
- Fix: forum name flicker on load (localStorage cache before fetch)
- Fix: dropdown menu closes on outside click (document listener)
- Fix: document.title + <title> sync on forum rename
2026-08-10 12:32:06 +08:00

55 lines
2.0 KiB
JavaScript

'use client';
// 管理后台:5 个 tab
import { useState } from 'react';
import { Icon } from './Icons';
import AdminReports from './admin/AdminReports';
import AdminUsers from './admin/AdminUsers';
import AdminLogs from './admin/AdminLogs';
import AdminLinks from './admin/AdminLinks';
import AdminForumSettings from './admin/AdminForumSettings';
import AdminCustomPages from './admin/AdminCustomPages';
import AdminCustomCss from './admin/AdminCustomCss';
const TABS = [
{ key: 'reports', label: '举报', icon: 'shieldAlert' },
{ key: 'users', label: '用户', icon: 'users' },
{ key: 'logs', label: '日志', icon: 'file' },
{ key: 'links', label: '友链', icon: 'link' },
{ key: 'custom', label: '自定义页面', icon: 'file' },
{ key: 'css', label: '自定义CSS', icon: 'file' },
{ key: 'settings', label: '论坛设置', icon: 'settings' },
];
export default function AdminPage() {
const [tab, setTab] = useState('reports');
return (
<div className="page-slide active">
<div className="page-header" style={{ maxWidth: 900, margin: '0 auto', width: '100%' }}>
<h2><Icon name="shieldAlert" size={20} /> 管理后台</h2>
</div>
<div className="admin-tabs" style={{ maxWidth: 900, margin: '0 auto', width: '100%' }}>
{TABS.map((t) => (
<button
key={t.key}
className={'admin-tab' + (tab === t.key ? ' active' : '')}
onClick={() => setTab(t.key)}
>
<Icon name={t.icon} size={14} /> {t.label}
</button>
))}
</div>
<div id="adminContent" style={{ maxWidth: 900, margin: '0 auto', width: '100%' }}>
{tab === 'reports' && <AdminReports />}
{tab === 'users' && <AdminUsers />}
{tab === 'logs' && <AdminLogs />}
{tab === 'links' && <AdminLinks />}
{tab === 'custom' && <AdminCustomPages />}
{tab === 'css' && <AdminCustomCss />}
{tab === 'settings' && <AdminForumSettings />}
</div>
</div>
);
}