feat: 完善用户字段管理 + 优化用户列表样式

This commit is contained in:
菜鸟生产 2026-03-18 15:19:04 +08:00
parent 529ddff7a9
commit 796eeb3645
5 changed files with 81 additions and 67 deletions

View File

@ -25,6 +25,7 @@ class User(Base):
bio = Column(Text, nullable=True)
password = Column(String(255), nullable=False)
role = Column(String(50), default="user")
last_login = Column(DateTime(timezone=True), nullable=True) # 最后登录时间
f99_92_created_at = Column(DateTime(timezone=True), server_default=func.now())
f99_93_updated_at = Column(DateTime(timezone=True), onupdate=func.now())

View File

@ -2,7 +2,7 @@
# Version Configuration for Zodiac Collection Management System
# 当前版本号 (语义化版本:主版本。次版本.修订版)
VERSION=1.1.13
VERSION=1.1.15
# 版本代号 (可选)
VERSION_CODENAME="新生"

View File

@ -4,7 +4,7 @@
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=no">
<meta name="apple-mobile-web-app-capable" content="yes">
<title>甲辰收藏 v1.1.12</title>
<title>甲辰收藏 v1.1.14</title>
<!-- Favicon -->
<link rel="icon" type="image/x-icon" href="/static/icons/favicon.ico" />

View File

@ -182,74 +182,71 @@ export default function Admin() {
</button>
</div>
<div style={{ background: 'rgba(30, 41, 59, 0.8)', borderRadius: '12px', overflow: 'hidden' }}>
<table style={{ width: '100%', borderCollapse: 'collapse', color: '#fff' }}>
<thead style={{ background: 'rgba(55, 65, 81, 0.8)' }}>
<tr>
<th style={{ padding: '12px', textAlign: 'left' }}>用户名</th>
<th style={{ padding: '12px', textAlign: 'left' }}>角色</th>
<th style={{ padding: '12px', textAlign: 'left' }}>藏品数</th>
<th style={{ padding: '12px', textAlign: 'left' }}>注册时间</th>
<th style={{ padding: '12px', textAlign: 'center' }}>操作</th>
</tr>
</thead>
<tbody>
{users.map((user, index) => (
<tr key={user.id} style={{ borderTop: '1px solid rgba(255,255,255,0.1)', background: index % 2 === 0 ? 'rgba(30, 41, 59, 0.4)' : 'rgba(30, 41, 59, 0.2)' }}>
<td style={{ padding: '12px', color: '#fbbf24' }}>{user.username}</td>
<td style={{ padding: '12px' }}>
<span style={{
padding: '4px 8px',
borderRadius: '4px',
background: user.role === 'admin' ? 'rgba(16, 185, 129, 0.2)' : 'rgba(148, 163, 184, 0.2)',
{/* 用户列表 - 卡片式布局 */}
<div style={{ display: 'flex', flexDirection: 'column', gap: '12px' }}>
{users.map((user) => (
<div key={user.id} style={{ background: 'rgba(30, 41, 59, 0.8)', borderRadius: '12px', padding: '16px' }}>
<div style={{ display: 'flex', justifyContent: 'space-between', alignItems: 'center' }}>
<div style={{ flex: 1 }}>
<div style={{ display: 'flex', alignItems: 'center', gap: '8px' }}>
<div style={{ color: '#fbbf24', fontSize: '16px', fontWeight: 'bold' }}>{user.username}</div>
<div style={{
padding: '2px 8px', borderRadius: '4px',
background: user.role === 'admin' ? 'rgba(16, 185, 129, 0.2)' : 'rgba(148, 163, 184, 0.2)',
color: user.role === 'admin' ? '#10b981' : '#94a3b8',
fontSize: '12px'
fontSize: '12px'
}}>
{user.role}
</span>
</td>
<td style={{ padding: '12px', color: '#94a3b8' }}>{user.collection_count}</td>
<td style={{ padding: '12px', color: '#94a3b8', fontSize: '12px' }}>
{new Date(user.created_at).toLocaleDateString('zh-CN')}
</td>
<td style={{ padding: '12px', textAlign: 'center' }}>
<div style={{ display: 'flex', gap: '8px', justifyContent: 'center' }}>
<button
onClick={() => setEditingUser({ ...user })}
style={{
padding: '6px 12px',
borderRadius: '6px',
border: 'none',
background: 'rgba(59, 130, 246, 0.2)',
color: '#3b82f6',
cursor: 'pointer',
fontSize: '12px'
}}
>
编辑
</button>
{user.role !== 'admin' && (
<button
onClick={() => handleDeleteUser(user.id, user.username)}
style={{
padding: '6px 12px',
borderRadius: '6px',
border: 'none',
background: 'rgba(239, 68, 68, 0.2)',
color: '#ef4444',
cursor: 'pointer',
fontSize: '12px'
}}
>
删除
</button>
)}
{user.role === 'admin' ? '👑 管理员' : '👤 用户'}
</div>
</td>
</tr>
))}
</tbody>
</table>
</div>
<div style={{ color: '#64748b', fontSize: '13px', marginTop: '4px' }}>
📧 {user.email || '未设置'} | 📱 {user.phone || '未设置'}
</div>
</div>
<div style={{ textAlign: 'right' }}>
<div style={{ color: '#94a3b8', fontSize: '12px' }}>藏品数</div>
<div style={{ color: '#60a5fa', fontSize: '20px', fontWeight: 'bold' }}>{user.collection_count || 0}</div>
</div>
</div>
<div style={{ display: 'flex', justifyContent: 'space-between', alignItems: 'center', marginTop: '12px', paddingTop: '12px', borderTop: '1px solid rgba(255,255,255,0.1)' }}>
<div style={{ color: '#64748b', fontSize: '12px' }}>
注册时间{user.created_at ? new Date(user.created_at).toLocaleDateString('zh-CN') : '-'}
</div>
<div style={{ display: 'flex', gap: '8px' }}>
<button
onClick={() => setEditingUser({ ...user })}
style={{
padding: '6px 12px',
borderRadius: '6px',
border: 'none',
background: 'rgba(59, 130, 246, 0.2)',
color: '#3b82f6',
cursor: 'pointer',
fontSize: '12px'
}}
>
编辑
</button>
{user.role !== 'admin' && (
<button
onClick={() => handleDeleteUser(user.id, user.username)}
style={{
padding: '6px 12px',
borderRadius: '6px',
border: 'none',
background: 'rgba(239, 68, 68, 0.2)',
color: '#ef4444',
cursor: 'pointer',
fontSize: '12px'
}}
>
🗑 删除
</button>
)}
</div>
</div>
</div>
))}
</div>
{users.length === 0 && (

View File

@ -11,6 +11,8 @@ export default function Settings() {
username: '',
email: '',
phone: '',
avatar: '',
address: '',
bio: ''
})
@ -39,6 +41,8 @@ export default function Settings() {
username: data.username || '',
email: data.email || '',
phone: data.phone || '',
avatar: data.avatar || '',
address: data.address || '',
bio: data.bio || ''
})
} else {
@ -55,6 +59,8 @@ export default function Settings() {
username: user.username || '',
email: user.email || '',
phone: user.phone || '',
avatar: user.avatar || '',
address: user.address || '',
bio: user.bio || ''
})
} catch (e2) {
@ -213,6 +219,16 @@ export default function Settings() {
/>
</div>
<div style={{ marginBottom: '16px' }}>
<label style={{ display: 'block', color: '#94a3b8', fontSize: '14px', marginBottom: '8px' }}>地址</label>
<input
type="text"
value={form.address}
onChange={(e) => setForm({ ...form, address: e.target.value })}
style={{ width: '100%', padding: '12px', borderRadius: '8px', border: '1px solid #334155', background: '#0f172a', color: '#fff' }}
/>
</div>
<div style={{ marginBottom: '16px' }}>
<label style={{ display: 'block', color: '#94a3b8', fontSize: '14px', marginBottom: '8px' }}>简介</label>
<textarea