From 1dbc6ed10458201d22e7f47a7da36f75f0ebf257 Mon Sep 17 00:00:00 2001
From: zhongrj <646384940@qq.com>
Date: Tue, 02 Jun 2026 13:35:58 +0800
Subject: [PATCH] ``` feat(layout): 添加退出登录功能
---
src/views/layout/index.vue | 60 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++-
1 files changed, 59 insertions(+), 1 deletions(-)
diff --git a/src/views/layout/index.vue b/src/views/layout/index.vue
index b6ae075..c3f2650 100644
--- a/src/views/layout/index.vue
+++ b/src/views/layout/index.vue
@@ -10,6 +10,10 @@
-->
<template>
<div class="wrapper">
+ <div class="logout-btn" @click="handleLogout">
+ <i class="el-icon-logout"></i>
+ <span>退出登录</span>
+ </div>
<map-box ref="modalForm" :curMap="curMap" @getsearchSKValList="getsearchSKValList($event)">
<!-- 主体内容区域 -->
<div slot="mainContent" class="main-content" id="MainContent">
@@ -134,6 +138,7 @@
<script>
import { getSignSituationList, getExamScoreList, getExamList, getLatestExam } from "@/api/home/index"
+import { logout } from "@/api/user"
import { EventBus } from "@/utils/EventBus"
@@ -453,6 +458,28 @@
handleVideoClose () {
this.$store.commit("SET_ISSHOWVIDEODIALOG", false)
+ },
+
+ handleLogout () {
+ this.$confirm('确定要退出登录吗?', '提示', {
+ confirmButtonText: '确定',
+ cancelButtonText: '取消',
+ type: 'warning'
+ }).then(() => {
+ logout().then(() => {
+ this.$store.commit('SET_TOKEN', '')
+ this.$store.commit('SET_USER_INFO', {})
+ localStorage.removeItem('token')
+ localStorage.removeItem('userInfo')
+ this.$router.push({ path: '/login' })
+ }).catch(() => {
+ this.$store.commit('SET_TOKEN', '')
+ this.$store.commit('SET_USER_INFO', {})
+ localStorage.removeItem('token')
+ localStorage.removeItem('userInfo')
+ this.$router.push({ path: '/login' })
+ })
+ }).catch(() => {})
}
}
}
@@ -463,7 +490,38 @@
position: relative;
width: 100vw;
height: 100vh;
- // border: 1px solid white;
+
+ .logout-btn {
+ position: fixed;
+ top: 20px;
+ right: 20px;
+ z-index: 9999;
+ display: flex;
+ align-items: center;
+ gap: 8px;
+ padding: 10px 20px;
+ background: rgba(255, 255, 255, 0.15);
+ border: 1px solid rgba(255, 255, 255, 0.3);
+ border-radius: 25px;
+ color: #fff;
+ font-size: 14px;
+ cursor: pointer;
+ transition: all 0.3s ease;
+
+ &:hover {
+ background: rgba(255, 255, 255, 0.25);
+ border-color: rgba(255, 255, 255, 0.5);
+ transform: translateY(-2px);
+ }
+
+ &:active {
+ transform: translateY(0);
+ }
+
+ i {
+ font-size: 16px;
+ }
+ }
#MainContent {
position: absolute;
--
Gitblit v1.9.3