fix: restore original Feather icons across UI

- Add components/Icons.js with SVG paths extracted verbatim from the original index.html (14 unique icons)
- Restore icons on navbar menu, sidebar, feed actions, post/reply, modals, admin tabs and settings
- Replaces emoji placeholders from the initial migration
This commit is contained in:
lezi-fun committed 2026-08-09 18:12:46 +08:00
1 parent 3e9d004fb6
commit 70a198ae32
14 files changed
+160 -35

No files matched your search

+8 -7
View File
@@ -2,6 +2,7 @@
// 管理后台: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';
@@ -9,11 +10,11 @@ import AdminLinks from './admin/AdminLinks';
import AdminForumSettings from './admin/AdminForumSettings';
const TABS = [
{ key: 'reports', label: '举报' },
{ key: 'users', label: '用户' },
{ key: 'logs', label: '日志' },
{ key: 'links', label: '友链' },
{ key: 'settings', label: '论坛设置' },
{ key: 'reports', label: '举报', icon: 'shieldAlert' },
{ key: 'users', label: '用户', icon: 'users' },
{ key: 'logs', label: '日志', icon: 'file' },
{ key: 'links', label: '友链', icon: 'link' },
{ key: 'settings', label: '论坛设置', icon: 'settings' },
];
export default function AdminPage() {
@@ -22,7 +23,7 @@ export default function AdminPage() {
return (
<div className="page-slide active">
<div className="page-header" style={{ maxWidth: 900, margin: '0 auto', width: '100%' }}>
<h2>管理后台</h2>
<h2><Icon name="shieldAlert" size={20} /> 管理后台</h2>
</div>
<div className="admin-tabs" style={{ maxWidth: 900, margin: '0 auto', width: '100%' }}>
{TABS.map((t) => (
@@ -31,7 +32,7 @@ export default function AdminPage() {
className={'admin-tab' + (tab === t.key ? ' active' : '')}
onClick={() => setTab(t.key)}
>
{t.label}
<Icon name={t.icon} size={14} /> {t.label}
</button>
))}
</div>
+12 -5
View File
@@ -4,6 +4,7 @@
import { useEffect, useState, useCallback } from 'react';
import { API } from '@/lib/api';
import { useApp } from './AppProvider';
import { Icon } from './Icons';
function avatar(username) {
return 'https://ui-avatars.com/api/?name=' + encodeURIComponent(username || '匿名用户') +
@@ -12,7 +13,7 @@ function avatar(username) {
export default function Feed({ onOpenModal, onReport }) {
const { currentUser, sort, setSort, openPost, navigate, refreshKey } = useApp();
const [posts, setPosts] = useState(null); // null = loading
const [posts, setPosts] = useState(null);
const [error, setError] = useState(null);
const load = useCallback(async () => {
@@ -53,7 +54,7 @@ export default function Feed({ onOpenModal, onReport }) {
navigate('new');
}}
>
发布新帖
<Icon name="plus" /> 发布新帖
</button>
</div>
<div id="postList">
@@ -82,17 +83,23 @@ export default function Feed({ onOpenModal, onReport }) {
</div>
)}
<div className="post-actions">
<span>💬 {p.reply_count || 0}</span>
<span>
<Icon name="message" size={14} /> {p.reply_count || 0}
</span>
<button className="action-report" onClick={(e) => {
e.stopPropagation();
if (!currentUser) { alert('请先登录'); return; }
onReport(p.id);
}}>举报</button>
}}>
<Icon name="flag" size={14} /> 举报
</button>
{currentUser && currentUser.id === p.user_id && (
<button className="action-delete" onClick={(e) => {
e.stopPropagation();
handleDelete(p.id);
}}>删除</button>
}}>
<Icon name="trash" size={14} /> 删除
</button>
)}
</div>
</div>
+85
View File
@@ -0,0 +1,85 @@
'use client';
// 图标库 — SVG 内容逐字符提取自旧版 index.html (Feather Icons),与原版一致
const S = {
xmlns: 'http://www.w3.org/2000/svg', width: 16, height: 16, viewBox: '0 0 24 24',
fill: 'none', stroke: 'currentColor', strokeWidth: 2, strokeLinecap: 'round', strokeLinejoin: 'round',
style: { display: 'inline', verticalAlign: 'middle' },
};
export function Icon({ name, size = 16, ...rest }) {
return <svg {...S} width={size} height={size} {...rest}>{PATHS[name] || null}</svg>;
}
const PATHS = {
message: (
<>
<path d="M21 15a2 2 0 0 1-2 2H7l-4 4V5a2 2 0 0 1 2-2h14a2 2 0 0 1 2 2z"/>
</>
),
settings: (
<>
<path d="M12.22 2h-.44a2 2 0 0 0-2 2v.18a2 2 0 0 1-1 1.73l-.43.25a2 2 0 0 1-2 0l-.15-.08a2 2 0 0 0-2.73.73l-.22.38a2 2 0 0 0 .73 2.73l.15.1a2 2 0 0 1 1 1.72v.51a2 2 0 0 1-1 1.74l-.15.09a2 2 0 0 0-.73 2.73l.22.38a2 2 0 0 0 2.73.73l.15-.08a2 2 0 0 1 2 0l.43.25a2 2 0 0 1 1 1.73V20a2 2 0 0 0 2 2h.44a2 2 0 0 0 2-2v-.18a2 2 0 0 1 1-1.73l.43-.25a2 2 0 0 1 2 0l.15.08a2 2 0 0 0 2.73-.73l.22-.39a2 2 0 0 0-.73-2.73l-.15-.08a2 2 0 0 1-1-1.74v-.5a2 2 0 0 1 1-1.74l.15-.09a2 2 0 0 0 .73-2.73l-.22-.38a2 2 0 0 0-2.73-.73l-.15.08a2 2 0 0 1-2 0l-.43-.25a2 2 0 0 1-1-1.73V4a2 2 0 0 0-2-2z"/><circle cx="12" cy="12" r="3"/>
</>
),
shieldAlert: (
<>
<path d="M12 22s8-4 8-10V5l-8-3-8 3v7c0 6 8 10 8 10z"/><path d="M12 8v4"/><path d="M12 16h.01"/>
</>
),
moon: (
<>
<path d="M21 12.79A9 9 0 1 1 11.21 3 7 7 0 0 0 21 12.79z"/>
</>
),
logout: (
<>
<path d="M9 21H5a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2h4"/><polyline points="16 17 21 12 16 7"/><line x1="21" y1="12" x2="9" y2="12"/>
</>
),
book: (
<>
<path d="M21 12V7H5a2 2 0 0 1 0-4h14v4"/><path d="M3 5v14a2 2 0 0 0 2 2h16v-5"/><line x1="18" y1="12" x2="18" y2="12"/>
</>
),
link: (
<>
<path d="M10 13a5 5 0 0 0 7.54.54l3-3a5 5 0 0 0-7.07-7.07l-1.72 1.71"/><path d="M14 11a5 5 0 0 0-7.54-.54l-3 3a5 5 0 0 0 7.07 7.07l1.71-1.71"/>
</>
),
plus: (
<>
<line x1="12" y1="5" x2="12" y2="19"/><line x1="5" y1="12" x2="19" y2="12"/>
</>
),
shield: (
<>
<path d="M12 22s8-4 8-10V5l-8-3-8 3v7c0 6 8 10 8 10z"/>
</>
),
users: (
<>
<path d="M17 21v-2a4 4 0 0 0-4-4H5a4 4 0 0 0-4 4v2"/><circle cx="9" cy="7" r="4"/><path d="M23 21v-2a4 4 0 0 0-3-3.87"/><path d="M16 3.13a4 4 0 0 1 0 7.75"/>
</>
),
file: (
<>
<path d="M14 2H6a2 2 0 0 0-2 2v16a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V8z"/><polyline points="14 2 14 8 20 8"/><line x1="16" y1="13" x2="8" y2="13"/><line x1="16" y1="17" x2="8" y2="17"/><polyline points="10 9 9 9 8 9"/>
</>
),
plus2: (
<>
<path d="M12 5v14"/><path d="M5 12h14"/>
</>
),
close: (
<>
<line x1="18" y1="6" x2="6" y2="18"/><line x1="6" y1="6" x2="18" y2="18"/>
</>
),
trash: (
<>
<polyline points="3 6 5 6 21 6"/><path d="M19 6v14a2 2 0 0 1-2 2H7a2 2 0 0 1-2-2V6m3 0V4a2 2 0 0 1 2-2h4a2 2 0 0 1 2 2v2"/>
</>
),
};
+5 -4
View File
@@ -4,6 +4,7 @@
import { useState, useEffect } from 'react';
import { API, generateCaptcha } from '@/lib/api';
import { useApp } from './AppProvider';
import { Icon } from './Icons';
export default function Modals({ modal, onClose, reportPostId }) {
const { login, register, currentUser, refresh } = useApp();
@@ -87,7 +88,7 @@ export default function Modals({ modal, onClose, reportPostId }) {
{modal === 'login' && (
<div className="modal active" onClick={close}>
<div className="modal-content">
<span className="close" onClick={onClose}>✕</span>
<span className="close" onClick={onClose}><Icon name="close" size={20} /></span>
<h2 style={{ marginBottom: 16 }}>登录</h2>
<input type="email" placeholder="邮箱" value={loginEmail} onChange={(e) => setLoginEmail(e.target.value)} />
<input type="password" placeholder="密码" value={loginPassword} onChange={(e) => setLoginPassword(e.target.value)}
@@ -100,7 +101,7 @@ export default function Modals({ modal, onClose, reportPostId }) {
{modal === 'register' && (
<div className="modal active" onClick={close}>
<div className="modal-content">
<span className="close" onClick={onClose}>✕</span>
<span className="close" onClick={onClose}><Icon name="close" size={20} /></span>
<h2 style={{ marginBottom: 16 }}>注册</h2>
<input type="text" placeholder="用户名" value={regUsername} onChange={(e) => setRegUsername(e.target.value)} />
<input type="email" placeholder="邮箱" value={regEmail} onChange={(e) => setRegEmail(e.target.value)} />
@@ -119,8 +120,8 @@ export default function Modals({ modal, onClose, reportPostId }) {
{modal === 'report' && currentUser && (
<div className="modal active" onClick={close}>
<div className="modal-content">
<span className="close" onClick={onClose}>✕</span>
<h2 style={{ marginBottom: 16 }}>举报帖子</h2>
<span className="close" onClick={onClose}><Icon name="close" size={20} /></span>
<h2 style={{ marginBottom: 16 }}><Icon name="shieldAlert" size={20} /> 举报帖子</h2>
<p style={{ fontSize: 14, color: '#64748b', marginBottom: 12 }}>请选择举报原因:</p>
<select
style={{ width: '100%', padding: '8px 12px', border: '1px solid #e2e8f0', borderRadius: 4, marginBottom: 16 }}
+13 -6
View File
@@ -3,9 +3,10 @@
// 导航栏:论坛名、登录/注册按钮、用户下拉菜单、主题切换
import { useState } from 'react';
import { useApp } from './AppProvider';
import { Icon } from './Icons';
export default function Navbar({ onOpenModal }) {
const { currentUser, forumName, theme, toggleTheme, navigate, logout, setCurrentUser } = useApp();
const { currentUser, forumName, theme, toggleTheme, navigate, logout } = useApp();
const [menuOpen, setMenuOpen] = useState(false);
const avatarSrc = currentUser?.avatar_url ||
@@ -45,10 +46,16 @@ export default function Navbar({ onOpenModal }) {
/>
{menuOpen && (
<div className="dropdown-menu show" onClick={(e) => e.stopPropagation()}>
<a href="#" onClick={(e) => { e.preventDefault(); goPage('messages'); }}>消息</a>
<a href="#" onClick={(e) => { e.preventDefault(); goPage('settings'); }}>设置</a>
<a href="#" onClick={(e) => { e.preventDefault(); goPage('messages'); }}>
<Icon name="message" /> 消息
</a>
<a href="#" onClick={(e) => { e.preventDefault(); goPage('settings'); }}>
<Icon name="settings" /> 设置
</a>
{currentUser.role === 'admin' && (
<a href="#" onClick={(e) => { e.preventDefault(); goPage('admin'); }}>管理后台</a>
<a href="#" onClick={(e) => { e.preventDefault(); goPage('admin'); }}>
<Icon name="shieldAlert" /> 管理后台
</a>
)}
<hr />
<a
@@ -59,7 +66,7 @@ export default function Navbar({ onOpenModal }) {
setMenuOpen(false);
}}
>
{theme === 'dark' ? '☀️ 亮色模式' : '🌙 暗色模式'}
<Icon name={theme === 'dark' ? 'sun' : 'moon'} /> {theme === 'dark' ? '亮色模式' : '暗色模式'}
</a>
<hr />
<a
@@ -72,7 +79,7 @@ export default function Navbar({ onOpenModal }) {
}
}}
>
退出
<Icon name="logout" /> 退出
</a>
</div>
)}
+2 -1
View File
@@ -4,6 +4,7 @@
import { useState, useEffect } from 'react';
import { API, generateCaptcha, uploadImage } from '@/lib/api';
import { useApp } from './AppProvider';
import { Icon } from './Icons';
export default function NewPost() {
const { currentUser, navigate, refresh } = useApp();
@@ -67,7 +68,7 @@ export default function NewPost() {
return (
<div className="page-slide active">
<div className="page-header" style={{ maxWidth: 600, margin: '0 auto', width: '100%' }}>
<h2>发布新帖</h2>
<h2><Icon name="plus" size={20} /> 发布新帖</h2>
</div>
<div style={{ maxWidth: 600, margin: '0 auto', width: '100%' }}>
<input
+4 -1
View File
@@ -5,6 +5,7 @@ import { useEffect, useState, useCallback } from 'react';
import { API } from '@/lib/api';
import { useApp } from './AppProvider';
import ReplyList from './ReplyList';
import { Icon } from './Icons';
function avatar(username) {
return 'https://ui-avatars.com/api/?name=' + encodeURIComponent(username || '匿名用户') +
@@ -65,7 +66,9 @@ export default function PostDetail({ postId }) {
<span className="post-username">{post.username || '匿名用户'}</span>
<span className="post-time">{time}</span>
{canDelete && (
<button className="btn-sm btn-danger" onClick={handleDelete}>删除</button>
<button className="btn-sm btn-danger" onClick={handleDelete}>
<Icon name="trash" size={14} /> 删除
</button>
)}
</div>
<div className="post-title" style={{ fontSize: 20, fontWeight: 700, margin: '8px 0 12px' }}>
+8 -3
View File
@@ -4,6 +4,7 @@
import { useEffect, useState, useCallback } from 'react';
import { API, generateCaptcha } from '@/lib/api';
import { useApp } from './AppProvider';
import { Icon } from './Icons';
function avatar(username) {
return 'https://ui-avatars.com/api/?name=' + encodeURIComponent(username || '匿名用户') +
@@ -61,7 +62,9 @@ export default function ReplyList({ postId, onRefresh }) {
return (
<>
<div style={{ marginTop: 20, fontSize: 14, color: '#64748b' }}>💬 {replies.length} 条回复</div>
<div style={{ marginTop: 20, fontSize: 14, color: '#64748b' }}>
<Icon name="message" size={14} /> {replies.length} 条回复
</div>
<div style={{ marginTop: 12 }}>
{replies.length === 0 ? (
<div style={{ color: '#94a3b8', padding: '20px 0', textAlign: 'center' }}>还没有回复,快来抢沙发吧 🛋️</div>
@@ -75,7 +78,9 @@ export default function ReplyList({ postId, onRefresh }) {
<span className="reply-username">{r.username || '匿名用户'}</span>
<span className="reply-time">{rTime}</span>
{currentUser && currentUser.id === r.user_id && (
<button className="btn-sm btn-danger reply-delete-btn" onClick={() => handleDelete(r.id)}>删除</button>
<button className="btn-sm btn-danger reply-delete-btn" onClick={() => handleDelete(r.id)}>
<Icon name="trash" size={12} /> 删除
</button>
)}
</div>
<div className="reply-content">
@@ -88,7 +93,7 @@ export default function ReplyList({ postId, onRefresh }) {
</div>
<div id="replyArea" style={{ marginTop: 24, borderTop: '1px solid #e2e8f0', paddingTop: 20 }}>
<h3 style={{ fontSize: 16, marginBottom: 12 }}>发表回复</h3>
<h3 style={{ fontSize: 16, marginBottom: 12 }}><Icon name="message" size={16} /> 发表回复</h3>
<textarea
rows={3}
placeholder="写下你的回复..."
+2 -1
View File
@@ -4,6 +4,7 @@
import { useState } from 'react';
import { API } from '@/lib/api';
import { useApp } from './AppProvider';
import { Icon } from './Icons';
export default function SettingsPage() {
const { currentUser, setCurrentUser } = useApp();
@@ -26,7 +27,7 @@ export default function SettingsPage() {
return (
<div className="page-slide active">
<div className="page-header" style={{ maxWidth: 400, margin: '0 auto', width: '100%' }}>
<h2>设置</h2>
<h2><Icon name="settings" size={20} /> 设置</h2>
</div>
<div style={{ maxWidth: 400, margin: '0 auto', width: '100%' }}>
<label style={{ fontWeight: 600, fontSize: 14 }}>用户名</label>
+7 -2
View File
@@ -3,6 +3,7 @@
// 侧边栏:社区统计 + 友情链接
import { useEffect, useState } from 'react';
import { API } from '@/lib/api';
import { Icon } from './Icons';
export default function Sidebar() {
const [stats, setStats] = useState({ posts: 0, users: 0, topics: 0, online: 0 });
@@ -16,14 +17,18 @@ export default function Sidebar() {
return (
<aside id="sidebar">
<div className="stats-box">
<h4>社区统计</h4>
<h4>
<Icon name="book" size={14} /> 社区统计
</h4>
<div className="stat-item"><span>主题</span><span>{stats.topics || 0}</span></div>
<div className="stat-item"><span>帖子</span><span>{stats.posts || 0}</span></div>
<div className="stat-item"><span>用户</span><span>{stats.users || 0}</span></div>
<div className="stat-item"><span>在线</span><span>{stats.online || 0}</span></div>
</div>
<div className="links-box">
<h4>友情链接</h4>
<h4>
<Icon name="link" size={14} /> 友情链接
</h4>
<ul id="friendlyLinks">
{links.length === 0 ? (
<li style={{ color: '#94a3b8', fontSize: 13 }}>暂无链接</li>
+2 -1
View File
@@ -4,6 +4,7 @@
import { useEffect, useState } from 'react';
import { API } from '@/lib/api';
import { useApp } from '../AppProvider';
import { Icon } from '../Icons';
export default function AdminForumSettings() {
const { updateForumName } = useApp();
@@ -29,7 +30,7 @@ export default function AdminForumSettings() {
return (
<>
<h3 style={{ marginBottom: 16 }}>⚙️ 论坛设置</h3>
<h3 style={{ marginBottom: 16 }}><Icon name="settings" size={16} /> 论坛设置</h3>
<div style={{ maxWidth: 400 }}>
<label style={{ fontWeight: 600, fontSize: 14, display: 'block', marginBottom: 6 }}>论坛名称</label>
<input
+4 -1
View File
@@ -3,6 +3,7 @@
// 管理后台 - 友情链接管理
import { useEffect, useState } from 'react';
import { API } from '@/lib/api';
import { Icon } from '../Icons';
export default function AdminLinks() {
const [links, setLinks] = useState([]);
@@ -56,7 +57,9 @@ export default function AdminLinks() {
links.map((l) => (
<div key={l.id} style={{ display: 'flex', justifyContent: 'space-between', alignItems: 'center', padding: '8px 0', borderBottom: '1px solid #f1f5f9' }}>
<span><a href={l.url} target="_blank" rel="noreferrer" style={{ color: '#6366f1', textDecoration: 'none' }}>{l.title}</a></span>
<button className="btn-sm btn-danger" onClick={() => handleDelete(l.id)}>删除</button>
<button className="btn-sm btn-danger" onClick={() => handleDelete(l.id)}>
<Icon name="trash" size={12} /> 删除
</button>
</div>
))
)}
+7 -2
View File
@@ -3,6 +3,7 @@
// 管理后台 - 举报处理
import { useEffect, useState } from 'react';
import { API } from '@/lib/api';
import { Icon } from '../Icons';
const STATUS = { pending: '⏳ 待处理', approved: '✅ 已删除', rejected: '❌ 已驳回' };
@@ -53,8 +54,12 @@ export default function AdminReports() {
)}
{r.status === 'pending' && (
<div className="report-actions">
<button className="btn-sm btn-danger" onClick={() => handleAction(r, 'approve')}>删除帖子</button>
<button className="btn-sm btn-secondary" onClick={() => handleAction(r, 'reject')}>驳回举报</button>
<button className="btn-sm btn-danger" onClick={() => handleAction(r, 'approve')}>
<Icon name="trash" size={12} /> 删除帖子
</button>
<button className="btn-sm btn-secondary" onClick={() => handleAction(r, 'reject')}>
<Icon name="close" size={12} /> 驳回举报
</button>
</div>
)}
</div>