2016-08-23 14:03:45 +08:00
|
|
|
<style>
|
2016-08-23 17:39:58 +08:00
|
|
|
.side-nav {
|
|
|
|
width: 100%;
|
|
|
|
box-sizing: border-box;
|
2016-09-18 22:01:26 +08:00
|
|
|
padding-right: 30px;
|
2017-09-29 15:37:50 +08:00
|
|
|
transition: opacity .5s;
|
|
|
|
&:hover {
|
|
|
|
opacity: 1 !important;
|
|
|
|
}
|
2016-08-23 17:39:58 +08:00
|
|
|
|
|
|
|
li {
|
|
|
|
list-style: none;
|
|
|
|
}
|
2017-09-28 20:15:00 +08:00
|
|
|
|
2016-08-23 17:39:58 +08:00
|
|
|
ul {
|
|
|
|
padding: 0;
|
2016-08-23 19:15:15 +08:00
|
|
|
margin: 0;
|
2016-08-25 15:54:45 +08:00
|
|
|
overflow: hidden;
|
2016-08-23 17:39:58 +08:00
|
|
|
}
|
2017-03-10 00:24:15 +08:00
|
|
|
|
2016-08-23 17:39:58 +08:00
|
|
|
.nav-item {
|
|
|
|
a {
|
2016-09-13 20:02:33 +08:00
|
|
|
font-size: 16px;
|
2017-09-28 20:15:00 +08:00
|
|
|
color: #333;
|
2016-09-13 20:02:33 +08:00
|
|
|
line-height: 40px;
|
|
|
|
height: 40px;
|
2016-09-07 12:17:16 +08:00
|
|
|
margin: 0;
|
2016-09-13 20:02:33 +08:00
|
|
|
padding: 0;
|
2016-08-23 17:39:58 +08:00
|
|
|
text-decoration: none;
|
|
|
|
display: block;
|
2016-09-07 12:17:16 +08:00
|
|
|
position: relative;
|
2017-09-28 20:15:00 +08:00
|
|
|
transition: .15s ease-out;
|
|
|
|
font-weight: bold;
|
2016-08-23 17:39:58 +08:00
|
|
|
|
|
|
|
&.active {
|
2017-09-28 20:15:00 +08:00
|
|
|
color: #1989FA;
|
2016-08-23 17:39:58 +08:00
|
|
|
}
|
|
|
|
}
|
2017-09-28 20:15:00 +08:00
|
|
|
|
2016-08-23 17:39:58 +08:00
|
|
|
.nav-item {
|
|
|
|
a {
|
2016-09-07 12:17:16 +08:00
|
|
|
display: block;
|
2016-09-13 20:02:33 +08:00
|
|
|
height: 40px;
|
2017-09-28 20:15:00 +08:00
|
|
|
color: #666;
|
2016-09-13 20:02:33 +08:00
|
|
|
line-height: 40px;
|
2017-09-28 20:15:00 +08:00
|
|
|
font-size: 14px;
|
2017-03-10 00:24:15 +08:00
|
|
|
overflow: hidden;
|
|
|
|
white-space: nowrap;
|
|
|
|
text-overflow: ellipsis;
|
2017-09-28 20:15:00 +08:00
|
|
|
font-weight: normal;
|
2016-09-07 12:17:16 +08:00
|
|
|
|
2017-09-28 20:15:00 +08:00
|
|
|
&:hover,
|
|
|
|
&.active {
|
|
|
|
color: #1989FA;
|
2016-08-23 17:39:58 +08:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2017-09-28 20:15:00 +08:00
|
|
|
|
2016-08-23 17:39:58 +08:00
|
|
|
.nav-group__title {
|
2016-09-13 20:02:33 +08:00
|
|
|
font-size: 12px;
|
2017-09-28 20:15:00 +08:00
|
|
|
color: #999;
|
2016-09-13 20:02:33 +08:00
|
|
|
line-height: 26px;
|
2017-09-28 20:15:00 +08:00
|
|
|
margin-top: 15px;
|
2016-08-23 17:39:58 +08:00
|
|
|
}
|
2017-09-29 19:34:35 +08:00
|
|
|
|
2017-09-25 15:13:06 +08:00
|
|
|
#code-sponsor-widget {
|
|
|
|
margin: 50px 0 0 -20px;
|
|
|
|
}
|
2016-08-23 17:39:58 +08:00
|
|
|
}
|
2016-12-27 13:59:40 +08:00
|
|
|
.nav-dropdown-list {
|
|
|
|
width: 120px;
|
|
|
|
margin-top: -8px;
|
|
|
|
li {
|
|
|
|
font-size: 14px;
|
|
|
|
}
|
|
|
|
}
|
2016-08-23 14:03:45 +08:00
|
|
|
</style>
|
|
|
|
<template>
|
2017-09-29 15:37:50 +08:00
|
|
|
<div
|
|
|
|
class="side-nav"
|
|
|
|
@mouseenter="isFade = false"
|
|
|
|
:style="navStyle">
|
2016-08-23 14:03:45 +08:00
|
|
|
<ul>
|
2016-08-23 17:39:58 +08:00
|
|
|
<li class="nav-item" v-for="item in data">
|
2017-05-10 20:44:49 +08:00
|
|
|
<a v-if="!item.path && !item.href" @click="expandMenu">{{item.name}}</a>
|
|
|
|
<a v-if="item.href" :href="item.href" target="_blank">{{item.name}}</a>
|
2016-08-23 19:15:15 +08:00
|
|
|
<router-link
|
2017-05-10 20:44:49 +08:00
|
|
|
v-if="item.path"
|
2016-08-23 19:15:15 +08:00
|
|
|
active-class="active"
|
|
|
|
:to="base + item.path"
|
|
|
|
exact
|
|
|
|
v-text="item.title || item.name">
|
|
|
|
</router-link>
|
2016-08-23 17:39:58 +08:00
|
|
|
<ul class="pure-menu-list sub-nav" v-if="item.children">
|
|
|
|
<li class="nav-item" v-for="navItem in item.children">
|
|
|
|
<router-link
|
|
|
|
class=""
|
|
|
|
active-class="active"
|
2016-08-23 19:15:15 +08:00
|
|
|
:to="base + navItem.path"
|
2016-08-23 17:39:58 +08:00
|
|
|
exact
|
2016-08-23 19:15:15 +08:00
|
|
|
v-text="navItem.title || navItem.name">
|
2016-08-23 17:39:58 +08:00
|
|
|
</router-link>
|
|
|
|
</li>
|
|
|
|
</ul>
|
|
|
|
<template v-if="item.groups">
|
|
|
|
<div class="nav-group" v-for="group in item.groups">
|
2016-11-18 16:49:07 +08:00
|
|
|
<div class="nav-group__title" @click="expandMenu">{{group.groupName}}</div>
|
2016-08-23 17:39:58 +08:00
|
|
|
<ul class="pure-menu-list">
|
|
|
|
<li
|
|
|
|
class="nav-item"
|
2016-08-23 19:15:15 +08:00
|
|
|
v-for="navItem in group.list"
|
|
|
|
v-if="!navItem.disabled">
|
2016-08-23 17:39:58 +08:00
|
|
|
<router-link
|
|
|
|
active-class="active"
|
2016-08-23 19:15:15 +08:00
|
|
|
:to="base + navItem.path"
|
2016-08-23 17:39:58 +08:00
|
|
|
exact
|
2016-08-23 19:15:15 +08:00
|
|
|
v-text="navItem.title"></router-link>
|
2016-08-23 17:39:58 +08:00
|
|
|
</li>
|
|
|
|
</ul>
|
|
|
|
</div>
|
|
|
|
</template>
|
2016-08-23 14:03:45 +08:00
|
|
|
</li>
|
|
|
|
</ul>
|
2017-09-25 15:13:06 +08:00
|
|
|
<div id="code-sponsor-widget"></div>
|
2016-08-23 14:03:45 +08:00
|
|
|
</div>
|
|
|
|
</template>
|
|
|
|
<script>
|
2017-09-29 15:37:50 +08:00
|
|
|
import bus from '../bus';
|
2016-12-27 13:59:40 +08:00
|
|
|
import compoLang from '../i18n/component.json';
|
|
|
|
|
2016-08-23 14:03:45 +08:00
|
|
|
export default {
|
|
|
|
props: {
|
2016-08-23 19:15:15 +08:00
|
|
|
data: Array,
|
|
|
|
base: {
|
|
|
|
type: String,
|
|
|
|
default: ''
|
|
|
|
}
|
2016-08-23 14:03:45 +08:00
|
|
|
},
|
|
|
|
data() {
|
|
|
|
return {
|
|
|
|
highlights: [],
|
2016-11-18 16:49:07 +08:00
|
|
|
navState: [],
|
2016-12-27 13:59:40 +08:00
|
|
|
isSmallScreen: false,
|
2017-09-29 15:37:50 +08:00
|
|
|
isFade: false
|
2016-08-23 14:03:45 +08:00
|
|
|
};
|
2016-11-18 16:49:07 +08:00
|
|
|
},
|
|
|
|
watch: {
|
|
|
|
'$route.path'() {
|
|
|
|
this.handlePathChange();
|
2017-09-29 15:37:50 +08:00
|
|
|
},
|
|
|
|
isFade(val) {
|
|
|
|
bus.$emit('navFade', val);
|
2016-11-18 16:49:07 +08:00
|
|
|
}
|
|
|
|
},
|
|
|
|
computed: {
|
|
|
|
navStyle() {
|
2017-09-29 15:37:50 +08:00
|
|
|
const style = {};
|
|
|
|
if (this.isSmallScreen) {
|
|
|
|
style.paddingBottom = '60px';
|
|
|
|
}
|
|
|
|
if (this.isFade) {
|
|
|
|
style.opacity = '0.5';
|
|
|
|
}
|
|
|
|
return style;
|
2016-12-27 13:59:40 +08:00
|
|
|
},
|
|
|
|
langConfig() {
|
|
|
|
return compoLang.filter(config => config.lang === this.$route.meta.lang)[0]['nav'];
|
2016-11-18 16:49:07 +08:00
|
|
|
}
|
|
|
|
},
|
|
|
|
methods: {
|
|
|
|
handleResize() {
|
|
|
|
this.isSmallScreen = document.documentElement.clientWidth < 768;
|
|
|
|
this.handlePathChange();
|
|
|
|
},
|
|
|
|
handlePathChange() {
|
|
|
|
if (!this.isSmallScreen) {
|
|
|
|
this.expandAllMenu();
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
this.$nextTick(() => {
|
|
|
|
this.hideAllMenu();
|
|
|
|
let activeAnchor = this.$el.querySelector('a.active');
|
|
|
|
let ul = activeAnchor.parentNode;
|
|
|
|
while (ul.tagName !== 'UL') {
|
|
|
|
ul = ul.parentNode;
|
|
|
|
}
|
|
|
|
ul.style.height = 'auto';
|
|
|
|
});
|
|
|
|
},
|
|
|
|
hideAllMenu() {
|
|
|
|
[].forEach.call(this.$el.querySelectorAll('.pure-menu-list'), ul => {
|
|
|
|
ul.style.height = '0';
|
|
|
|
});
|
|
|
|
},
|
|
|
|
expandAllMenu() {
|
|
|
|
[].forEach.call(this.$el.querySelectorAll('.pure-menu-list'), ul => {
|
|
|
|
ul.style.height = 'auto';
|
|
|
|
});
|
|
|
|
},
|
|
|
|
expandMenu(event) {
|
|
|
|
if (!this.isSmallScreen) return;
|
|
|
|
let target = event.currentTarget;
|
|
|
|
if (!target.nextElementSibling || target.nextElementSibling.tagName !== 'UL') return;
|
|
|
|
this.hideAllMenu();
|
|
|
|
event.currentTarget.nextElementSibling.style.height = 'auto';
|
|
|
|
}
|
|
|
|
},
|
2016-12-27 13:59:40 +08:00
|
|
|
created() {
|
2017-09-29 15:37:50 +08:00
|
|
|
bus.$on('fadeNav', () => {
|
|
|
|
this.isFade = true;
|
|
|
|
});
|
2016-12-27 13:59:40 +08:00
|
|
|
},
|
2016-11-18 16:49:07 +08:00
|
|
|
mounted() {
|
|
|
|
this.handleResize();
|
|
|
|
window.addEventListener('resize', this.handleResize);
|
|
|
|
},
|
|
|
|
beforeDestroy() {
|
|
|
|
window.removeEventListener('resize', this.handleResize);
|
2016-08-23 14:03:45 +08:00
|
|
|
}
|
|
|
|
};
|
|
|
|
</script>
|