Navbar.vue 5.4 KB
Newer Older
sunhongwei's avatar
sunhongwei committed
1 2 3 4 5 6 7 8 9
<template>
  <div class="navbar">
    <hamburger id="hamburger-container" :is-active="sidebar.opened" class="hamburger-container" @toggleClick="toggleSideBar" />

    <breadcrumb id="breadcrumb-container" class="breadcrumb-container" v-if="!topNav"/>
    <top-nav id="topmenu-container" class="topmenu-container" v-if="topNav"/>

    <div class="right-menu">
      <template v-if="device!=='mobile'">
jiuping520's avatar
jiuping520 committed
10 11 12 13 14 15 16

        <el-badge :value="notReadTotal" class="right-menu-item">
          <el-button size="small" @click="notRead">未读消息</el-button>
        </el-badge>



sunhongwei's avatar
sunhongwei committed
17 18
        <search id="header-search" class="right-menu-item" />

jiuping520's avatar
jiuping520 committed
19

sunhongwei's avatar
sunhongwei committed
20

houjn@hikoon.cn's avatar
houjn@hikoon.cn committed
21 22 23
<!--        <el-tooltip content="文档地址" effect="dark" placement="bottom">-->
<!--          <ruo-yi-doc id="ruoyi-doc" class="right-menu-item hover-effect" />-->
<!--        </el-tooltip>-->
sunhongwei's avatar
sunhongwei committed
24 25 26 27 28 29 30 31 32

        <screenfull id="screenfull" class="right-menu-item hover-effect" />

        <el-tooltip content="布局大小" effect="dark" placement="bottom">
          <size-select id="size-select" class="right-menu-item hover-effect" />
        </el-tooltip>

      </template>

sunhongwei's avatar
sunhongwei committed
33 34 35 36
      <el-select v-model="locale" placeholder="语言" class="right-menu-item" style="width: 116px;" @change="localeChange">
        <el-option v-for="dict in langDatas" :key="dict.value" :label="dict.label" :value="dict.value"/>
      </el-select>

sunhongwei's avatar
sunhongwei committed
37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67
      <el-dropdown class="avatar-container right-menu-item hover-effect" trigger="click">
        <div class="avatar-wrapper">
          <img :src="avatar" class="user-avatar">
          <i class="el-icon-caret-bottom" />
        </div>
        <el-dropdown-menu slot="dropdown">
          <router-link to="/user/profile">
            <el-dropdown-item>个人中心</el-dropdown-item>
          </router-link>
          <el-dropdown-item @click.native="setting = true">
            <span>布局设置</span>
          </el-dropdown-item>
          <el-dropdown-item divided @click.native="logout">
            <span>退出登录</span>
          </el-dropdown-item>
        </el-dropdown-menu>
      </el-dropdown>
    </div>
  </div>
</template>

<script>
import { mapGetters } from 'vuex'
import Breadcrumb from '@/components/Breadcrumb'
import TopNav from '@/components/TopNav'
import Hamburger from '@/components/Hamburger'
import Screenfull from '@/components/Screenfull'
import SizeSelect from '@/components/SizeSelect'
import Search from '@/components/HeaderSearch'
import RuoYiGit from '@/components/RuoYi/Git'
import RuoYiDoc from '@/components/RuoYi/Doc'
sunhongwei's avatar
sunhongwei committed
68 69
import {getLocale, saveLocale} from "@/utils/db";
import {LangEnum} from "@/utils/constants";
sunhongwei's avatar
sunhongwei committed
70 71

export default {
sunhongwei's avatar
sunhongwei committed
72 73 74 75 76
  data() {
    return {
      locale: getLocale(),
      // 枚举
      langDatas: LangEnum.LANG,
jiuping520's avatar
jiuping520 committed
77
      notReadTotal:0,//要去取VUEX里面的未读数据总数,我不会,登录之后要调得到当前人未读记录总数接口放到VUEX中
sunhongwei's avatar
sunhongwei committed
78 79
    }
  },
sunhongwei's avatar
sunhongwei committed
80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116
  components: {
    Breadcrumb,
    TopNav,
    Hamburger,
    Screenfull,
    SizeSelect,
    Search,
    RuoYiGit,
    RuoYiDoc
  },
  computed: {
    ...mapGetters([
      'sidebar',
      'avatar',
      'device'
    ]),
    setting: {
      get() {
        return this.$store.state.settings.showSettings
      },
      set(val) {
        this.$store.dispatch('settings/changeSetting', {
          key: 'showSettings',
          value: val
        })
      }
    },
    topNav: {
      get() {
        return this.$store.state.settings.topNav
      }
    }
  },
  methods: {
    toggleSideBar() {
      this.$store.dispatch('app/toggleSideBar')
    },
sunhongwei's avatar
sunhongwei committed
117 118 119 120
    localeChange(value) {
      console.log(value)
      saveLocale(value)
    },
sunhongwei's avatar
sunhongwei committed
121 122 123
    async logout() {
      this.$modal.confirm('确定注销并退出系统吗?', '提示').then(() => {
        this.$store.dispatch('LogOut').then(() => {
sunhongwei's avatar
sunhongwei committed
124
          location.href = '/';
sunhongwei's avatar
sunhongwei committed
125 126
        })
      }).catch(() => {});
jiuping520's avatar
jiuping520 committed
127 128 129
    },
    notRead(){
      this.$router.push({path:'/system/internalMessage/my-internal-message',query:{'status':0}});
sunhongwei's avatar
sunhongwei committed
130 131 132 133 134 135 136 137 138 139 140 141 142
    }
  }
}
</script>

<style lang="scss" scoped>
.navbar {
  height: 50px;
  overflow: hidden;
  position: relative;
  background: #fff;
  box-shadow: 0 1px 4px rgba(0,21,41,.08);

jiuping520's avatar
jiuping520 committed
143

sunhongwei's avatar
sunhongwei committed
144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 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 222 223
  .hamburger-container {
    line-height: 46px;
    height: 100%;
    float: left;
    cursor: pointer;
    transition: background .3s;
    -webkit-tap-highlight-color:transparent;

    &:hover {
      background: rgba(0, 0, 0, .025)
    }
  }

  .breadcrumb-container {
    float: left;
  }

  .topmenu-container {
    position: absolute;
    left: 50px;
  }

  .errLog-container {
    display: inline-block;
    vertical-align: top;
  }

  .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;
      vertical-align: text-bottom;

      &.hover-effect {
        cursor: pointer;
        transition: background .3s;

        &:hover {
          background: rgba(0, 0, 0, .025)
        }
      }
    }

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

      .avatar-wrapper {
        margin-top: 5px;
        position: relative;

        .user-avatar {
          cursor: pointer;
          width: 40px;
          height: 40px;
          border-radius: 10px;
        }

        .el-icon-caret-bottom {
          cursor: pointer;
          position: absolute;
          right: -20px;
          top: 25px;
          font-size: 12px;
        }
      }
    }
  }
}
</style>