feat: login

This commit is contained in:
tbphp
2025-07-02 19:14:23 +08:00
parent c7d54db31a
commit 8e1de8d29f
10 changed files with 216 additions and 9 deletions

View File

@@ -1,5 +1,5 @@
<template>
<n-layout>
<n-layout v-if="authService.isLoggedIn()">
<n-layout-header class="flex items-center">
<h1 class="layout-header-title">T.COM</h1>
<nav-bar />
@@ -9,11 +9,13 @@
<router-view />
</n-layout-content>
</n-layout>
<router-view v-else />
</template>
<script setup lang="ts">
import NavBar from "@/components/NavBar.vue";
import Logout from "@/components/Logout.vue";
import { authService } from "@/services/auth";
</script>
<style scoped>

View File

@@ -1,3 +1,15 @@
<template>
<n-button quaternary round>退出</n-button>
<n-button quaternary round @click="handleLogout">退出</n-button>
</template>
<script setup lang="ts">
import { authService } from "@/services/auth";
import { useRouter } from "vue-router";
const router = useRouter();
const handleLogout = () => {
authService.logout();
router.push("/login");
};
</script>