Blame view

src/layout/components/Navbar.vue 5.44 KB
赵千 committed
1
<template>
任超 committed
2 3 4 5 6 7 8 9 10
  <div class="navbar-con">
    <div class="navbar" v-theme.background="mTheme">
      <div class="logo">
        <img v-if="logo" :src="logo" class="header-logo">
      </div>
      <div class="backdrop">
        <theme style="float: right;height: 26px;width: 26px;margin-top: 26px;" @change="themeChange" />
      </div>
      <div class="right-menu">
任超 committed
11
        <svg-icon class="function" icon-class='function' />
任超 committed
12 13 14 15 16 17 18 19 20 21 22
        <el-dropdown class="avatar-container right-menu-item hover-effect" trigger="hover" @command="handleCommand">
          <div class="avatar-wrapper">
            <span style="padding-right:10px">{{ name }}</span>
            <img :src="avatar + '?imageView2/1/w/80/h/80'" class="user-avatar" />
            <!-- <i class="el-icon-caret-bottom" /> -->
          </div>
          <el-dropdown-menu slot="dropdown">
            <el-dropdown-item command="a">个人中心</el-dropdown-item>
          </el-dropdown-menu>
        </el-dropdown>

任超 committed
23 24

        <svg-icon class="shutdown" icon-class='shutdown' />
任超 committed
25
      </div>
赵千 committed
26
    </div>
任超 committed
27
    <NoticeBar class="NoticeBar" :noticeList="noticeList" />
赵千 committed
28 29 30 31
  </div>
</template>
<script>
import { mapGetters } from 'vuex'
任超 committed
32 33 34
import NoticeBar from '@/components/NoticeBar/index'
import {
  getHomeNoticeList
任超 committed
35
} from "@/api/user"
赵千 committed
36
export default {
任超 committed
37 38 39
  components: {
    NoticeBar
  },
赵千 committed
40 41 42
  computed: {
    ...mapGetters(['sidebar', 'avatar', 'name'])
  },
任超 committed
43 44
  data () {
    return {
任超 committed
45
      logo: require('../../image/logo.png'),
任超 committed
46
      noticeList: []
任超 committed
47 48
    }
  },
任超 committed
49 50 51
  created () {
    this.queryNoticeList()
  },
任超 committed
52 53 54 55 56 57 58 59
  mounted () {
    let that = this
    window.addEventListener('message', function (messageEvent) {
      if (messageEvent.data.update) {
        that.queryNoticeList()
      }
    }, false)
  },
任超 committed
60 61 62
  destroyed () {
    window.removeEventListener('message')
  },
赵千 committed
63
  methods: {
任超 committed
64 65 66 67 68 69 70
    queryNoticeList () {
      getHomeNoticeList().then(res => {
        if (res.result) {
          this.noticeList = res.result.noticeList
        }
      })
    },
任超 committed
71 72 73
    themeChange (val) {
      this.$store.dispatch('app/updateTheme', val)
    },
赵千 committed
74 75 76 77 78 79 80 81 82 83 84 85 86
    searchMessageCenter () {
      this.$router.push({ name: 'messagecenter' })
    },
    handleCommand (command) {
      if (command == 'a') {
        //个人中心
        this.$router.push({ name: 'personal' })
      }
    }
  }
}
</script>
<style lang="scss" scoped>
任超 committed
87 88 89 90 91 92 93 94 95
.navbar-con {
  position: relative;
}

.NoticeBar {
  position: absolute;
  bottom: 0;
}

赵千 committed
96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131
.el-dropdown-menu {
  padding: 0 !important;
  border: 1px solid #EBEEF5;
  box-shadow: 0 2px 10px 0 rgba(0, 0, 0, 0.12);
  border-radius: 4px 0 0 4px 4px;

  .el-dropdown-menu__item {
    text-align: center;
    margin-top: 0 !important;
    font-size: 14px;
    font-family: PingFangSC-Regular, PingFang SC;
    font-weight: 400;
    color: #4A4A4A;
    width: 140px;
    height: 36px;
    line-height: 36px;
  }

  .el-dropdown-menu__item:nth-child(6) {
    border-top: 1px solid #EBEEF5;
  }

  .popper__arrow {
    top: -11px !important;
    left: 110px !important;
    transform: rotate(0deg) scale(2);
  }

  .el-dropdown-menu__item:not(.is-disabled):hover,
  .el-dropdown-menu__item:focus {
    background: #F6F7F9;
    color: #4A4A4A;
  }
}

.navbar {
任超 committed
132
  height: $headerHeight;
赵千 committed
133 134 135
  overflow: hidden;
  position: relative;
  background: #fff;
任超 committed
136
  // background: linear-gradient(270deg, #148CEE 0%, #1870E3 100%); //默认颜色
赵千 committed
137
  box-shadow: 0 1px 0px rgba(0, 21, 41, 0.08);
任超 committed
138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153
  display: flex;
  align-items: center;
  padding: 0 20px;
  justify-content: space-between;

  .header-logo {
    width: 300px;
  }

  .backdrop {
    flex: 1;
    width: 60%;
    background: url('../../image/backdrop.png');
    background-size: 100% 100%;
    height: $headerHeight;
  }
赵千 committed
154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175

  .hamburger-container {
    line-height: 43px;
    height: 100%;
    float: left;
    cursor: pointer;
    transition: background 0.3s;
    -webkit-tap-highlight-color: transparent;

    &:hover {
      background: rgba(0, 0, 0, 0.025);
    }
  }

  .breadcrumb-container {
    float: left;
  }

  .right-menu {
    float: right;
    height: 100%;
    line-height: 50px;
任超 committed
176 177 178 179 180 181 182 183 184 185 186 187 188
    display: flex;
    align-items: center;

    .function {
      margin: 0 15px;
      cursor: pointer;
    }

    .shutdown {
      font-size: 20px;
      margin-left: 15px;
      cursor: pointer;
    }
赵千 committed
189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221

    .organization-item {
      margin-right: 40px;
      margin-top: -40px !important;
    }

    .item {
      margin-right: 40px;
      margin-top: -20px;
      line-height: 18.4px;
      cursor: pointer;
      position: relative;

      .item-box {
        position: absolute;
        top: -5px;
        left: 3px;
        width: 100%;
        min-width: 25px;
        height: 25px;
        cursor: pointer;
        z-index: 100;
      }
    }

    &:focus {
      outline: none;
    }

    .right-menu-item {
      display: inline-block;
      height: 100%;
      font-size: 18px;
任超 committed
222
      color: #fff;
赵千 committed
223 224 225 226 227
      vertical-align: text-bottom;

      &.hover-effect {
        cursor: pointer;
        transition: background 0.3s;
任超 committed
228 229
        display: flex;
        align-items: center;
赵千 committed
230 231 232 233 234 235 236

        &:hover {
          background: rgba(0, 0, 0, 0.025);
        }
      }
    }

任超 committed
237 238 239 240 241
    .avatar-wrapper {
      position: relative;
      display: flex;
      height: 40px;
      align-items: center;
赵千 committed
242

任超 committed
243 244 245 246 247 248
      .user-avatar {
        cursor: pointer;
        width: 35px;
        height: 35px;
        border-radius: 50%;
      }
赵千 committed
249

任超 committed
250 251 252 253 254 255
      .el-icon-caret-bottom {
        cursor: pointer;
        position: absolute;
        right: -15px;
        top: 17px;
        font-size: 12px;
赵千 committed
256 257 258 259 260
      }
    }
  }
}
</style>