feat: super admin badge — earliest admin shows 超级管理员 in user list

- /api/users: mark is_super for the earliest-registered admin (matches
  the auto-promotion migration semantics)
- AdminUsers: render 超级管理员 badge for is_super, 管理员 otherwise
- i18n keys admin.user.roleSuper (zh/en)
- Mobile settings nav: active tab gets top-left/top-right rounded
  corners only (desktop unchanged)
This commit is contained in:
lezi-fun committed 2026-08-11 20:40:02 +08:00
1 parent f0867935ac
commit d757bde780
5 files changed
+17 -4

No files matched your search

+9 -1
View File
@@ -11,6 +11,12 @@ export async function GET(req) {
const username = url.searchParams.get('username');
try {
// 超级管理员 = 最早注册的 admin(对齐迁移:无 admin 时自动提升最早注册用户)
const superR = await pool.query(
`SELECT id FROM users WHERE role = 'admin' ORDER BY created_at ASC, id ASC LIMIT 1`
);
const superAdminId = superR.rows[0]?.id || null;
let query = 'SELECT id, username, avatar_url, bio, role, created_at FROM users';
const params = [];
if (username) {
@@ -19,7 +25,9 @@ export async function GET(req) {
}
query += ' ORDER BY created_at DESC';
const r = await pool.query(query, params);
return Response.json(r.rows);
// 标记超级管理员(前端显示"超级管理员")
const rows = r.rows.map((u) => ({ ...u, is_super: u.id === superAdminId }));
return Response.json(rows);
} catch {
return Response.json({ error: '服务器错误' }, { status: 500 });
}