feat: add admin login

This commit is contained in:
yanghao05
2025-04-16 19:55:32 +08:00
parent 8d601d456e
commit e95fc65f5f
11 changed files with 241 additions and 3 deletions

View File

@@ -1,10 +1,12 @@
<script setup>
import { useAuthStore } from '@/stores/auth';
import Button from 'primevue/button';
import Menubar from 'primevue/menubar';
import { ref } from 'vue';
import { useRouter } from 'vue-router';
const router = useRouter();
const authStore = useAuthStore();
const navItems = ref([
{
@@ -39,10 +41,18 @@ const navItems = ref([
}
]);
const handleLogout = () => {
authStore.logout();
router.push('/login');
};
</script>
<template>
<div class="flex flex-col min-h-screen">
<div v-if="!authStore.isAuthenticated">
<router-view />
</div>
<div v-else class="flex flex-col min-h-screen">
<header class="sticky top-0 z-50 shadow-md">
<Menubar :model="navItems" class="!rounded-none">
<template #start>
@@ -51,7 +61,7 @@ const navItems = ref([
</div>
</template>
<template #end>
<Button label="Logout" icon="pi pi-power-off" severity="secondary" text />
<Button label="Logout" icon="pi pi-power-off" severity="secondary" text @click="handleLogout" />
</template>
</Menubar>
</header>