|
@@ -1,55 +1,73 @@
|
|
<template>
|
|
<template>
|
|
- <el-menu class="navbar" mode="horizontal">
|
|
|
|
- <div class="user-profile-container" trigger="click">
|
|
|
|
- <div class="user-profile-content">
|
|
|
|
- <div class="menu-icons">
|
|
|
|
- <span class="menu-icon">
|
|
|
|
- <i class="el-icon-search icon" />
|
|
|
|
- </span>
|
|
|
|
- <span class="menu-icon">
|
|
|
|
- <i class="el-icon-message icon" />
|
|
|
|
- </span>
|
|
|
|
- <span class="menu-icon">
|
|
|
|
- <el-badge is-dot class="item">
|
|
|
|
- <i class="el-icon-bell icon" />
|
|
|
|
- </el-badge>
|
|
|
|
- </span>
|
|
|
|
- </div>
|
|
|
|
- <el-dropdown>
|
|
|
|
- <div class="user-profile-body">
|
|
|
|
- <img
|
|
|
|
- class="user-avatar"
|
|
|
|
- src="https://img.alicdn.com/tfs/TB1ONhloamWBuNjy1XaXXXCbXXa-200-200.png"
|
|
|
|
- />
|
|
|
|
- <span class="user-name">{{ name }}</span>
|
|
|
|
|
|
+ <div class="nav-bar">
|
|
|
|
+ <div class="nav-bar-logo">
|
|
|
|
+ <img
|
|
|
|
+ src="https://img.alicdn.com/tfs/TB13UQpnYGYBuNjy0FoXXciBFXa-242-134.png"
|
|
|
|
+ width="40"
|
|
|
|
+ />
|
|
|
|
+ <!-- <span class="site-name">ADMIN LITE</span> -->
|
|
|
|
+ </div>
|
|
|
|
+ <div class="nav-bar-menu menu-list">
|
|
|
|
+ <ul>
|
|
|
|
+ <li
|
|
|
|
+ v-for="(nav, index) in navs"
|
|
|
|
+ :key="index"
|
|
|
|
+ @click="toPage(nav)"
|
|
|
|
+ :class="{ 'menu-item-act': curNav === nav.name }"
|
|
|
|
+ >
|
|
|
|
+ <div class="menu-item">
|
|
|
|
+ <i
|
|
|
|
+ :class="[
|
|
|
|
+ 'icon',
|
|
|
|
+ curNav === nav.name ? `${nav.icon}-act` : `${nav.icon}`,
|
|
|
|
+ ]"
|
|
|
|
+ ></i>
|
|
|
|
+ <span>{{ nav.title }}</span>
|
|
|
|
+ </div>
|
|
|
|
+ </li>
|
|
|
|
+ </ul>
|
|
|
|
+ </div>
|
|
|
|
+ <div class="nav-bar-user menu-list">
|
|
|
|
+ <ul>
|
|
|
|
+ <li>
|
|
|
|
+ <div class="menu-item">
|
|
|
|
+ <i class="icon icon-user"></i>
|
|
|
|
+ <span v-if="username">{{ username }},欢迎你</span>
|
|
</div>
|
|
</div>
|
|
- <el-dropdown-menu slot="dropdown" class="user-dropdown">
|
|
|
|
- <router-link to="/">
|
|
|
|
- <el-dropdown-item>我的主页</el-dropdown-item>
|
|
|
|
- </router-link>
|
|
|
|
- <router-link to="/">
|
|
|
|
- <el-dropdown-item>个人设置</el-dropdown-item>
|
|
|
|
- </router-link>
|
|
|
|
- <el-dropdown-item>
|
|
|
|
- <span style="display: block;" @click="logout">退出</span>
|
|
|
|
- </el-dropdown-item>
|
|
|
|
- </el-dropdown-menu>
|
|
|
|
- </el-dropdown>
|
|
|
|
- </div>
|
|
|
|
|
|
+ </li>
|
|
|
|
+ <li @click="toLogout">
|
|
|
|
+ <div class="menu-item">
|
|
|
|
+ <i class="icon icon-logout"></i>
|
|
|
|
+ <span>退出登录</span>
|
|
|
|
+ </div>
|
|
|
|
+ </li>
|
|
|
|
+ </ul>
|
|
</div>
|
|
</div>
|
|
- </el-menu>
|
|
|
|
|
|
+ </div>
|
|
</template>
|
|
</template>
|
|
|
|
|
|
<script>
|
|
<script>
|
|
|
|
+import { headerMenuConfig } from "./menu";
|
|
|
|
+
|
|
export default {
|
|
export default {
|
|
name: "NavBar",
|
|
name: "NavBar",
|
|
computed: {
|
|
computed: {
|
|
- name() {
|
|
|
|
|
|
+ username() {
|
|
return this.$store.state.user.name;
|
|
return this.$store.state.user.name;
|
|
},
|
|
},
|
|
},
|
|
},
|
|
|
|
+ data() {
|
|
|
|
+ return {
|
|
|
|
+ navs: headerMenuConfig,
|
|
|
|
+ curNav: "",
|
|
|
|
+ };
|
|
|
|
+ },
|
|
methods: {
|
|
methods: {
|
|
- logout() {
|
|
|
|
|
|
+ toPage(nav) {
|
|
|
|
+ this.curNav = nav.name;
|
|
|
|
+ this.$emit("on-nav-change", nav.name);
|
|
|
|
+ },
|
|
|
|
+ toLogout() {
|
|
// console.log('Logout');
|
|
// console.log('Logout');
|
|
this.$router.push("/login");
|
|
this.$router.push("/login");
|
|
},
|
|
},
|
|
@@ -58,56 +76,70 @@ export default {
|
|
</script>
|
|
</script>
|
|
|
|
|
|
<style lang="scss" scoped>
|
|
<style lang="scss" scoped>
|
|
-.navbar {
|
|
|
|
- height: 64px;
|
|
|
|
- box-shadow: 0 1px 4px rgba(0, 21, 41, 0.08);
|
|
|
|
- .user-profile-container {
|
|
|
|
|
|
+.nav-bar {
|
|
|
|
+ position: fixed;
|
|
|
|
+ top: 0;
|
|
|
|
+ left: 0;
|
|
|
|
+ width: 100%;
|
|
|
|
+ height: 60px;
|
|
|
|
+ z-index: 1001;
|
|
|
|
+ overflow: hidden;
|
|
|
|
+ background: #fff;
|
|
|
|
+
|
|
|
|
+ &::after {
|
|
|
|
+ content: "";
|
|
position: absolute;
|
|
position: absolute;
|
|
- right: 20px;
|
|
|
|
- cursor: pointer;
|
|
|
|
- .user-profile-content {
|
|
|
|
- display: flex;
|
|
|
|
- padding: 20px 0;
|
|
|
|
|
|
+ width: 100%;
|
|
|
|
+ left: 0;
|
|
|
|
+ bottom: 0;
|
|
|
|
+ z-index: auto;
|
|
|
|
+ border-bottom: 1px solid #eee;
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ &-logo {
|
|
|
|
+ width: 220px;
|
|
|
|
+ float: left;
|
|
|
|
+ padding: 14px 30px;
|
|
|
|
+ font-size: 20px;
|
|
|
|
+ line-height: 32px;
|
|
|
|
+ > img {
|
|
|
|
+ display: block;
|
|
|
|
+ max-width: 160px;
|
|
|
|
+ height: 32px;
|
|
}
|
|
}
|
|
- .menu-icons {
|
|
|
|
- display: flex;
|
|
|
|
- align-items: center;
|
|
|
|
- .menu-icon {
|
|
|
|
- padding: 0 12px;
|
|
|
|
- .icon {
|
|
|
|
- display: inline-block;
|
|
|
|
- font-size: 18px;
|
|
|
|
- text-align: center;
|
|
|
|
- }
|
|
|
|
- }
|
|
|
|
|
|
+ }
|
|
|
|
+ &-menu {
|
|
|
|
+ float: left;
|
|
|
|
+ }
|
|
|
|
+ &-user {
|
|
|
|
+ float: right;
|
|
|
|
+ }
|
|
|
|
+ .menu-list {
|
|
|
|
+ ul {
|
|
|
|
+ padding: 0;
|
|
}
|
|
}
|
|
- .user-profile-body {
|
|
|
|
|
|
+ li {
|
|
|
|
+ display: inline-block;
|
|
|
|
+ vertical-align: top;
|
|
|
|
+ padding: 20px 15px;
|
|
|
|
+ line-height: 20px;
|
|
|
|
+ font-size: 14px;
|
|
position: relative;
|
|
position: relative;
|
|
- display: flex;
|
|
|
|
- flex-direction: row;
|
|
|
|
- align-items: center;
|
|
|
|
- justify-content: center;
|
|
|
|
text-align: center;
|
|
text-align: center;
|
|
- padding-right: 14px;
|
|
|
|
- }
|
|
|
|
- .user-avatar {
|
|
|
|
- width: 24px;
|
|
|
|
- height: 24px;
|
|
|
|
- margin: 0 8px 0 12px;
|
|
|
|
- border-radius: 4px;
|
|
|
|
- }
|
|
|
|
- .user-name {
|
|
|
|
- color: rgba(0, 0, 0, 0.65);
|
|
|
|
- }
|
|
|
|
- .user-department {
|
|
|
|
- font-size: 12px;
|
|
|
|
- color: rgba(102, 102, 102, 0.65);
|
|
|
|
- }
|
|
|
|
- .el-icon-caret-bottom {
|
|
|
|
- position: absolute;
|
|
|
|
- right: 0;
|
|
|
|
- top: 13px;
|
|
|
|
- font-size: 12px;
|
|
|
|
|
|
+ font-weight: 600;
|
|
|
|
+ color: #626a82;
|
|
|
|
+ cursor: pointer;
|
|
|
|
+
|
|
|
|
+ &:hover,
|
|
|
|
+ &.menu-item-act {
|
|
|
|
+ color: #1886fe;
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ span {
|
|
|
|
+ display: inline-block;
|
|
|
|
+ vertical-align: middle;
|
|
|
|
+ margin-left: 8px;
|
|
|
|
+ }
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|