MyHeader.vue 1.1 KB
Newer Older
1
<template>
2 3 4
  <div
    class="layout-header-container d-flex justify-content-between align-items-center p-3"
  >
5 6 7
    <!-- 左侧 logo 和 标题区域 -->
    <div class="layout-header-left d-flex align-items-center user-select-none">
      <!-- logo -->
8
      <img class="layout-header-left-img" src="../../assets/kwan.png" alt="" />
9
      <!-- 标题 -->
10
      <h4 class="layout-header-left-title ml-3">kwan的解忧杂货铺</h4>
11
    </div>
12 13 14
    <a href="http://qinyingjie.top/" target="_blank" class="header-button-item"
      >kwan</a
    >
15 16
    <!-- 右侧按钮区域 -->
    <div class="layout-header-right">
17 18 19
      <button type="button" class="btn btn-light" @click="logout">
        退出登录
      </button>
20 21 22 23 24 25
    </div>
  </div>
</template>

<script>
export default {
26
  name: "MyHeader",
27 28 29
  methods: {
    logout() {
      // 1. 清空 token
30
      localStorage.removeItem("token");
31
      // 2. 跳转到登录页面
32 33 34 35
      this.$router.push("/login");
    },
  },
};
36 37 38 39 40 41 42 43 44 45 46
</script>

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

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