Blame view

HHECS.Web/src/layout/components/Navbar.vue 3.16 KB
胡菁 authored
1
2
<template>
  <div class="navbar">
王硕 authored
3
4
5
6
7
    <hamburger
      :is-active="sidebar.opened"
      class="hamburger-container"
      @toggleClick="toggleSideBar"
    />
胡菁 authored
8
9
10
11
12
13

    <breadcrumb class="breadcrumb-container" />

    <div class="right-menu">
      <el-dropdown class="avatar-container" trigger="click">
        <div class="avatar-wrapper">
王硕 authored
14
          <span style="margin-right: 10px">{{ name }}</span>
胡菁 authored
15
16
          <!-- <img :src="avatar+'?imageView2/1/w/80/h/80'" class="user-avatar"> -->
          <!-- <div icon="el-icon-user-solid" class="user-avatar"></div> -->
王硕 authored
17
          <i class="el-icon-user-solid user-avatar" />
胡菁 authored
18
          <i class="el-icon-caret-bottom" />
胡菁 authored
19
20
        </div>
        <el-dropdown-menu slot="dropdown" class="user-dropdown">
胡菁 authored
21
          <!-- <router-link to="/">
胡菁 authored
22
23
24
            <el-dropdown-item>
              Home
            </el-dropdown-item>
胡菁 authored
25
          </router-link> -->
胡菁 authored
26
          <el-dropdown-item divided @click.native="logout">
王硕 authored
27
            <span style="display: block">{{ $gl("logOut") }}</span>
胡菁 authored
28
29
30
31
32
33
34
35
          </el-dropdown-item>
        </el-dropdown-menu>
      </el-dropdown>
    </div>
  </div>
</template>

<script>
王硕 authored
36
37
38
import Breadcrumb from "@/components/Breadcrumb";
import Hamburger from "@/components/Hamburger";
import { mapGetters } from "vuex";
胡菁 authored
39
40

export default {
胡菁 authored
41
  data() {
王硕 authored
42
    return {};
胡菁 authored
43
  },
胡菁 authored
44
45
  components: {
    Breadcrumb,
王硕 authored
46
    Hamburger,
胡菁 authored
47
48
  },
  computed: {
王硕 authored
49
    ...mapGetters(["sidebar", "avatar", "name"]),
胡菁 authored
50
51
52
  },
  methods: {
    toggleSideBar() {
王硕 authored
53
      this.$store.dispatch("app/toggleSideBar");
胡菁 authored
54
55
    },
    async logout() {
王硕 authored
56
57
58
59
60
61
      window.$currentLang = "zh";
      await this.$store.dispatch("user/logout");
      this.$router.push(`/login?redirect=${this.$route.fullPath}`);
    },
  },
};
胡菁 authored
62
63
64
65
66
67
68
69
</script>

<style lang="scss" scoped>
.navbar {
  height: 50px;
  overflow: hidden;
  position: relative;
  background: #fff;
王硕 authored
70
  box-shadow: 0 1px 4px rgba(0, 21, 41, 0.08);
胡菁 authored
71
72
73
74
75
76

  .hamburger-container {
    line-height: 46px;
    height: 100%;
    float: left;
    cursor: pointer;
王硕 authored
77
78
    transition: background 0.3s;
    -webkit-tap-highlight-color: transparent;
胡菁 authored
79
80

    &:hover {
王硕 authored
81
      background: rgba(0, 0, 0, 0.025);
胡菁 authored
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
    }
  }

  .breadcrumb-container {
    float: left;
  }

  .right-menu {
    float: right;
    height: 100%;
    line-height: 50px;

    &:focus {
      outline: none;
    }

    .right-menu-item {
      display: inline-block;
      padding: 0 8px;
      height: 100%;
      font-size: 18px;
      color: #5a5e66;
      vertical-align: text-bottom;

      &.hover-effect {
        cursor: pointer;
王硕 authored
108
        transition: background 0.3s;
胡菁 authored
109
110

        &:hover {
王硕 authored
111
          background: rgba(0, 0, 0, 0.025);
胡菁 authored
112
113
114
115
116
117
118
119
        }
      }
    }

    .avatar-container {
      margin-right: 30px;

      .avatar-wrapper {
胡菁 authored
120
        // margin-top: 5px;
胡菁 authored
121
        position: relative;
胡菁 authored
122
123
124
125
        display: flex;
        align-items: center;
        font-size: 14pt;
        font-weight: bold;
胡菁 authored
126
127
128

        .user-avatar {
          cursor: pointer;
胡菁 authored
129
130
          // width: 40px;
          // height: 40px;
胡菁 authored
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
          border-radius: 10px;
        }

        .el-icon-caret-bottom {
          cursor: pointer;
          position: absolute;
          right: -20px;
          top: 25px;
          font-size: 12px;
        }
      }
    }
  }
}
</style>