feat: login
This commit is contained in:
@@ -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>
|
||||
|
@@ -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>
|
||||
|
Reference in New Issue
Block a user