修改目录

This commit is contained in:
2025-05-19 11:14:52 +08:00
parent 6bacf24d12
commit b706598b9f
3 changed files with 239 additions and 0 deletions

View File

@@ -0,0 +1,35 @@
<template>
<button @click="handleLogout">
退出登录
</button>
</template>
<script setup>
import { ref, onMounted } from 'vue'
import { useRouter } from 'vue-router'
const router = useRouter()
const hasToken = ref(false)
onMounted(() => {
// 检查是否有token
const token = localStorage.getItem('access_token')
hasToken.value = !!token
console.log('检测到token')
if (!token) {
console.log('未检测到token')
}
})
const handleLogout = () => {
// 清除本地存储的 token
localStorage.removeItem('access_token')
// 跳转到登录页面
router.push('/backend/login')
}
</script>
<style scoped>
</style>