guhongwei 4 лет назад
Родитель
Сommit
692d64d2ad
1 измененных файлов с 33 добавлено и 2 удалено
  1. 33 2
      src/components/adminCommon/frame.vue

+ 33 - 2
src/components/adminCommon/frame.vue

@@ -7,7 +7,7 @@
         </el-col>
         <el-col :span="4" class="right">
           <span>{{ user ? user.name : '游客' }}</span>
-          <span><i class="el-icon-switch-button"></i></span>
+          <span @click="logoutBtn"><i class="el-icon-switch-button"></i></span>
         </el-col>
       </el-header>
       <el-container class="container">
@@ -35,7 +35,13 @@ export default {
     return {};
   },
   created() {},
-  methods: {},
+  methods: {
+    // 退出登录
+    logoutBtn() {
+      localStorage.removeItem('token');
+      this.$router.push({ path: '/' });
+    },
+  },
   computed: {
     ...mapState(['user']),
   },
@@ -55,6 +61,31 @@ export default {
 <style lang="less" scoped>
 .header {
   border-bottom: 1px solid #ff0000;
+  .left {
+    height: 60px;
+    line-height: 60px;
+    font-size: 25px;
+    font-family: cursive;
+    font-weight: bold;
+  }
+  .right {
+    height: 60px;
+    line-height: 60px;
+    font-size: 20px;
+    text-align: center;
+    span {
+      padding: 0 10px;
+      i {
+        font-weight: bold;
+      }
+    }
+    span:hover {
+      cursor: pointer;
+      i {
+        color: #ff0000;
+      }
+    }
+  }
 }
 .container {
   .aside {