Blame view

src/layout1/components/Navbar.vue 2.17 KB
任超 committed
1 2 3
<template>
  <div class="navbar-con">
    <div class="navbar">
任超 committed
4
      <div class="logo">
xiaomiao committed
5
        <img :src="require('@/image/bdclogo.png')" alt="" />
renchao@pashanhoo.com committed
6
        <h4>{{ BASE_API.TITLE }}</h4>
任超 committed
7
      </div>
任超 committed
8
      <div class="right-menu">
9 10 11 12 13 14
        <div class="user">
          {{ userName }}
          <span @click="onCancel">
            <i class="el-icon-switch-button"></i>
          </span>
        </div>
任超 committed
15 16 17 18 19
      </div>
    </div>
  </div>
</template>
<script>
任超 committed
20 21
import { mapGetters } from 'vuex'
import Breadcrumb from './Breadcrumb'
任超 committed
22
import { logout } from "@/api/login.js";
任超 committed
23 24 25 26 27
export default {
  components: {
    Breadcrumb
  },
  computed: {
renchao@pashanhoo.com committed
28
    ...mapGetters(["userInfo"]),
任超 committed
29 30
    userName () {
      return this.userInfo ? this.userInfo.name : ""
任超 committed
31 32 33 34 35 36
    }
  },
  methods: {
    handleDataView () {
      const { href } = this.$router.resolve('/dataView');
      window.open(href, '_blank');
xiaomiao committed
37
    },
任超 committed
38 39
    themeChange (val) {
      this.$store.dispatch('app/updateTheme', val)
任超 committed
40
    },
任超 committed
41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56
    onCancel () {
      logout()
        .then((res) => {
          sessionStorage.removeItem("token");
          this.$store.dispatch("user/resetState");
          this.$store.dispatch("permission/resetRoutes");
          this.$router.replace({
            path: "/sb",
            query: {
              redirect: this.$route.fullPath,
            },
          });
        })
        .catch((error) => {
          // console.dir(error);
        })
任超 committed
57 58
    }
  }
任超 committed
59
}
任超 committed
60 61
</script>
<style lang="scss" scoped>
任超 committed
62
@import "~@/styles/_handle.scss";
任超 committed
63

任超 committed
64 65 66 67 68 69 70 71
.navbar-con {
  position: relative;

  .logo {
    color: #fff;
    font-size: 26px;
    font-weight: 700;
    display: flex;
任超 committed
72
    margin-left: 15px;
任超 committed
73 74 75 76 77 78 79 80 81 82

    img {
      width: 47px;
      height: 47px;
    }

    h4 {
      margin-left: 20px;
      height: 50px;
      line-height: 50px;
xiaomiao committed
83
    }
任超 committed
84
  }
任超 committed
85 86 87 88 89 90
}

.navbar {
  height: $headerHeight;
  overflow: hidden;
  position: relative;
任超 committed
91
  @include background("navbg");
任超 committed
92

任超 committed
93 94 95 96 97 98 99
  display: flex;
  align-items: center;
  padding-right: 20px;
  justify-content: space-between;

  .header-logo {
    width: 300px;
100 101
  }

任超 committed
102 103
  .right-menu-item {
    &.hover-effect {
任超 committed
104
      cursor: pointer;
任超 committed
105
      transition: background 0.3s;
任超 committed
106 107
      display: flex;
      align-items: center;
任超 committed
108 109
    }
  }
任超 committed
110
}
任超 committed
111
</style>