Blame view

src/layout/components/Navbar.vue 6.45 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' />
12 13 14 15
        <div class="avatar-wrapper">
          <span style="padding-right:10px">{{ name }}</span>
          <img :src="avatar + '?imageView2/1/w/80/h/80'" class="user-avatar" />
        </div>
1  
renchao@pashanhoo.com committed
16
        <svg-icon class="shutdown" @click.native="logout" icon-class='shutdown' />
任超 committed
17
      </div>
赵千 committed
18
    </div>
19
    <NoticeBar class="NoticeBar" :noticeList="noticeList" v-if="noticeList.length > 0" />
赵千 committed
20 21 22
  </div>
</template>
<script>
23
  import axios from 'axios'
24
  import Cookies from 'js-cookie'
25 26
  import { mapGetters } from 'vuex'
  import NoticeBar from '@/components/NoticeBar/index'
1  
renchao@pashanhoo.com committed
27
  import { getHomeNoticeList } from "@/api/home"
yangwei committed
28
  import {setToken} from "@/utils/util";
29 30 31
  export default {
    components: {
      NoticeBar
1  
renchao@pashanhoo.com committed
32
    },
33 34 35
    computed: {
      ...mapGetters(['sidebar', 'avatar', 'name']),
      baseUrl () {
36
        return window._config.baseUrl;
37 38 39 40 41 42
      },
    },
    data () {
      return {
        logo: require('../../image/logo.png'),
        noticeList: []
任超 committed
43
      }
44 45 46 47 48 49 50 51 52
    },
    created () {
      this.queryNoticeList()
    },
    mounted () {
      let that = this
      window.addEventListener('message', function (messageEvent) {
        if (messageEvent.data.update) {
          that.queryNoticeList()
任超 committed
53 54 55
        }
      })
    },
56 57
    destroyed () {
      window.removeEventListener('message')
1  
renchao@pashanhoo.com committed
58
    },
59
    methods: {
yuanbo committed
60 61 62 63
      /**
       * @description: queryNoticeList
       * @author: renchao
       */
64 65 66 67 68 69 70
      queryNoticeList () {
        getHomeNoticeList().then(res => {
          if (res.result) {
            this.noticeList = res.result.noticeList
          }
        })
      },
yuanbo committed
71 72 73 74
      /**
       * @description: logout
       * @author: renchao
       */
75
      logout () {
yangwei committed
76 77 78 79 80
        axios.post(window._config.services.management + "/management/logout").then(() => {
          setToken(undefined)
          sessionStorage.removeItem('token')
          localStorage.setItem('dj-location',window.location.href)
          window.location.href = window._config.casBaseURL + '/logout?service=' + encodeURIComponent(window.location.href);
81
        })
82 83
      },

yuanbo committed
84 85 86 87 88
      /**
       * @description: themeChange
       * @param {*} val
       * @author: renchao
       */
89 90 91 92 93 94
      themeChange (val) {
        this.$store.dispatch('app/updateTheme', val)
      },
      searchMessageCenter () {
        this.$router.push({ name: 'messagecenter' })
      },
yuanbo committed
95 96 97 98 99
      /**
       * @description: handleCommand
       * @param {*} command
       * @author: renchao
       */
100 101 102 103 104
      handleCommand (command) {
        if (command == 'a') {
          //个人中心
          this.$router.push({ name: 'personal' })
        }
赵千 committed
105 106 107 108 109
      }
    }
  }
</script>
<style lang="scss" scoped>
110 111
  .navbar-con {
    position: relative;
赵千 committed
112 113
  }

114 115 116
  .NoticeBar {
    position: absolute;
    bottom: 0;
赵千 committed
117 118
  }

119 120 121 122 123
  .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;
任超 committed
124

125 126 127 128 129 130 131 132 133 134 135
    .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;
    }
赵千 committed
136

137 138 139
    .el-dropdown-menu__item:nth-child(6) {
      border-top: 1px solid #ebeef5;
    }
赵千 committed
140

141 142 143 144
    .popper__arrow {
      top: -11px !important;
      left: 110px !important;
      transform: rotate(0deg) scale(2);
赵千 committed
145 146
    }

147 148 149 150 151
    .el-dropdown-menu__item:not(.is-disabled):hover,
    .el-dropdown-menu__item:focus {
      background: #f6f7f9;
      color: #4a4a4a;
    }
赵千 committed
152 153
  }

154 155 156 157 158 159 160
  .navbar {
    height: $headerHeight;
    overflow: hidden;
    position: relative;
    background: #fff;
    // background: linear-gradient(270deg, #148CEE 0%, #1870E3 100%); //默认颜色
    box-shadow: 0 1px 0px rgba(0, 21, 41, 0.08);
任超 committed
161 162
    display: flex;
    align-items: center;
163 164
    padding: 0 20px;
    justify-content: space-between;
任超 committed
165

166 167 168 169 170 171 172 173 174 175
    .header-logo {
      width: 300px;
    }

    .backdrop {
      flex: 1;
      width: 60%;
      background: url("../../image/backdrop.png");
      background-size: 100% 100%;
      height: $headerHeight;
任超 committed
176 177
    }

178 179 180 181
    .hamburger-container {
      line-height: 43px;
      height: 100%;
      float: left;
任超 committed
182
      cursor: pointer;
183 184 185 186 187 188
      transition: background 0.3s;
      -webkit-tap-highlight-color: transparent;

      &:hover {
        background: rgba(0, 0, 0, 0.025);
      }
任超 committed
189
    }
赵千 committed
190

191 192
    .breadcrumb-container {
      float: left;
赵千 committed
193 194
    }

195 196 197 198 199 200
    .right-menu {
      float: right;
      height: 100%;
      line-height: 50px;
      display: flex;
      align-items: center;
赵千 committed
201

202 203
      .function {
        margin: 0 15px;
赵千 committed
204 205 206
        cursor: pointer;
      }

207 208 209 210 211
      .shutdown {
        font-size: 20px;
        margin-left: 15px;
        cursor: pointer;
      }
赵千 committed
212

213 214 215 216
      .organization-item {
        margin-right: 40px;
        margin-top: -40px !important;
      }
赵千 committed
217

218 219 220 221
      .item {
        margin-right: 40px;
        margin-top: -20px;
        line-height: 18.4px;
赵千 committed
222
        cursor: pointer;
223
        position: relative;
赵千 committed
224

225 226 227 228 229 230 231 232 233
        .item-box {
          position: absolute;
          top: -5px;
          left: 3px;
          width: 100%;
          min-width: 25px;
          height: 25px;
          cursor: pointer;
          z-index: 100;
赵千 committed
234 235 236
        }
      }

237 238 239
      &:focus {
        outline: none;
      }
赵千 committed
240

241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256
      .right-menu-item {
        display: inline-block;
        font-size: 18px;
        color: #fff;
        vertical-align: text-bottom;

        &.hover-effect {
          cursor: pointer;
          transition: background 0.3s;
          display: flex;
          align-items: center;

          &:hover {
            background: rgba(0, 0, 0, 0.025);
          }
        }
任超 committed
257
      }
赵千 committed
258

259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279
      .avatar-wrapper {
        position: relative;
        display: flex;
        height: 40px;
        align-items: center;
        color: #ffffff;

        .user-avatar {
          cursor: pointer;
          width: 35px;
          height: 35px;
          border-radius: 50%;
        }

        .el-icon-caret-bottom {
          cursor: pointer;
          position: absolute;
          right: -15px;
          top: 17px;
          font-size: 12px;
        }
赵千 committed
280 281 282 283
      }
    }
  }
</style>