You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

191 lines
7.0 KiB

2 years ago
<template>
<div>
<header class="navbar navbar-expand-md d-print-none">
<div class="container-xl">
2 years ago
<button v-show="$store.state.app.device === 'mobile'" :aria-expanded="isShowMenuMobile" class="navbar-toggler" @click="isShowMenuMobile = !isShowMenuMobile">
2 years ago
<span class="navbar-toggler-icon" />
2 years ago
</button>
<div class="navbar-brand navbar-brand-autodark d-none-navbar-horizontal pe-0 pe-md-3">
<router-link to="/">
2 years ago
<img :src="require('@/assets/title.png')" style="height: 20px;filter: drop-shadow(0 2px 4px #00000088)" alt="">
2 years ago
</router-link>
</div>
<div class="navbar-nav flex-row order-md-last">
<div class="d-none d-md-flex">
2 years ago
<template v-if="isFullscreen">
<a class="nav-link px-0 fullscreen" @click="fullscreen">
<svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="icon">
2 years ago
<path stroke-width="2" d="M 4 8 l 4 0 l 0 -4 M 16 4 l 0 4 l 4 0 M 20 16 l -4 0 l 0 4 M 8 20 l 0 -4 l -4 0" />
2 years ago
</svg>
</a>
</template>
<template v-else>
<a class="nav-link px-0 fullscreen" @click="fullscreen">
<svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="icon">
2 years ago
<path stroke-width="2" d="M 4 8 l 0 -4 l 4 0 M 16 4 l 4 0 l 0 4 M 20 16 l 0 4 l -4 0 M 8 20 l -4 0 l 0 -4" />
2 years ago
</svg>
</a>
</template>
<div class="nav-item d-md-flex">
2 years ago
<theme-picker class="nav-link" />
2 years ago
</div>
2 years ago
<div class="nav-item d-none d-md-flex me-3">
<a class="nav-link px-0" data-bs-toggle="dropdown" tabindex="-1" aria-label="Show notifications">
2 years ago
<svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="icon"><path stroke="none" d="M0 0h24v24H0z" fill="none" /><path d="M10 5a2 2 0 1 1 4 0a7 7 0 0 1 4 6v3a4 4 0 0 0 2 3h-16a4 4 0 0 0 2 -3v-3a7 7 0 0 1 4 -6" /><path d="M9 17v1a3 3 0 0 0 6 0v-1" /></svg>
<span class="badge bg-red" />
2 years ago
</a>
</div>
</div>
<div class="nav-item">
2 years ago
<el-dropdown @command="userCommandHandle">
2 years ago
<a class="nav-link d-flex lh-1 text-reset p-0" aria-label="Open user menu">
2 years ago
<img class="avatar avatar-sm" style="" src="@/assets/face.jpg" alt="">
2 years ago
<div class="d-none d-xl-block ps-2">
<div>{{ name }}</div>
2 years ago
<div class="mt-1 small" style="color: #eee;">{{ (department && department.name) ? department.name : '暂无部门' }}</div>
2 years ago
</div>
</a>
<el-dropdown-menu slot="dropdown" size="mini">
2 years ago
<el-dropdown-item command="info">
<SvgIcon icon-class="user" />
2 years ago
<span style="padding-left: 8px;">用户信息</span>
</el-dropdown-item>
2 years ago
<el-dropdown-item command="password">
<SvgIcon icon-class="password"/>
2 years ago
<span style="padding-left: 8px;">修改密码</span>
</el-dropdown-item>
2 years ago
<el-dropdown-item divided command="logout">
<SvgIcon icon-class="logout" />
2 years ago
<span style="padding-left: 8px;">退出</span>
</el-dropdown-item>
</el-dropdown-menu>
</el-dropdown>
2 years ago
</div>
</div>
</div>
</header>
<header class="navbar-expand-md">
2 years ago
<div id="navbar-menu" class="navbar-collapse" v-if="$store.state.app.device === 'desktop'">
2 years ago
<el-menu
style="width: 100%;padding: 0 10px;"
:text-color="variables.menuText"
:background-color="variables.menuBg"
:active-text-color="variables.menuActiveText"
:default-active="activeMenu"
mode="horizontal"
>
<Item v-for="(item, index) in permission_routes" :key="item.key" :item="item" :base-path="item.path" />
2 years ago
</el-menu>
</div>
2 years ago
<div id="navbar-menu-mobile" class="navbar-collapse collapse" v-else>
<transition name="fade-transform-y">
<div class="navbar" v-show="isShowMenuMobile">
<div class="container-xl">
<div class="row flex-fill align-items-center">
<el-menu
unique-opened
style="width: 100%;padding: 0 10px;"
:text-color="variables.menuText"
:background-color="variables.menuBg"
:active-text-color="variables.menuActiveText"
:default-active="activeMenu"
>
<Item v-for="(item, index) in permission_routes" :key="item.key" :item="item" :base-path="item.path" />
</el-menu>
</div>
</div>
</div>
</transition>
</div>
2 years ago
</header>
</div>
</template>
<script>
2 years ago
import variables from '@/styles/variables.scss'
2 years ago
import { mapGetters } from 'vuex'
2 years ago
import Item from './Item.vue'
2 years ago
import SvgIcon from '@/components/SvgIcon/index.vue'
import ThemePicker from '@/components/ThemePicker/index.vue'
2 years ago
export default {
components: {
2 years ago
ThemePicker,
Item,
SvgIcon
2 years ago
},
2 years ago
data() {
2 years ago
return {
2 years ago
isFullscreen: false,
isShowMenuMobile: true,
2 years ago
}
},
computed: {
2 years ago
variables() {
2 years ago
return variables
},
...mapGetters([
'sidebar',
'avatar',
'name',
'permission_routes',
2 years ago
'department'
2 years ago
]),
2 years ago
activeMenu() {
const route = this.$route
const {
meta,
path
} = route
// if set path, the sidebar will highlight the path you set
if (meta.activeMenu) {
return meta.activeMenu
}
return path
2 years ago
}
},
created() {
},
mounted() {
document.addEventListener('fullscreenchange', this.handleFullscreen)
},
beforeDestroy() {
document.removeEventListener('fullscreenchange', this.handleFullscreen)
2 years ago
},
methods: {
2 years ago
handleFullscreen() {
2 years ago
this.isFullscreen = document.fullscreenElement !== null
},
2 years ago
fullscreen() {
2 years ago
if (!document.fullscreenElement) {
// 请求全屏
document.documentElement.requestFullscreen()
} else {
// 退出全屏
document.exitFullscreen()
}
2 years ago
},
2 years ago
async userCommandHandle (command) {
switch (command){
case "logout":
await this.logout();
break;
}
},
2 years ago
async logout() {
await this.$store.dispatch('user/logout')
2 years ago
await this.$store.commit('permission/SET_ROUTES',[])
2 years ago
this.$router.push(`/login?redirect=${this.$route.fullPath}`)
}
}
}
</script>
<style lang="scss" scoped>
2 years ago
@import url('~@/styles/navbar.scss');
2 years ago
</style>