Blame view

HHECS.Web/src/layout/components/Navbar.vue 4.3 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

    <breadcrumb class="breadcrumb-container" />

    <div class="right-menu">
12
13
      <screenfull id="screenfull" class="right-menu-item hover-effect" />
14
      <!-- <el-dropdown
王硕 authored
15
16
17
18
        class="avatar-container"
        trigger="click"
        style="margin: 0 5px"
      >
19
20
21
22
23
24
25
        <div class="avatar-wrapper">
          <span class="lang">
            <svg-icon icon-class="language" />
          </span>
        </div>
        <el-dropdown-menu slot="dropdown" class="user-dropdown">
          <router-link to="/">
胡菁 authored
26
27
28
29
30
31
            <el-dropdown-item @click.native="onChange('zh')">
              中文
            </el-dropdown-item>
            <el-dropdown-item @click.native="onChange('en')">
              英文
            </el-dropdown-item>
32
33
          </router-link>
        </el-dropdown-menu>
34
      </el-dropdown> -->
胡菁 authored
35
      <el-divider direction="vertical"></el-divider>
36
胡菁 authored
37
38
      <el-dropdown class="avatar-container" trigger="click">
        <div class="avatar-wrapper">
胡菁 authored
39
          <span style="margin-right: 10px; cursor: pointer">{{ name }}</span>
胡菁 authored
40
41
          <!-- <img :src="avatar+'?imageView2/1/w/80/h/80'" class="user-avatar"> -->
          <!-- <div icon="el-icon-user-solid" class="user-avatar"></div> -->
王硕 authored
42
          <i class="el-icon-user-solid user-avatar" />
胡菁 authored
43
          <i class="el-icon-caret-bottom" />
胡菁 authored
44
45
        </div>
        <el-dropdown-menu slot="dropdown" class="user-dropdown">
weijuan55650@qq.com authored
46
          <router-link to="/system/index/system">
胡菁 authored
47
            <el-dropdown-item>{{ $t("system.authorize") }}</el-dropdown-item>
48
          </router-link>
胡菁 authored
49
          <el-dropdown-item divided @click.native="logout">
胡菁 authored
50
            <span style="display: block">{{ $t("system.logOut") }}</span>
胡菁 authored
51
52
53
54
55
56
57
58
          </el-dropdown-item>
        </el-dropdown-menu>
      </el-dropdown>
    </div>
  </div>
</template>

<script>
胡菁 authored
59
60
61
62
import Breadcrumb from "@/components/Breadcrumb";
import Hamburger from "@/components/Hamburger";
import Screenfull from "@/components/Screenfull";
import { mapGetters } from "vuex";
胡菁 authored
63
64
65
66

export default {
  components: {
    Breadcrumb,
王硕 authored
67
    Hamburger,
胡菁 authored
68
    Screenfull,
69
70
  },
  data() {
胡菁 authored
71
    return {};
胡菁 authored
72
73
  },
  computed: {
胡菁 authored
74
75
76
    ...mapGetters(["sidebar", "avatar", "name"]),
  },
胡菁 authored
77
78
  methods: {
    toggleSideBar() {
胡菁 authored
79
      this.$store.dispatch("app/toggleSideBar");
胡菁 authored
80
81
    },
    async logout() {
胡菁 authored
82
83
84
      await this.$store.dispatch("user/logout");
      this.$router.push(`/login?redirect=${this.$route.fullPath}`);
    },
胡菁 authored
85
86
87
88
    onChange(data) {
      localStorage.setItem("lang", data);
      this.$i18n.locale = data;
    },
胡菁 authored
89
90
  },
};
胡菁 authored
91
92
93
94
95
96
97
98
</script>

<style lang="scss" scoped>
.navbar {
  height: 50px;
  overflow: hidden;
  position: relative;
  background: #fff;
王硕 authored
99
  box-shadow: 0 1px 4px rgba(0, 21, 41, 0.08);
胡菁 authored
100
101
102
103
104
105

  .hamburger-container {
    line-height: 46px;
    height: 100%;
    float: left;
    cursor: pointer;
王硕 authored
106
107
    transition: background 0.3s;
    -webkit-tap-highlight-color: transparent;
胡菁 authored
108
109

    &:hover {
王硕 authored
110
      background: rgba(0, 0, 0, 0.025);
胡菁 authored
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
    }
  }

  .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;
王硕 authored
133
      //   vertical-align: text-bottom;
胡菁 authored
134
135
136

      &.hover-effect {
        cursor: pointer;
王硕 authored
137
        transition: background 0.3s;
胡菁 authored
138
139

        &:hover {
王硕 authored
140
          background: rgba(0, 0, 0, 0.025);
胡菁 authored
141
142
143
144
145
146
147
148
        }
      }
    }

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

      .avatar-wrapper {
胡菁 authored
149
        // margin-top: 5px;
胡菁 authored
150
        position: relative;
151
        // display: flex;
胡菁 authored
152
153
154
        align-items: center;
        font-size: 14pt;
        font-weight: bold;
王硕 authored
155
156
        span.lang {
          display: block;
157
158
159
          height: 100%;
          padding: 0 10px;
        }
王硕 authored
160
161
162
        span.lang:hover {
          cursor: pointer;
          background: #f9f9f9;
163
        }
胡菁 authored
164
165
        .user-avatar {
          cursor: pointer;
胡菁 authored
166
167
          // width: 40px;
          // height: 40px;
胡菁 authored
168
169
170
171
172
173
174
          border-radius: 10px;
        }

        .el-icon-caret-bottom {
          cursor: pointer;
          position: absolute;
          right: -20px;
175
          top: 22px;
胡菁 authored
176
177
178
179
180
181
182
          font-size: 12px;
        }
      }
    }
  }
}
</style>