123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313 |
- <template>
- <div class="navbar">
- <hamburger id="hamburger-container" :is-active="sidebar.opened" class="hamburger-container" @toggleClick="toggleSideBar(0)" />
- <!-- <breadcrumb id="breadcrumb-container" class="breadcrumb-container" /> -->
- <!-- <SignNumArr class="SignNumArr"/> -->
- <div class="sign_box">
- <div class="sign_item" :class="{active: activeMenu.includes((item.path||item.redirect))}" v-for="(item,index) in this.sidebarRouters.filter(res => {
- return res.hidden == false || res.redirect == 'index'
- })" :key="index"
- @click="tabBtn(item)">
- <item v-if="item.meta" :icon="item.meta && item.meta.icon" :title="item.meta.title" />
- <item v-if="!item.meta" :icon="item.meta && item.meta.icon" :title="'首页'" />
- </div>
- </div>
- <div class="right-menu">
- <!-- <template v-if="device!=='mobile'">
- <search id="header-search" class="right-menu-item" />
- <el-tooltip content="源码地址" effect="dark" placement="bottom">
- <ruo-yi-git id="ruoyi-git" class="right-menu-item hover-effect" />
- </el-tooltip>
- <el-tooltip content="文档地址" effect="dark" placement="bottom">
- <ruo-yi-doc id="ruoyi-doc" class="right-menu-item hover-effect" />
- </el-tooltip>
- <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> -->
- <el-dropdown class="avatar-container right-menu-item hover-effect" trigger="click">
- <div class="avatar-wrapper">
- <img :src="avatar" class="user-avatar">
- <span></span>
- <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>
- <!-- <router-link to="/system/ucleic/index">
- <el-dropdown-item>在线人数:<span style="color: #00a8ec;">2568</span></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, mapState } from 'vuex'
- import Breadcrumb from '@/components/Breadcrumb'
- import SignNumArr from '@/components/SignNumArr'
- 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'
- import Item from '@/layout/components/Sidebar/Item'
- export default {
- data() {
- return {
- indexs: 1,
- newArr: [],
- showde:true
- }
- },
- components: {
- SignNumArr,
- Hamburger,
- Screenfull,
- SizeSelect,
- Search,
- RuoYiGit,
- RuoYiDoc,
- Item
- },
- mounted() {
- this.init()
- },
- computed: {
- ...mapGetters([
- 'sidebar',
- 'avatar',
- 'device',
- "sidebarRouters", "sidebar", "tabIndex"
- ]),
- activeMenu() {
- return this.tabIndex;
- },
- setting: {
- get() {
- return this.$store.state.settings.showSettings
- },
- set(val) {
- this.$store.dispatch('settings/changeSetting', {
- key: 'showSettings',
- value: val
- })
- },
- }
- },
- methods: {
- toggleSideBar(index) {
- this.$store.dispatch('app/toggleSideBar')
- // console.log( this.$store.dispatch('app/toggleSideBar'))
- },
- async logout() {
- this.$confirm('确定注销并退出系统吗?', '提示', {
- confirmButtonText: '确定',
- cancelButtonText: '取消',
- type: 'warning'
- }).then(() => {
- this.$store.dispatch('LogOut').then(() => {
- location.href = '/index';
- })
- })
- },
- tabBtn(item) {
- console.log(item)
- if(this.activeMenu.includes((item.path||item.redirect))){
- return
- }
- this.$store.dispatch('app/toggleSideBartwo')
- if (item.redirect == 'index') {
- if(this.$route.path!=='/index'){
- this.$router.push({
- path: '/index'
- })
- }
- this.$store.dispatch('TabFn', item.redirect)
- return
- }
- this.$store.dispatch('TabFn', item.path)
- this.showde = true
- },
- init() {
- const route = this.$route;
- const {
- meta,
- path
- } = route;
- // if set path, the sidebar will highlight the path you set
- console.log(route)
- if (meta.activeMenu) {
- this.$store.dispatch('TabFn', meta.activeMenu)
- }
- this.$store.dispatch('TabFn', path)
- }
- }
- }
- </script>
- <style lang="scss" scoped>
- .navbar {
- height: 50px;
- overflow: hidden;
- position: relative;
- background-color: #1890ff ;
- box-shadow: 0 1px 4px rgba(0,21,41,.08);
- .SignNumArr{
- float: left;
- }
- .hamburger-container {
- line-height: 46px;
- height: 100%;
- float: left;
- cursor: pointer;
- transition: background .3s;
- color: #fff;
- -webkit-tap-highlight-color:transparent;
- svg{
- color: #fff!important;
- }
- &:hover {
- background: rgba(0, 0, 0, .025)
- }
- }
- .breadcrumb-container {
- float: left;
- }
- .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: 50%;
- }
- .el-icon-caret-bottom {
- cursor: pointer;
- position: absolute;
- right: -20px;
- top: 25px;
- color: #fff;
- font-size: 12px;
- }
- }
- }
- }
- }
- .sign_box {
- // padding-left: 12px;
- width: calc(100% - 160px);
- overflow-x: scroll;
- float: left;
- white-space: nowrap;
- .sign_item {
- cursor: pointer;
- float: left;
- display: inline-table;
- height: 50px;
- text-align: center;
- line-height: 50px;
- position: relative;
- width: 143px;
- box-sizing: border-box;
- color: #fff;
- .img {
- width: 153px;
- height: 48px;
- position: absolute;
- left: 0;
- bottom: 0;
- }
- .icon {
- position: relative;
- z-index: 1;
- width: 16px;
- height: 16px;
- margin-right: 8px;
- }
- span {
- position: relative;
- z-index: 1;
- color: #fff !important;
- font-size: 16px !important;
- }
- svg {
- color: #fff !important;
- z-index: 2;
- line-height: 1;
- margin-right: 5px;
- }
- }
- }
- .active{
- background-color: #367FA8!important;
- }
- </style>
|