Browse Source

删除不必要文件

master
刘力 3 years ago
parent
commit
5c484033d8
  1. 2
      src/components/Breadcrumb/index.vue
  2. 165
      src/layout/components/Topbar.vue

2
src/components/Breadcrumb/index.vue

@ -20,7 +20,6 @@ export default {
}, },
watch: { watch: {
$route(route) { $route(route) {
// if you go to the redirect page, do not update the breadcrumbs
if (route.path.startsWith('/redirect/')) { if (route.path.startsWith('/redirect/')) {
return return
} }
@ -32,7 +31,6 @@ export default {
}, },
methods: { methods: {
getBreadcrumb() { getBreadcrumb() {
// only show routes with meta.title
let matched = this.$route.matched.filter(item => item.meta && item.meta.title) let matched = this.$route.matched.filter(item => item.meta && item.meta.title)
const first = matched[0] const first = matched[0]

165
src/layout/components/Topbar.vue

@ -1,165 +0,0 @@
<template>
<div class="navmenu">
<el-menu :active-text-color="variables.menuActiveText" :default-active="activeMenu" mode="horizontal" @select="handleSelect">
<div v-for="item in routes" :key="item.path" class="navmenu">
<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>
</template>
<script>
import { mapGetters } from 'vuex'
import AppLink from './Sidebar/Link'
import variables from '@/assets/styles/variables.scss'
import { isExternal } from '@/utils/validate'
export default {
name: 'Topbar',
components: {
AppLink
},
data() {
return {
routes: this.$store.getters.navMenus
}
},
computed: {
...mapGetters(['device', 'user', 'baseApi']),
activeMenu() {
const route = this.$route
const { meta, path } = route
console.log(this.routes)
// if set path, the sidebar will highlight the path you set
if (meta.activeMenu) {
return meta.activeMenu
}
//
if (path === '/dashboard') {
return '/'
}
//
const activeMenu = '/' + path.split('/')[1]
return activeMenu
},
variables() {
return variables
},
sidebar() {
return this.$store.state.app.sidebar
},
show: {
get() {
return this.$store.state.settings.showSettings
},
set(val) {
this.$store.dispatch('settings/changeSetting', {
key: 'showSettings',
value: val
})
}
}
},
methods: {
// store
initCurrentRoutes() {
const { path } = this.$route
console.log(this.routes)
let route = this.routes.find(
item => item.path === '/' + path.split('/')[1]
)
//
if (!route) {
route = this.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.routes.find(item => item.path === key)
this.$store.commit('SET_CURRENT_ROUTES', route)
this.setSidebarHide(route)
},
//
setSidebarHide(route) {
if (!route.children || route.children.length === 1) {
this.$store.dispatch('app/toggleSideBarHide', true)
} else {
this.$store.dispatch('app/toggleSideBarHide', false)
}
},
toggleSideBar() {
this.$store.dispatch('app/toggleSideBar')
},
open() {
this.$confirm('确定注销并退出系统吗?', '提示', {
confirmButtonText: '确定',
cancelButtonText: '取消',
type: 'warning'
}).then(() => {
this.logout()
})
},
logout() {
this.$store.dispatch('LogOut').then(() => {
location.reload()
})
}
}
}
</script>
Loading…
Cancel
Save