From 780726a4e37b446f53e2b477065eefeaea8c1382 Mon Sep 17 00:00:00 2001
From: saopig1 <4x7sw862st@gmail.com>
Date: Wed, 27 May 2026 15:38:42 +0800
Subject: [PATCH] feat(web): role-aware UI (badge, selector, toggle button,
hide admin-only sections for members)
---
web/src/components/Navbar.vue | 10 +++++
web/src/composables/useSession.ts | 2 +
web/src/views/Settings.vue | 75 +++++++++++++++++++++++++++----
3 files changed, 78 insertions(+), 9 deletions(-)
diff --git a/web/src/components/Navbar.vue b/web/src/components/Navbar.vue
index 789e865..1024b3f 100644
--- a/web/src/components/Navbar.vue
+++ b/web/src/components/Navbar.vue
@@ -91,6 +91,9 @@
{{ session.currentUser.value.username }}
+
+ {{ session.currentUser.value.role === 'admin' ? '管理员' : '成员' }}
+
@@ -670,4 +673,11 @@ onUnmounted(() => {
border-radius: var(--radius-sm);
&:hover { background: var(--bg-secondary); color: var(--text-primary); }
}
+
+.nav-user-role {
+ font-size: 11px; padding: 2px 6px; border-radius: 4px;
+ font-weight: 500;
+}
+.role-admin { background: rgba(99, 145, 226, 0.18); color: #6391e2; }
+.role-member { background: rgba(150, 150, 150, 0.18); color: var(--text-secondary); }
diff --git a/web/src/composables/useSession.ts b/web/src/composables/useSession.ts
index 97ec892..b64e680 100644
--- a/web/src/composables/useSession.ts
+++ b/web/src/composables/useSession.ts
@@ -3,6 +3,7 @@ import { ref, computed, readonly } from "vue";
interface User {
id: string;
username: string;
+ role: 'admin' | 'member';
}
const currentUser = ref
(null);
@@ -75,6 +76,7 @@ export function useSession() {
currentUser: readonly(currentUser),
needsSetup: readonly(needsSetup),
isAuthenticated: computed(() => currentUser.value !== null),
+ isAdmin: computed(() => currentUser.value?.role === 'admin'),
ready: readonly(ready),
refresh,
login,
diff --git a/web/src/views/Settings.vue b/web/src/views/Settings.vue
index 032497e..ada351e 100755
--- a/web/src/views/Settings.vue
+++ b/web/src/views/Settings.vue
@@ -460,13 +460,16 @@
-
+
用户管理
{{ u.username }}
+
+ {{ u.role === 'admin' ? '管理员' : '成员' }}
+
本人
创建于 {{ formatDate(u.createdAt) }}
@@ -475,10 +478,19 @@
+