Navbar.vue 7.46 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'">
dragondean@qq.com's avatar
dragondean@qq.com committed
10
        <router-link class="right-menu-item" to="/chat/chat">捷哥</router-link>
11 12 13
        <div class="right-menu-item">
          <el-image style="width: 22px;height: 22px;cursor: pointer;" :src="helpIcon" @click="tohelp"></el-image>
        </div>
dcy's avatar
dcy committed
14
        <el-badge :value="matterNum !== 0 ? matterNum : '' " class="right-menu-item badge">
15
         <div @click="$router.push('/task/todo')" style="font-size: 28px; color: #cccccc;cursor: pointer;" class="el-icon-postcard"></div>
dcy's avatar
dcy committed
16
        </el-badge>
17 18


dcy's avatar
dcy committed
19
        <el-badge :value="notMessage !== 0 ? notMessage : '' " class="right-menu-item badge">
dcy's avatar
dcy committed
20
         <el-image style="width: 22px;height: 20px;cursor: pointer;" :src="unreadMessage" @click="notRead"></el-image>
jiuping520's avatar
jiuping520 committed
21 22 23 24
        </el-badge>



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

jiuping520's avatar
jiuping520 committed
27

sunhongwei's avatar
sunhongwei committed
28

Marcus's avatar
Marcus committed
29
<!--        <el-tooltip :content="$t('文档地址')" effect="dark" placement="bottom">-->
houjn@hikoon.cn's avatar
houjn@hikoon.cn committed
30 31
<!--          <ruo-yi-doc id="ruoyi-doc" class="right-menu-item hover-effect" />-->
<!--        </el-tooltip>-->
sunhongwei's avatar
sunhongwei committed
32 33 34

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

dragondean@qq.com's avatar
dragondean@qq.com committed
35
        <el-tooltip :content="$t('布局大小')" effect="dark" placement="bottom">
sunhongwei's avatar
sunhongwei committed
36 37 38 39 40
          <size-select id="size-select" class="right-menu-item hover-effect" />
        </el-tooltip>

      </template>

Marcus's avatar
Marcus committed
41
      <!-- <el-select v-model="locale" :placeholder="$t('语言')" class="right-menu-item select-nav"  @change="localeChange">
sunhongwei's avatar
sunhongwei committed
42
        <el-option v-for="dict in langDatas" :key="dict.value" :label="dict.label" :value="dict.value"/>
dragondean@qq.com's avatar
dragondean@qq.com committed
43 44 45
      </el-select> -->

      <dict-selector :type="DICT_TYPE.SYSTEM_LOCALE" v-model="lang" defaultable class="right-menu-item select-nav" />
sunhongwei's avatar
sunhongwei committed
46

sunhongwei's avatar
sunhongwei committed
47
      <el-dropdown class="avatar-container right-menu-item hover-effect" trigger="click">
48

dragondean@qq.com's avatar
dragondean@qq.com committed
49 50 51
        <div class="avatar-wrapper flex-center">
          {{$store.getters.name}}
          <img :src="avatar" class="user-avatar ml-10">
sunhongwei's avatar
sunhongwei committed
52 53 54 55
          <i class="el-icon-caret-bottom" />
        </div>
        <el-dropdown-menu slot="dropdown">
          <router-link to="/user/profile">
dragondean@qq.com's avatar
dragondean@qq.com committed
56
            <el-dropdown-item>{{$t('个人中心')}}</el-dropdown-item>
sunhongwei's avatar
sunhongwei committed
57 58
          </router-link>
          <el-dropdown-item @click.native="setting = true">
Marcus's avatar
Marcus committed
59
            <span>{{ $t('布局设置') }}</span>
sunhongwei's avatar
sunhongwei committed
60 61
          </el-dropdown-item>
          <el-dropdown-item divided @click.native="logout">
Marcus's avatar
Marcus committed
62
            <span>{{ $t('退出登录') }}</span>
sunhongwei's avatar
sunhongwei committed
63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79
          </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
80
import {getLocale, saveLocale} from "@/utils/db";
dcy's avatar
dcy committed
81
import unreadMessage from  "@/assets/images/unread-message.png"
82
import helpIcon from  "@/assets/images/help.png"
dragondean@qq.com's avatar
dragondean@qq.com committed
83
import i18n from '@/i18n'
sunhongwei's avatar
sunhongwei committed
84
export default {
sunhongwei's avatar
sunhongwei committed
85 86
  data() {
    return {
dcy's avatar
dcy committed
87
      unreadMessage,
88
      helpIcon,
89
      // locale: getLocale(),
sunhongwei's avatar
sunhongwei committed
90
      // 枚举
dragondean@qq.com's avatar
dragondean@qq.com committed
91
      // langDatas: LangEnum.LANG,
jiuping520's avatar
jiuping520 committed
92
      notReadTotal:0,//要去取VUEX里面的未读数据总数,我不会,登录之后要调得到当前人未读记录总数接口放到VUEX中
dragondean@qq.com's avatar
dragondean@qq.com committed
93
      lang: i18n.locale, // 当前语言
sunhongwei's avatar
sunhongwei committed
94 95
    }
  },
dcy's avatar
dcy committed
96
  created() {
97 98 99 100 101 102
    // 未避免频繁内存溢出,减少请求记录感染,开发的时候不轮询消息
    if(process.env.NODE_ENV != 'development'){
      setInterval(() => {
        this.updateMessage()
      }, 10000)
    }
103
    this.updateMessage()
104

dragondean@qq.com's avatar
dragondean@qq.com committed
105
  },
sunhongwei's avatar
sunhongwei committed
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 132 133 134 135 136
  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
      }
dcy's avatar
dcy committed
137 138 139
    },
    notMessage(){
      return this.$store.state.user.notMessage
dcy's avatar
dcy committed
140 141 142
    },
    matterNum(){
      return this.$store.state.user.matterNum
sunhongwei's avatar
sunhongwei committed
143 144
    }
  },
dragondean@qq.com's avatar
dragondean@qq.com committed
145 146 147 148 149 150 151
  watch:{
    lang(val){
      console.log('切换了语言', val)
      this.$i18n.locale = val
      saveLocale(val)
    }
  },
sunhongwei's avatar
sunhongwei committed
152
  methods: {
153 154 155 156
    updateMessage(){
      this.$store.dispatch('getNotMessage');
      this.$store.dispatch('getToDoList');
    },
sunhongwei's avatar
sunhongwei committed
157 158 159
    toggleSideBar() {
      this.$store.dispatch('app/toggleSideBar')
    },
dragondean@qq.com's avatar
dragondean@qq.com committed
160
    /* localeChange(value) {
sunhongwei's avatar
sunhongwei committed
161 162
      console.log(value)
      saveLocale(value)
dragondean@qq.com's avatar
dragondean@qq.com committed
163
    }, */
sunhongwei's avatar
sunhongwei committed
164 165 166
    async logout() {
      this.$modal.confirm('确定注销并退出系统吗?', '提示').then(() => {
        this.$store.dispatch('LogOut').then(() => {
sunhongwei's avatar
sunhongwei committed
167
          location.href = '/';
sunhongwei's avatar
sunhongwei committed
168 169
        })
      }).catch(() => {});
jiuping520's avatar
jiuping520 committed
170 171
    },
    notRead(){
dcy's avatar
dcy committed
172
      this.$router.push({path:'/system/internalMessage/my-internal-message',query:{status:'0'}});
173 174 175
    },
    tohelp(){
      this.$router.push({path:'/operation_manage/info'});
sunhongwei's avatar
sunhongwei committed
176 177 178 179 180 181 182 183 184 185 186 187 188
    }
  }
}
</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
189

sunhongwei's avatar
sunhongwei committed
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 224
  .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;
    }
dcy's avatar
dcy committed
225 226 227 228
    ::v-deep.el-badge{
     .el-badge__content{
       top: 13px;
       right:15px;
dcy's avatar
dcy committed
229
       height: 20px;
dcy's avatar
dcy committed
230 231
     }
    }
sunhongwei's avatar
sunhongwei committed
232 233 234 235 236 237 238
    .right-menu-item {
      display: inline-block;
      padding: 0 8px;
      height: 100%;
      font-size: 18px;
      color: #5a5e66;
      vertical-align: text-bottom;
239
      margin-right: 15px;
sunhongwei's avatar
sunhongwei committed
240 241 242 243 244 245 246 247 248
      &.hover-effect {
        cursor: pointer;
        transition: background .3s;

        &:hover {
          background: rgba(0, 0, 0, .025)
        }
      }
    }
dcy's avatar
dcy committed
249 250 251 252 253 254 255 256 257 258 259
   ::v-deep.select-nav{
     width: 110px;
     height: 32px;
     vertical-align: top;
     .el-input__inner{
       font-size: 14px;
       font-family: PingFang SC;
       font-weight: 400;
       color: #D9D9D9;
     }
   }
sunhongwei's avatar
sunhongwei committed
260 261 262 263 264 265 266 267 268
    .avatar-container {
      margin-right: 30px;

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

        .user-avatar {
          cursor: pointer;
dcy's avatar
dcy committed
269 270 271 272
          width: 32px;
          height: 32px;
          border-radius: 50%;
          vertical-align: sub;
sunhongwei's avatar
sunhongwei committed
273 274 275 276 277
        }

        .el-icon-caret-bottom {
          cursor: pointer;
          position: absolute;
dcy's avatar
dcy committed
278 279 280
          right: -16px;
          top: 10px;
          font-size: 14px;
sunhongwei's avatar
sunhongwei committed
281 282 283 284 285 286
        }
      }
    }
  }
}
</style>