feat: user signature (设置页编辑 + 帖子底部显示)

- schema: users.signature column (upstream aligned)
- API: posts query JOIN signature, /auth/me returns signature, PUT /users/:id updates signature
- Settings: signature textarea (Markdown hint), saved with profile
- PostDetail: signature shown under post content with divider
- README: remove upstream DB schema note (fixed upstream)
This commit is contained in:
lezi-fun committed 2026-08-10 14:46:05 +08:00
1 parent c8dcf32dd4
commit 694fa2bfaf
6 files changed
+16 -8

No files matched your search

+5
View File
@@ -140,6 +140,11 @@ export default function PostDetail({ postId }) {
))}
</div>
)}
{post.signature && (
<div style={{ marginTop: 16, paddingTop: 12, borderTop: '1px solid var(--border-light)', fontSize: 12, color: 'var(--text-secondary)' }}>
{post.signature}
</div>
)}
</div>
<ReplyList postId={postId} onRefresh={load} />
</div>
+7 -2
View File
@@ -12,6 +12,7 @@ export default function SettingsPage() {
const { currentUser, setCurrentUser } = useApp();
const [username, setUsername] = useState(currentUser?.username || '');
const [bio, setBio] = useState(currentUser?.bio || '');
const [signature, setSignature] = useState(currentUser?.signature || '');
const [avatarUrl, setAvatarUrl] = useState(currentUser?.avatar_url || '');
const [avatarStatus, setAvatarStatus] = useState(null);
const avatarInputRef = useRef(null);
@@ -35,9 +36,9 @@ export default function SettingsPage() {
if (!currentUser) { alert('请先登录'); return; }
if (!username.trim()) { alert('用户名不能为空'); return; }
try {
const data = await API.updateProfile(currentUser.id, username.trim(), bio.trim());
const data = await API.updateProfile(currentUser.id, username.trim(), bio.trim(), signature.trim());
if (data.error) throw new Error(data.error);
setCurrentUser({ ...currentUser, username: username.trim(), bio: bio.trim() });
setCurrentUser({ ...currentUser, username: username.trim(), bio: bio.trim(), signature: signature.trim() });
alert('保存成功!');
} catch (err) {
alert('保存失败:' + err.message);
@@ -82,6 +83,10 @@ export default function SettingsPage() {
<label style={{ fontWeight: 600, fontSize: 14, display: 'block', marginBottom: 4 }}>个人简介</label>
<textarea rows={3} value={bio} style={{ width: '100%', padding: '8px 12px', border: '1px solid var(--border)', borderRadius: 4, fontSize: 14, background: 'var(--bg)', color: 'var(--text)', resize: 'vertical' }} onChange={(e) => setBio(e.target.value)} />
</div>
<div style={{ marginBottom: 16 }}>
<label style={{ fontWeight: 600, fontSize: 14, display: 'block', marginBottom: 4 }}>个性签名 <span style={{ color: 'var(--text-light)', fontWeight: 400 }}>(显示在每篇帖子底部,支持 Markdown)</span></label>
<textarea rows={2} value={signature} placeholder="签名..." style={{ width: '100%', padding: '8px 12px', border: '1px solid var(--border)', borderRadius: 4, fontSize: 14, background: 'var(--bg)', color: 'var(--text)', resize: 'vertical', fontFamily: 'inherit' }} onChange={(e) => setSignature(e.target.value)} />
</div>
<button className="btn-primary" style={{ width: '100%', padding: 10 }} onClick={handleSave}>保存设置</button>
</div>