From 694fa2bfaf36c6c0af500d3838de3f1f3fe660a4 Mon Sep 17 00:00:00 2001 From: lezi-fun <177434121+lezi-fun@users.noreply.github.com> Date: Mon, 10 Aug 2026 14:45:50 +0800 Subject: [PATCH] =?UTF-8?q?feat:=20user=20signature=20(=E8=AE=BE=E7=BD=AE?= =?UTF-8?q?=E9=A1=B5=E7=BC=96=E8=BE=91=20+=20=E5=B8=96=E5=AD=90=E5=BA=95?= =?UTF-8?q?=E9=83=A8=E6=98=BE=E7=A4=BA)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - 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) --- README.md | 2 -- app/api/auth/me/route.js | 2 +- app/api/users/[id]/route.js | 2 +- components/PostDetail.js | 5 +++++ components/SettingsPage.js | 9 +++++++-- lib/api.js | 4 ++-- 6 files changed, 16 insertions(+), 8 deletions(-) diff --git a/README.md b/README.md index 1eafae9..e5f1fa5 100644 --- a/README.md +++ b/README.md @@ -154,8 +154,6 @@ npx @cloudflare/next-on-pages 两个分支使用**完全相同的 `schema.sql`**,共用同一个数据库实例(已验证:main 的 Express 代码与 next 的 Next.js 代码可同时连接同一 PostgreSQL 库,表结构、数据互不冲突)。 -> 注意:上游 main 的 `server.js` 引用了 `is_pinned` / `signature` 等列,但这些列在上游仓库的 `schema.sql` 中缺失(未同步)。本分支的 `schema.sql` 是完整超集,已包含全部列,可直接用于两个分支。 - ## 🏗️ 项目结构 ``` diff --git a/app/api/auth/me/route.js b/app/api/auth/me/route.js index 44c6a72..b948cd3 100644 --- a/app/api/auth/me/route.js +++ b/app/api/auth/me/route.js @@ -9,7 +9,7 @@ export async function GET(req) { } try { const r = await pool.query( - 'SELECT id, username, avatar_url, bio, role, created_at FROM users WHERE id = $1', + 'SELECT id, username, avatar_url, bio, signature, role, created_at FROM users WHERE id = $1', [user.id] ); if (!r.rows[0]) { diff --git a/app/api/users/[id]/route.js b/app/api/users/[id]/route.js index 92897af..826c157 100644 --- a/app/api/users/[id]/route.js +++ b/app/api/users/[id]/route.js @@ -35,7 +35,7 @@ export async function PUT(req, { params }) { return Response.json({ error: '无权限修改他人资料' }, { status: 403 }); } try { - await pool.query('UPDATE users SET username = $1, bio = $2 WHERE id = $3', [username, bio || '', id]); + await pool.query('UPDATE users SET username = $1, bio = $2, signature = $3 WHERE id = $4', [username, bio || '', signature || '', id]); return Response.json({ success: true }); } catch (err) { if (err.code === '23505') { diff --git a/components/PostDetail.js b/components/PostDetail.js index e0644f4..f0fff46 100644 --- a/components/PostDetail.js +++ b/components/PostDetail.js @@ -140,6 +140,11 @@ export default function PostDetail({ postId }) { ))} )} + {post.signature && ( +