diff --git a/frontend/src/layout/AppAdminLayout.vue b/frontend/src/layout/AppAdminLayout.vue new file mode 100644 index 0000000..5ab42e5 --- /dev/null +++ b/frontend/src/layout/AppAdminLayout.vue @@ -0,0 +1,87 @@ + + + diff --git a/frontend/src/layout/AppAdminMenu.vue b/frontend/src/layout/AppAdminMenu.vue new file mode 100644 index 0000000..4876376 --- /dev/null +++ b/frontend/src/layout/AppAdminMenu.vue @@ -0,0 +1,88 @@ + + + + + diff --git a/frontend/src/layout/AppAdminSidebar.vue b/frontend/src/layout/AppAdminSidebar.vue new file mode 100644 index 0000000..14468dc --- /dev/null +++ b/frontend/src/layout/AppAdminSidebar.vue @@ -0,0 +1,11 @@ + + + + + diff --git a/frontend/src/layout/AppMenu.vue b/frontend/src/layout/AppMenu.vue index 8238a0e..cbd6cd7 100644 --- a/frontend/src/layout/AppMenu.vue +++ b/frontend/src/layout/AppMenu.vue @@ -67,15 +67,10 @@ const adminModel = ref({ label: '系统设置', items: [ { - label: '实例管理', - icon: 'pi pi-fw pi-desktop text-lime-500', + label: '管理后台', + icon: 'pi pi-fw pi-sliders-h text-yellow-500', to: '/admin/instances' }, - { - label: '用户管理', - icon: 'pi pi-fw pi-users text-indigo-500', - to: '/admin/users' - }, ] }) @@ -83,25 +78,10 @@ const superAdminModel = ref({ label: '系统设置', items: [ { - label: '节点管理', - icon: 'pi pi-fw pi-server text-yellow-400', + label: '管理后台', + icon: 'pi pi-fw pi-sliders-h text-yellow-400', to: '/admin/servers' }, - { - label: '实例管理', - icon: 'pi pi-fw pi-desktop text-lime-500', - to: '/admin/instances' - }, - { - label: '镜像管理', - icon: 'pi pi-fw pi-images text-teal-500', - to: '/admin/images' - }, - { - label: '用户管理', - icon: 'pi pi-fw pi-users text-indigo-500', - to: '/admin/users' - }, ] }) diff --git a/frontend/src/layout/AppTopbar.vue b/frontend/src/layout/AppTopbar.vue index 62b0c50..ad48e94 100644 --- a/frontend/src/layout/AppTopbar.vue +++ b/frontend/src/layout/AppTopbar.vue @@ -39,7 +39,7 @@ - + @@ -61,7 +61,7 @@ const username = ref(''); const profileMenu = ref(null); const profileMenuActive = ref(false); -const instanceMenuItems = [ +const profileMenuItems = ref([ { label: '个人信息', icon: 'pi pi-user !text-cyan-500', @@ -78,6 +78,12 @@ const instanceMenuItems = [ router.push('/settings'); } }, + { + separator: true + }, +]); + +const profileExitItems = ref([ { label: '退出登录', icon: 'pi pi-sign-out', @@ -86,7 +92,35 @@ const instanceMenuItems = [ logout(); } } -]; +]); + +const profileAdminItems = ref([ + { + label: '管理后台', + icon: 'pi pi-sliders-h !text-yellow-400', + command: () => { + profileMenu.value.hide(); + router.push('/admin/instances'); + } + }, + { + separator: true + }, +]) + +const profileSuperadminItems = ref([ + { + label: '管理后台', + icon: 'pi pi-sliders-h !text-yellow-400', + command: () => { + profileMenu.value.hide(); + router.push('/admin/servers'); + } + }, + { + separator: true + }, +]) const showMenu = (event) => { profileMenu.value.show(event); @@ -105,6 +139,14 @@ const logout = () => { onMounted(() => { username.value = profileStore.username; + + if (profileStore.isSuperAdmin) { + profileMenuItems.value.push(...profileSuperadminItems.value); + } else if (profileStore.isAdmin) { + profileMenuItems.value.push(...profileAdminItems.value); + } + + profileMenuItems.value.push(...profileExitItems.value); }); \ No newline at end of file diff --git a/frontend/src/router/index.js b/frontend/src/router/index.js index 4e11b15..ed382e1 100644 --- a/frontend/src/router/index.js +++ b/frontend/src/router/index.js @@ -17,6 +17,7 @@ import Instances from '@/views/admin/Instances.vue'; import Servers from '@/views/admin/Servers.vue'; import Users from '@/views/admin/Users.vue'; +import AppAdminLayout from '@/layout/AppAdminLayout.vue'; import NotFound from '@/views/NotFound.vue'; const router = createRouter({ @@ -70,24 +71,31 @@ const router = createRouter({ path: 'settings', name: 'settings', component: Settings - }, + } + ] + }, + { + path: '/admin/', + name: 'admin-dashboard', + component: AppAdminLayout, + children: [ { - path: 'admin/images', + path: 'images', name: 'admin-images', component: Images }, { - path: 'admin/instances', + path: 'instances', name: 'admin-instances', component: Instances }, { - path: 'admin/servers', + path: 'servers', name: 'admin-servers', component: Servers }, { - path: 'admin/users', + path: 'users', name: 'admin-users', component: Users }