MyHeader.vue 1.3 KB
Newer Older
1
<template>
2
  <div class="layout-header-container d-flex justify-content-between align-items-center p-3">
3 4 5
    <!-- 左侧 logo 和 标题区域 -->
    <div class="layout-header-left d-flex align-items-center user-select-none">
      <!-- logo -->
6
      <img class="layout-header-left-img" src="../../assets/kwan.png" alt=""/>
7
      <!-- 标题 -->
8
      <h4 class="layout-header-left-title ml-3">kwan的解忧杂货铺</h4>
9
    </div>
10 11 12 13 14 15 16 17 18 19
    <el-row>
      <el-col :inline="true" :span="24">
        <el-button class="el-button-header" type="success" round @click="myHome">
          我的主页
        </el-button>
        <el-button class="el-button-header" type="primary" round @click="logout">
          退出登录
        </el-button>
      </el-col>
    </el-row>
20 21 22 23 24
  </div>
</template>

<script>
export default {
25
  name: "MyHeader",
26 27 28
  methods: {
    logout() {
      // 1. 清空 token
29
      localStorage.removeItem("token");
30
      // 2. 跳转到登录页面
31 32
      this.$router.push("/login");
    },
33 34 35 36 37 38
    myHome() {
      // 新页面打开
      window.open("http://qinyingjie.top/");
      // 当前页面打开
      // window.location.href = "http://qinyingjie.top/";
    },
39 40
  },
};
41 42 43 44 45 46 47 48 49 50 51
</script>

<style lang="less" scoped>
.layout-header-container {
  height: 60px;
  border-bottom: 1px solid #eaeaea;
}

.layout-header-left-img {
  height: 50px;
}
52
</style>