2021-03-03 15:06:52 +08:00
|
|
|
|
<template>
|
2021-05-19 14:58:21 +08:00
|
|
|
|
<div class="top-nav" :style="{'background-color': '#f1f3f8'}">
|
2021-06-24 11:08:28 +08:00
|
|
|
|
<div v-loading="!axiosFinished" class="log">
|
2021-06-08 16:03:49 +08:00
|
|
|
|
<!-- <img v-if="!logoUrl" src="@/assets/DataEase-color.png" width="140" alt="" style="padding-top: 10px;">-->
|
2021-06-24 11:08:28 +08:00
|
|
|
|
<svg-icon v-if="!logoUrl && axiosFinished" icon-class="DataEase" custom-class="top-nav-logo-icon" />
|
2021-06-24 16:21:39 +08:00
|
|
|
|
<img v-if="logoUrl && axiosFinished" :src="logoUrl" width="140" alt="" style="padding-top: 10px;">
|
2021-04-21 12:03:11 +08:00
|
|
|
|
</div>
|
2021-03-03 15:06:52 +08:00
|
|
|
|
<el-menu
|
2021-03-08 11:09:46 +08:00
|
|
|
|
:active-text-color="variables.topMenuActiveText"
|
2021-03-03 15:06:52 +08:00
|
|
|
|
:default-active="activeMenu"
|
|
|
|
|
mode="horizontal"
|
2021-06-15 18:52:33 +08:00
|
|
|
|
:style="{'background-color': '#f1f3f8', 'margin-left': '260px', 'position': 'absolute'}"
|
2021-03-03 15:06:52 +08:00
|
|
|
|
@select="handleSelect"
|
|
|
|
|
>
|
|
|
|
|
<div v-for="item in permission_routes" :key="item.path" class="nav-item">
|
|
|
|
|
<app-link :to="resolvePath(item)">
|
|
|
|
|
<el-menu-item
|
|
|
|
|
v-if="!item.hidden"
|
|
|
|
|
:index="item.path"
|
|
|
|
|
>{{ item.meta ? item.meta.title : item.children[0].meta.title }}</el-menu-item>
|
|
|
|
|
</app-link>
|
|
|
|
|
</div>
|
|
|
|
|
</el-menu>
|
|
|
|
|
|
|
|
|
|
<div class="right-menu">
|
|
|
|
|
<template>
|
2021-05-17 17:23:29 +08:00
|
|
|
|
<!-- <el-tooltip content="项目文档" effect="dark" placement="bottom">-->
|
|
|
|
|
<!-- <doc class="right-menu-item hover-effect" />-->
|
|
|
|
|
<!-- </el-tooltip>-->
|
2021-03-03 15:06:52 +08:00
|
|
|
|
|
2021-05-17 17:23:29 +08:00
|
|
|
|
<!-- <el-tooltip content="全屏缩放" effect="dark" placement="bottom">-->
|
|
|
|
|
<!-- <screenfull id="screenfull" class="right-menu-item hover-effect" />-->
|
|
|
|
|
<!-- </el-tooltip>-->
|
2021-03-03 15:06:52 +08:00
|
|
|
|
|
2021-03-08 11:57:18 +08:00
|
|
|
|
<!-- <el-tooltip :content="$t('navbar.size')" effect="dark" placement="bottom">
|
2021-03-03 15:06:52 +08:00
|
|
|
|
<size-select id="size-select" class="right-menu-item hover-effect" />
|
2021-03-08 11:57:18 +08:00
|
|
|
|
</el-tooltip> -->
|
2021-07-06 15:24:34 +08:00
|
|
|
|
<notification class="right-menu-item hover-effect" />
|
2021-05-18 15:46:14 +08:00
|
|
|
|
<lang-select class="right-menu-item hover-effect" />
|
2021-06-17 11:02:54 +08:00
|
|
|
|
<div style="height: 100%;padding: 0 8px;" class="right-menu-item hover-effect">
|
2021-06-24 15:20:41 +08:00
|
|
|
|
<a href="https://dataease.io/docs/" target="_blank" style="display: flex;height: 100%;width: 100%;justify-content: center;align-items: center;">
|
2021-06-17 11:02:54 +08:00
|
|
|
|
<svg-icon icon-class="docs" />
|
|
|
|
|
</a>
|
|
|
|
|
</div>
|
2021-03-03 15:06:52 +08:00
|
|
|
|
</template>
|
2021-05-13 16:00:15 +08:00
|
|
|
|
|
2021-05-17 17:23:29 +08:00
|
|
|
|
<el-dropdown class="top-dropdown" style="display: flex;align-items: center;">
|
2021-05-17 19:11:07 +08:00
|
|
|
|
<span class="el-dropdown-link" style="font-size: 14px;">
|
2021-05-13 16:00:15 +08:00
|
|
|
|
{{ name }}<i class="el-icon-arrow-down el-icon--right" />
|
|
|
|
|
</span>
|
|
|
|
|
<el-dropdown-menu slot="dropdown">
|
|
|
|
|
<router-link to="/person-info/index">
|
2021-05-18 12:40:47 +08:00
|
|
|
|
<el-dropdown-item>{{ $t('commons.personal_info') }}</el-dropdown-item>
|
2021-05-13 16:00:15 +08:00
|
|
|
|
</router-link>
|
|
|
|
|
<router-link to="/person-pwd/index">
|
2021-05-28 17:48:05 +08:00
|
|
|
|
<el-dropdown-item>{{ $t('user.change_password') }}</el-dropdown-item>
|
2021-05-13 16:00:15 +08:00
|
|
|
|
</router-link>
|
2021-06-17 11:02:54 +08:00
|
|
|
|
<!-- <a href="https://de-docs.fit2cloud.com/" target="_blank">-->
|
|
|
|
|
<!-- <el-dropdown-item>{{ $t('commons.help_documentation') }} </el-dropdown-item>-->
|
|
|
|
|
<!-- </a>-->
|
2021-05-19 11:42:09 +08:00
|
|
|
|
<router-link to="/about/index">
|
2021-05-18 12:45:45 +08:00
|
|
|
|
<el-dropdown-item>{{ $t('commons.about_us') }}</el-dropdown-item>
|
2021-05-18 12:23:21 +08:00
|
|
|
|
</router-link>
|
2021-05-13 16:00:15 +08:00
|
|
|
|
<el-dropdown-item divided @click.native="logout">
|
2021-05-18 12:40:47 +08:00
|
|
|
|
<span style="display:block;">{{ $t('commons.exit_system') }}</span>
|
2021-05-13 16:00:15 +08:00
|
|
|
|
</el-dropdown-item>
|
|
|
|
|
</el-dropdown-menu>
|
|
|
|
|
</el-dropdown>
|
2021-03-03 15:06:52 +08:00
|
|
|
|
</div>
|
|
|
|
|
</div>
|
|
|
|
|
</template>
|
|
|
|
|
|
|
|
|
|
<script>
|
|
|
|
|
import { mapGetters } from 'vuex'
|
|
|
|
|
import AppLink from './Sidebar/Link'
|
|
|
|
|
import variables from '@/styles/variables.scss'
|
|
|
|
|
import { isExternal } from '@/utils/validate'
|
2021-07-02 19:19:38 +08:00
|
|
|
|
import Notification from '@/components/Notification'
|
2021-05-17 15:18:20 +08:00
|
|
|
|
// import Screenfull from '@/components/Screenfull'
|
2021-03-08 11:57:18 +08:00
|
|
|
|
// import SizeSelect from '@/components/SizeSelect'
|
2021-05-18 15:46:14 +08:00
|
|
|
|
import LangSelect from '@/components/LangSelect'
|
2021-05-12 16:19:41 +08:00
|
|
|
|
import { getSysUI } from '@/utils/auth'
|
2021-03-03 15:06:52 +08:00
|
|
|
|
export default {
|
|
|
|
|
name: 'Topbar',
|
|
|
|
|
components: {
|
2021-05-18 15:46:14 +08:00
|
|
|
|
AppLink,
|
2021-05-17 15:18:20 +08:00
|
|
|
|
// Screenfull,
|
2021-03-08 11:57:18 +08:00
|
|
|
|
// SizeSelect,
|
2021-07-02 19:19:38 +08:00
|
|
|
|
Notification,
|
2021-05-18 15:46:14 +08:00
|
|
|
|
LangSelect
|
2021-05-17 15:18:20 +08:00
|
|
|
|
// Doc
|
2021-03-03 15:06:52 +08:00
|
|
|
|
},
|
|
|
|
|
data() {
|
|
|
|
|
return {
|
2021-05-12 16:19:41 +08:00
|
|
|
|
uiInfo: null,
|
2021-06-24 11:08:28 +08:00
|
|
|
|
logoUrl: null,
|
|
|
|
|
axiosFinished: false
|
2021-03-03 15:06:52 +08:00
|
|
|
|
}
|
|
|
|
|
},
|
2021-05-12 16:19:41 +08:00
|
|
|
|
|
2021-03-03 15:06:52 +08:00
|
|
|
|
computed: {
|
2021-03-08 11:09:46 +08:00
|
|
|
|
theme() {
|
|
|
|
|
return this.$store.state.settings.theme
|
|
|
|
|
},
|
2021-03-03 15:06:52 +08:00
|
|
|
|
activeMenu() {
|
|
|
|
|
const route = this.$route
|
|
|
|
|
const { meta, path } = route
|
|
|
|
|
// if set path, the sidebar will highlight the path you set
|
|
|
|
|
if (meta.activeMenu) {
|
2021-06-24 18:34:05 +08:00
|
|
|
|
// return meta.activeMenu
|
2021-03-03 15:06:52 +08:00
|
|
|
|
}
|
|
|
|
|
// 如果是首页,首页高亮
|
2021-04-22 17:59:16 +08:00
|
|
|
|
if (path === '/panel') {
|
2021-03-03 15:06:52 +08:00
|
|
|
|
return '/'
|
|
|
|
|
}
|
|
|
|
|
// 如果不是首页,高亮一级菜单
|
|
|
|
|
const activeMenu = '/' + path.split('/')[1]
|
|
|
|
|
return activeMenu
|
|
|
|
|
},
|
|
|
|
|
variables() {
|
|
|
|
|
return variables
|
|
|
|
|
},
|
|
|
|
|
sidebar() {
|
|
|
|
|
return this.$store.state.app.sidebar
|
|
|
|
|
},
|
|
|
|
|
...mapGetters([
|
|
|
|
|
'avatar',
|
2021-05-13 16:00:15 +08:00
|
|
|
|
'permission_routes',
|
|
|
|
|
'name'
|
2021-03-03 15:06:52 +08:00
|
|
|
|
])
|
|
|
|
|
},
|
2021-03-04 14:58:52 +08:00
|
|
|
|
|
2021-03-03 15:06:52 +08:00
|
|
|
|
mounted() {
|
|
|
|
|
this.initCurrentRoutes()
|
|
|
|
|
},
|
2021-05-12 16:19:41 +08:00
|
|
|
|
created() {
|
|
|
|
|
this.$store.dispatch('user/getUI').then(() => {
|
|
|
|
|
this.uiInfo = getSysUI()
|
|
|
|
|
if (this.uiInfo['ui.logo'] && this.uiInfo['ui.logo'].paramValue) {
|
|
|
|
|
this.logoUrl = '/system/ui/image/' + this.uiInfo['ui.logo'].paramValue
|
|
|
|
|
}
|
2021-06-24 11:08:28 +08:00
|
|
|
|
this.axiosFinished = true
|
2021-05-12 16:19:41 +08:00
|
|
|
|
})
|
|
|
|
|
},
|
2021-03-03 15:06:52 +08:00
|
|
|
|
methods: {
|
|
|
|
|
// 通过当前路径找到二级菜单对应项,存到store,用来渲染左侧菜单
|
|
|
|
|
initCurrentRoutes() {
|
|
|
|
|
const { path } = this.$route
|
|
|
|
|
let route = this.permission_routes.find(
|
|
|
|
|
item => item.path === '/' + path.split('/')[1]
|
|
|
|
|
)
|
|
|
|
|
// 如果找不到这个路由,说明是首页
|
|
|
|
|
if (!route) {
|
|
|
|
|
route = this.permission_routes.find(item => item.path === '/')
|
|
|
|
|
}
|
|
|
|
|
this.$store.commit('permission/SET_CURRENT_ROUTES', route)
|
|
|
|
|
this.setSidebarHide(route)
|
|
|
|
|
},
|
|
|
|
|
// 判断该路由是否只有一个子项或者没有子项,如果是,则在一级菜单添加跳转路由
|
|
|
|
|
isOnlyOneChild(item) {
|
|
|
|
|
if (item.children && item.children.length === 1) {
|
|
|
|
|
return true
|
|
|
|
|
}
|
|
|
|
|
return false
|
|
|
|
|
},
|
|
|
|
|
resolvePath(item) {
|
|
|
|
|
// 如果是个完成的url直接返回
|
|
|
|
|
if (isExternal(item.path)) {
|
|
|
|
|
return item.path
|
|
|
|
|
}
|
|
|
|
|
// 如果是首页,就返回重定向路由
|
|
|
|
|
if (item.path === '/') {
|
|
|
|
|
const path = item.redirect
|
|
|
|
|
return path
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// 如果有子项,默认跳转第一个子项路由
|
|
|
|
|
let path = ''
|
|
|
|
|
/**
|
|
|
|
|
* item 路由子项
|
|
|
|
|
* parent 路由父项
|
|
|
|
|
*/
|
|
|
|
|
const getDefaultPath = (item, parent) => {
|
|
|
|
|
// 如果path是个外部链接(不建议),直接返回链接,存在个问题:如果是外部链接点击跳转后当前页内容还是上一个路由内容
|
|
|
|
|
if (isExternal(item.path)) {
|
|
|
|
|
path = item.path
|
|
|
|
|
return
|
|
|
|
|
}
|
|
|
|
|
// 第一次需要父项路由拼接,所以只是第一个传parent
|
|
|
|
|
if (parent) {
|
|
|
|
|
path += (parent.path + '/' + item.path)
|
|
|
|
|
} else {
|
|
|
|
|
path += ('/' + item.path)
|
|
|
|
|
}
|
|
|
|
|
// 如果还有子项,继续递归
|
|
|
|
|
if (item.children) {
|
|
|
|
|
getDefaultPath(item.children[0])
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (item.children) {
|
|
|
|
|
getDefaultPath(item.children[0], item)
|
|
|
|
|
return path
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return item.path
|
|
|
|
|
},
|
|
|
|
|
handleSelect(key, keyPath) {
|
|
|
|
|
// 把选中路由的子路由保存store
|
|
|
|
|
const route = this.permission_routes.find(item => item.path === key)
|
|
|
|
|
this.$store.commit('permission/SET_CURRENT_ROUTES', route)
|
|
|
|
|
this.setSidebarHide(route)
|
|
|
|
|
},
|
|
|
|
|
// 设置侧边栏的显示和隐藏
|
|
|
|
|
setSidebarHide(route) {
|
2021-04-29 15:38:03 +08:00
|
|
|
|
// if (!route.children || route.children.length === 1) {
|
2021-06-17 11:08:04 +08:00
|
|
|
|
if (route.name !== 'system' && (!route.children || this.showChildLength(route) === 1)) {
|
2021-03-03 15:06:52 +08:00
|
|
|
|
this.$store.dispatch('app/toggleSideBarHide', true)
|
|
|
|
|
} else {
|
|
|
|
|
this.$store.dispatch('app/toggleSideBarHide', false)
|
|
|
|
|
}
|
|
|
|
|
},
|
2021-04-29 15:38:03 +08:00
|
|
|
|
// 获取非隐藏子路由的个数
|
|
|
|
|
showChildLength(route) {
|
|
|
|
|
if (!route || !route.children) {
|
|
|
|
|
return 0
|
|
|
|
|
}
|
|
|
|
|
return route.children.filter(kid => !kid.hidden).length
|
|
|
|
|
},
|
2021-03-03 15:06:52 +08:00
|
|
|
|
async logout() {
|
|
|
|
|
await this.$store.dispatch('user/logout')
|
|
|
|
|
this.$router.push(`/login?redirect=${this.$route.fullPath}`)
|
|
|
|
|
}
|
2021-03-04 14:58:52 +08:00
|
|
|
|
|
2021-03-03 15:06:52 +08:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
</script>
|
|
|
|
|
<style lang="scss" scoped>
|
2021-05-13 16:00:15 +08:00
|
|
|
|
.el-dropdown-link {
|
|
|
|
|
cursor: pointer;
|
2021-05-19 14:58:21 +08:00
|
|
|
|
color: #1e212a;
|
2021-05-13 16:00:15 +08:00
|
|
|
|
}
|
|
|
|
|
.el-icon-arrow-down {
|
|
|
|
|
font-size: 12px;
|
|
|
|
|
}
|
2021-03-03 15:06:52 +08:00
|
|
|
|
|
2021-05-13 16:00:15 +08:00
|
|
|
|
.top-dropdown {
|
|
|
|
|
display: inline-block;
|
|
|
|
|
padding: 10px 8px;
|
|
|
|
|
height: 100%;
|
|
|
|
|
font-size: 16px;
|
2021-05-19 14:58:21 +08:00
|
|
|
|
color: #1e212a;
|
2021-05-13 16:00:15 +08:00
|
|
|
|
vertical-align: text-bottom;
|
2021-05-17 17:23:29 +08:00
|
|
|
|
margin-right: 10px;
|
2021-05-13 16:00:15 +08:00
|
|
|
|
}
|
2021-03-03 15:06:52 +08:00
|
|
|
|
</style>
|