feat: 后台管理员独立账号体系,Casdoor 配置改为后台管理
- 新增 admin_users/admin_sessions 表与 adminAuth 工具(scrypt 密码 + 独立会话 Cookie) - /admin/init 初始化首个管理员,未初始化时服务端/客户端双守卫引导 - 后台鉴权改为管理员会话,前台 Casdoor 用户一律普通用户、与后台解耦 - Casdoor 配置改存 settings 表并由「统一认证」页管理,移除全部 CASDOOR 环境变量 - 侧边栏增加统一认证/管理员入口与登出;LoginModal 感知 SSO 启用状态 - 补充 adminAuth 测试,重写 casdoor 测试,全部 23 项通过
This commit is contained in:
+3
-16
@@ -21,8 +21,6 @@ const apiError = useApiError()
|
||||
|
||||
useSeoMeta({ title: () => t('account.title') })
|
||||
|
||||
const isAdmin = computed(() => userStore.user?.role === 'admin')
|
||||
|
||||
const formatDate = (raw?: string, monthOnly = false) => {
|
||||
if (!raw) return ''
|
||||
const d = new Date(String(raw).replace(' ', 'T') + 'Z')
|
||||
@@ -157,12 +155,9 @@ onBeforeUnmount(() => ctx?.revert())
|
||||
<div class="flex-1 min-w-0">
|
||||
<div class="flex items-center gap-3 flex-wrap">
|
||||
<h1 class="text-3xl md:text-4xl font-bold tracking-tight text-black">{{ userStore.user?.username }}</h1>
|
||||
<span
|
||||
class="inline-flex items-center gap-1 px-2.5 py-0.5 rounded-full text-xs font-semibold"
|
||||
:class="isAdmin ? 'bg-black text-white' : 'bg-gray-100 text-gray-600'"
|
||||
>
|
||||
<Icon :name="isAdmin ? 'ph:shield-check' : 'ph:user'" class="w-3 h-3" />
|
||||
{{ isAdmin ? t('account.roleAdmin') : t('account.roleUser') }}
|
||||
<span class="inline-flex items-center gap-1 px-2.5 py-0.5 rounded-full text-xs font-semibold bg-gray-100 text-gray-600">
|
||||
<Icon name="ph:user" class="w-3 h-3" />
|
||||
{{ t('account.roleUser') }}
|
||||
</span>
|
||||
</div>
|
||||
<p class="mt-2 text-gray-500">{{ userStore.user?.email }}</p>
|
||||
@@ -170,14 +165,6 @@ onBeforeUnmount(() => ctx?.revert())
|
||||
{{ t('account.joinedAt') }} · {{ formatDate(userStore.user?.createdAt) }}
|
||||
</p>
|
||||
</div>
|
||||
<NuxtLink
|
||||
v-if="isAdmin"
|
||||
to="/admin"
|
||||
class="inline-flex items-center gap-1.5 text-sm font-semibold text-black underline underline-offset-4 hover:text-gray-500 transition-colors flex-shrink-0"
|
||||
>
|
||||
{{ t('account.adminEntry') }}
|
||||
<Icon name="ph:arrow-right" class="w-4 h-4" />
|
||||
</NuxtLink>
|
||||
</div>
|
||||
|
||||
<!-- 统计(细分隔线) -->
|
||||
|
||||
Reference in New Issue
Block a user