feat: public user profile API + settings swipe navigation

- GET /api/users/profile/:username public endpoint (no auth) for user
  pages, matching upstream main; UserProfile uses it (was admin /users
  search)
- Settings page: vertical scroll-snap panels (profile/security/recovery),
  swipe up/down to switch smoothly; sidebar nav scrolls to panel and
  active highlight follows scroll position
This commit is contained in:
lezi-fun committed 2026-08-11 10:07:30 +08:00
1 parent 93be3a2880
commit aeb8adae4c
4 files changed
+78 -11

No files matched your search

+21
View File
@@ -0,0 +1,21 @@
// GET /api/users/profile/:username — 用户公开信息(无需登录,用于用户主页)
import pool from '@/lib/db';
export async function GET(req, { params }) {
const { username } = await params;
if (!username) {
return Response.json({ error: '缺少用户名' }, { status: 400 });
}
try {
const r = await pool.query(
'SELECT id, username, avatar_url, bio, role, signature, created_at FROM users WHERE username = $1',
[username]
);
if (r.rows.length === 0) {
return Response.json({ error: '用户不存在' }, { status: 404 });
}
return Response.json(r.rows[0]);
} catch {
return Response.json({ error: '服务器错误' }, { status: 500 });
}
}