feat(auth): implement login page and state management

This commit is contained in:
2025-06-17 10:00:17 +03:00
parent c4a1c2cde0
commit d6059f4325
5 changed files with 209 additions and 11 deletions

View File

@@ -1,16 +1,31 @@
<template>
<header>
<nav>
<router-link to="/">Главная</router-link> | <router-link to="/login">Вход</router-link> |
<router-link to="/register">Регистрация</router-link>
<router-link to="/">Главная</router-link> |
<!-- Показываем, если пользователь НЕ залогинен -->
<template v-if="!authStore.isAuthenticated">
<router-link to="/login">Вход</router-link> |
<router-link to="/register">Регистрация</router-link>
</template>
<!-- Показываем, если пользователь залогинен -->
<template v-else>
<span>Привет, {{ authStore.user?.username }}!</span> |
<a @click="authStore.handleLogout" href="#">Выход</a>
</template>
</nav>
</header>
<main>
<!-- Здесь будут отображаться компоненты-страницы -->
<router-view />
</main>
</template>
<script setup lang="ts">
import { useAuthStore } from "@/stores/auth";
const authStore = useAuthStore();
</script>
<style scoped>
header {
background-color: #f0f0f0;
@@ -29,4 +44,10 @@ nav a.router-link-exact-active {
main {
padding: 1rem;
}
span {
margin: 0 1rem;
}
a {
cursor: pointer;
}
</style>