2019-09-15 20:24:56 +08:00
|
|
|
<template>
|
2019-09-18 22:26:53 +08:00
|
|
|
<div>
|
2020-05-21 17:22:07 +08:00
|
|
|
<el-scrollbar style="height:calc(100vh - 64px)">
|
|
|
|
<transition :duration="{ enter: 800, leave: 100 }" mode="out-in" name="el-fade-in-linear">
|
|
|
|
<el-menu
|
|
|
|
:collapse="isCollapse"
|
|
|
|
:collapse-transition="true"
|
|
|
|
:default-active="active"
|
|
|
|
class="el-menu-vertical"
|
2021-06-25 17:24:02 +08:00
|
|
|
:background-color="$store.getters['app/getSIdeMode'] === 'light' ? '#fff' : '#111'"
|
|
|
|
text-color="#777"
|
2020-05-21 17:22:07 +08:00
|
|
|
unique-opened
|
2021-06-02 14:11:45 +08:00
|
|
|
@select="selectMenuItem"
|
2020-05-21 17:22:07 +08:00
|
|
|
>
|
|
|
|
<template v-for="item in asyncRouters[0].children">
|
2021-06-02 14:11:45 +08:00
|
|
|
<aside-component v-if="!item.hidden" :key="item.name" :router-info="item" />
|
2020-05-21 17:22:07 +08:00
|
|
|
</template>
|
|
|
|
</el-menu>
|
|
|
|
</transition>
|
2019-10-15 22:56:03 +08:00
|
|
|
</el-scrollbar>
|
2019-09-18 22:26:53 +08:00
|
|
|
</div>
|
2019-09-15 20:24:56 +08:00
|
|
|
</template>
|
|
|
|
|
|
|
|
<script>
|
2021-06-02 14:11:45 +08:00
|
|
|
import { mapGetters, mapMutations } from 'vuex'
|
|
|
|
import AsideComponent from '@/view/layout/aside/asideComponent'
|
2019-09-15 20:24:56 +08:00
|
|
|
export default {
|
2021-06-02 14:11:45 +08:00
|
|
|
name: 'Aside',
|
|
|
|
components: {
|
|
|
|
AsideComponent
|
|
|
|
},
|
2019-09-15 20:24:56 +08:00
|
|
|
data() {
|
|
|
|
return {
|
2021-06-02 14:11:45 +08:00
|
|
|
active: '',
|
2019-10-15 22:56:03 +08:00
|
|
|
isCollapse: false
|
2019-09-15 20:24:56 +08:00
|
|
|
}
|
|
|
|
},
|
2019-09-15 21:17:08 +08:00
|
|
|
computed: {
|
2021-06-02 14:11:45 +08:00
|
|
|
...mapGetters('router', ['asyncRouters'])
|
2019-09-15 20:24:56 +08:00
|
|
|
},
|
2021-06-02 14:11:45 +08:00
|
|
|
watch: {
|
|
|
|
$route() {
|
|
|
|
this.active = this.$route.name
|
|
|
|
}
|
2019-09-15 20:24:56 +08:00
|
|
|
},
|
|
|
|
created() {
|
2021-06-02 14:11:45 +08:00
|
|
|
this.active = this.$route.name
|
|
|
|
const screenWidth = document.body.clientWidth
|
2020-05-21 17:22:07 +08:00
|
|
|
if (screenWidth < 1000) {
|
2021-06-02 14:11:45 +08:00
|
|
|
this.isCollapse = !this.isCollapse
|
2020-05-21 17:22:07 +08:00
|
|
|
}
|
2020-05-01 18:10:45 +08:00
|
|
|
|
2021-06-02 14:11:45 +08:00
|
|
|
this.$bus.on('collapse', item => {
|
|
|
|
this.isCollapse = item
|
|
|
|
})
|
2020-04-01 15:56:39 +08:00
|
|
|
},
|
2019-09-18 22:26:53 +08:00
|
|
|
beforeDestroy() {
|
2021-06-02 14:11:45 +08:00
|
|
|
this.$bus.off('collapse')
|
|
|
|
},
|
|
|
|
methods: {
|
|
|
|
...mapMutations('history', ['addHistory']),
|
|
|
|
selectMenuItem(index, _, ele) {
|
|
|
|
const query = {}
|
|
|
|
const params = {}
|
|
|
|
ele.route.parameters &&
|
|
|
|
ele.route.parameters.map(item => {
|
|
|
|
if (item.type === 'query') {
|
|
|
|
query[item.key] = item.value
|
|
|
|
} else {
|
|
|
|
params[item.key] = item.value
|
|
|
|
}
|
|
|
|
})
|
|
|
|
if (index === this.$route.name) return
|
|
|
|
if (index.indexOf('http://') > -1 || index.indexOf('https://') > -1) {
|
|
|
|
window.open(index)
|
|
|
|
} else {
|
|
|
|
this.$router.push({ name: index, query, params })
|
|
|
|
}
|
|
|
|
}
|
2019-09-15 20:24:56 +08:00
|
|
|
}
|
2021-06-02 14:11:45 +08:00
|
|
|
}
|
2019-09-15 20:24:56 +08:00
|
|
|
</script>
|
2019-09-18 22:26:53 +08:00
|
|
|
|
|
|
|
<style lang="scss">
|
2019-12-12 17:17:27 +08:00
|
|
|
.el-scrollbar {
|
|
|
|
.el-scrollbar__view {
|
2019-12-12 14:49:40 +08:00
|
|
|
height: 100%;
|
|
|
|
}
|
|
|
|
}
|
2019-09-18 22:26:53 +08:00
|
|
|
.menu-info {
|
|
|
|
.menu-contorl {
|
|
|
|
line-height: 52px;
|
|
|
|
font-size: 20px;
|
|
|
|
display: table-cell;
|
|
|
|
vertical-align: middle;
|
|
|
|
}
|
|
|
|
}
|
2021-06-25 17:24:02 +08:00
|
|
|
.el-menu-item {
|
|
|
|
background-color: #fff;
|
|
|
|
height: 44px;
|
|
|
|
line-height: 44px;
|
|
|
|
color: #000;
|
|
|
|
&.is-active{
|
|
|
|
background-color: #e6f7ff ;
|
|
|
|
border-right: 4px solid ;
|
|
|
|
color: #1890ff ;
|
|
|
|
}
|
|
|
|
}
|
2021-06-02 14:11:45 +08:00
|
|
|
</style>
|