首页增加退出登录按钮

This commit is contained in:
GeekMaster
2025-05-08 09:46:35 +08:00
parent cdaeb2a404
commit 7c81d946a7
2 changed files with 40 additions and 15 deletions

View File

@@ -34,6 +34,15 @@
>登录/注册</el-button
>
</span>
<span v-if="isLogin">
<el-button
@click="logout"
class="btn-go animate__animated animate__pulse animate__infinite"
round
>
退出登录
</el-button>
</span>
</div>
</el-menu>
</div>
@@ -195,6 +204,15 @@ const rainbowColor = (index) => {
const hue = (index * 40) % 360 // 每个字符间隔40度形成彩虹色
return `hsl(${hue}, 90%, 50%)` // 色调(hue),饱和度(70%),亮度(50%)
}
httpGet('/api/user/logout')
.then(() => {
removeUserToken()
router.push('/login')
})
.catch(() => {
ElMessage.error('注销失败!')
})
</script>
<style lang="stylus" scoped>