Add transfer tracking and secure admin access
This commit is contained in:
+33
-7
@@ -1,9 +1,11 @@
|
||||
<script setup lang="ts">
|
||||
import { ref, watch } from 'vue'
|
||||
import { computed, ref, watch } from 'vue'
|
||||
import { useRouter, useRoute } from 'vue-router'
|
||||
import { adminAuth } from './auth'
|
||||
import { DashboardOutlined, SettingOutlined, ControlOutlined, SmileOutlined,
|
||||
GithubOutlined, PictureOutlined, TeamOutlined, AppstoreOutlined,
|
||||
NotificationOutlined } from '@ant-design/icons-vue'
|
||||
NotificationOutlined, SafetyCertificateOutlined, AuditOutlined,
|
||||
LogoutOutlined } from '@ant-design/icons-vue'
|
||||
|
||||
const router = useRouter()
|
||||
const route = useRoute()
|
||||
@@ -12,7 +14,7 @@ const selectedKeys = ref<string[]>([String(route.name)])
|
||||
|
||||
watch(() => route.name, (n) => { selectedKeys.value = [String(n)] })
|
||||
|
||||
const nav = [
|
||||
const nav = computed(() => [
|
||||
{ key: 'Dashboard', icon: DashboardOutlined, label: '仪表盘' },
|
||||
{ key: 'Settings', icon: ControlOutlined, label: '系统设置' },
|
||||
{ key: 'Configs', icon: SettingOutlined, label: '品牌配置' },
|
||||
@@ -22,11 +24,25 @@ const nav = [
|
||||
{ key: 'Stickers', icon: PictureOutlined, label: '表情包库' },
|
||||
{ key: 'Users', icon: TeamOutlined, label: '用户管理' },
|
||||
{ key: 'PushCampaigns', icon: NotificationOutlined, label: '推送管理' },
|
||||
]
|
||||
...(adminAuth.identity.value?.role === 'super_admin' ? [
|
||||
{ key: 'AdminAccounts', icon: SafetyCertificateOutlined, label: '管理员账号' },
|
||||
{ key: 'Audit', icon: AuditOutlined, label: '操作审计' },
|
||||
] : []),
|
||||
])
|
||||
|
||||
watch(adminAuth.identity, value => {
|
||||
if (!value && !route.meta.public) router.replace('/login')
|
||||
})
|
||||
|
||||
async function logout() {
|
||||
await adminAuth.logout()
|
||||
await router.replace('/login')
|
||||
}
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<a-layout style="min-height: 100vh">
|
||||
<router-view v-if="route.meta.public || route.name === 'ChangePassword'" />
|
||||
<a-layout v-else style="min-height: 100vh">
|
||||
<a-layout-sider v-model:collapsed="collapsed" collapsible theme="light" :width="200"
|
||||
style="border-right: 1px solid #f0f0f0">
|
||||
<div style="padding: 18px 20px; font-size: 16px; font-weight: 700; white-space: nowrap; overflow: hidden;">
|
||||
@@ -39,10 +55,20 @@ const nav = [
|
||||
<span>{{ n.label }}</span>
|
||||
</a-menu-item>
|
||||
</a-menu>
|
||||
<div style="position:absolute;bottom:16px;left:20px;font-size:11px;color:#bbb">v20260726-0130</div>
|
||||
<div style="position:absolute;bottom:16px;left:16px;right:16px">
|
||||
<a-button type="text" block style="text-align:left" @click="logout">
|
||||
<template #icon><LogoutOutlined /></template>退出登录
|
||||
</a-button>
|
||||
</div>
|
||||
</a-layout-sider>
|
||||
<a-layout>
|
||||
<a-layout-content style="margin: 18px 20px; padding: 20px; background: #fff; border-radius: 10px; min-height: 360px;">
|
||||
<a-layout-header style="height:52px;padding:0 20px;background:#fff;border-bottom:1px solid #f0f0f0;display:flex;align-items:center;justify-content:flex-end">
|
||||
<a-space>
|
||||
<span>{{ adminAuth.identity.value?.username }}</span>
|
||||
<a-tag>{{ adminAuth.identity.value?.role }}</a-tag>
|
||||
</a-space>
|
||||
</a-layout-header>
|
||||
<a-layout-content style="margin: 18px 20px; padding: 20px; background: #fff; border-radius: 8px; min-height: 360px;">
|
||||
<router-view />
|
||||
</a-layout-content>
|
||||
</a-layout>
|
||||
|
||||
Reference in New Issue
Block a user