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:
1 parent
f0867935ac
commit
d757bde780
5 files changed
+17
-4
No files matched your search
@@ -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 });
|
||||
}
|
||||
|
||||
@@ -2855,6 +2855,9 @@ a.btn-secondary {
|
||||
.settings-nav-item.active {
|
||||
border-left-color: transparent;
|
||||
border-bottom-color: var(--primary);
|
||||
/* 手机端选中 tab:仅左上/右上圆角(桌面端保持直角不变) */
|
||||
border-top-left-radius: 8px;
|
||||
border-top-right-radius: 8px;
|
||||
}
|
||||
|
||||
.settings-content {
|
||||
|
||||
Reference in new issue
Block a user