2020-08-13 15:18:26 +08:00
|
|
|
<template>
|
|
|
|
<div
|
|
|
|
class="side-nav"
|
|
|
|
:class="{ 'is-fade': isFade }"
|
|
|
|
:style="navStyle"
|
|
|
|
@mouseenter="isFade = false"
|
|
|
|
>
|
|
|
|
<ul>
|
2020-11-27 13:41:53 +08:00
|
|
|
<li class="nav-item sponsors">
|
2020-08-13 15:18:26 +08:00
|
|
|
<a>{{ lang === 'zh-CN' ? '赞助商' : 'Sponsors' }}</a>
|
|
|
|
<ul class="pure-menu-list sub-nav">
|
2020-11-27 13:41:53 +08:00
|
|
|
<li class="nav-item">
|
2021-06-04 13:54:37 +08:00
|
|
|
<a
|
|
|
|
class="sponsor"
|
|
|
|
href="https://bit.dev/?from=element-ui"
|
|
|
|
target="_blank"
|
2021-07-26 00:24:30 +08:00
|
|
|
title="bit"
|
2021-06-04 13:54:37 +08:00
|
|
|
>
|
2021-07-22 19:24:00 +08:00
|
|
|
<img src="~examples/assets/images/bit.svg">
|
|
|
|
</a>
|
|
|
|
</li>
|
|
|
|
<li class="nav-item">
|
|
|
|
<a
|
|
|
|
class="sponsor"
|
|
|
|
href="https://www.renren.io/?from=element-ui"
|
|
|
|
target="_blank"
|
|
|
|
:title="sponsorIntroR"
|
|
|
|
>
|
|
|
|
<img src="~examples/assets/images/renren.png">
|
2020-11-27 13:41:53 +08:00
|
|
|
</a>
|
|
|
|
</li>
|
2020-08-13 15:18:26 +08:00
|
|
|
</ul>
|
2020-11-27 13:41:53 +08:00
|
|
|
</li>
|
2021-06-04 13:54:37 +08:00
|
|
|
<li v-for="(item, keyy) in data" :key="keyy" class="nav-item">
|
|
|
|
<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>
|
2020-08-13 15:18:26 +08:00
|
|
|
<router-link
|
|
|
|
v-if="item.path"
|
|
|
|
active-class="active"
|
|
|
|
:to="base + item.path"
|
|
|
|
exact
|
|
|
|
v-text="item.title || item.name"
|
|
|
|
/>
|
|
|
|
<ul v-if="item.children" class="pure-menu-list sub-nav">
|
|
|
|
<li
|
|
|
|
v-for="(navItem, key) in item.children"
|
|
|
|
:key="key"
|
|
|
|
class="nav-item"
|
|
|
|
>
|
|
|
|
<router-link
|
|
|
|
class=""
|
|
|
|
active-class="active"
|
|
|
|
:to="base + navItem.path"
|
|
|
|
exact
|
|
|
|
v-text="navItem.title || navItem.name"
|
|
|
|
/>
|
|
|
|
</li>
|
|
|
|
</ul>
|
|
|
|
<template v-if="item.groups">
|
2021-06-04 13:54:37 +08:00
|
|
|
<div v-for="(group, key) in item.groups" :key="key" class="nav-group">
|
|
|
|
<div class="nav-group__title" @click="expandMenu">
|
|
|
|
{{ group.groupName }}
|
|
|
|
</div>
|
2020-08-13 15:18:26 +08:00
|
|
|
<ul class="pure-menu-list">
|
|
|
|
<li
|
|
|
|
v-for="(navItem, keey) in group.list"
|
|
|
|
v-show="!navItem.disabled"
|
|
|
|
:key="keey"
|
|
|
|
class="nav-item"
|
|
|
|
>
|
2021-06-08 14:12:16 +08:00
|
|
|
<el-badge v-if="navItem.beta" value="Beta">
|
|
|
|
<router-link
|
|
|
|
class=""
|
|
|
|
active-class="active"
|
|
|
|
:to="base + navItem.path"
|
|
|
|
exact
|
|
|
|
v-text="navItem.title || navItem.name"
|
|
|
|
/>
|
|
|
|
</el-badge>
|
2020-08-13 15:18:26 +08:00
|
|
|
<router-link
|
2021-06-08 14:12:16 +08:00
|
|
|
v-else
|
|
|
|
class=""
|
2020-08-13 15:18:26 +08:00
|
|
|
active-class="active"
|
|
|
|
:to="base + navItem.path"
|
|
|
|
exact
|
2021-06-08 14:12:16 +08:00
|
|
|
v-text="navItem.title || navItem.name"
|
2020-08-13 15:18:26 +08:00
|
|
|
/>
|
|
|
|
</li>
|
|
|
|
</ul>
|
|
|
|
</div>
|
|
|
|
</template>
|
|
|
|
</li>
|
|
|
|
</ul>
|
|
|
|
<!--<div id="code-sponsor-widget"></div>-->
|
|
|
|
</div>
|
|
|
|
</template>
|
2021-06-04 13:54:37 +08:00
|
|
|
<script lang="ts">
|
|
|
|
import {
|
|
|
|
computed,
|
2021-08-31 09:40:13 +08:00
|
|
|
CSSProperties,
|
2021-06-04 13:54:37 +08:00
|
|
|
defineComponent,
|
|
|
|
nextTick,
|
|
|
|
onBeforeUnmount,
|
|
|
|
onMounted,
|
|
|
|
ref,
|
|
|
|
watch,
|
|
|
|
} from 'vue'
|
|
|
|
import { useRoute } from 'vue-router'
|
2020-08-13 15:18:26 +08:00
|
|
|
import bus from '../bus'
|
|
|
|
import compoLang from '../i18n/component.json'
|
|
|
|
|
2021-06-04 13:54:37 +08:00
|
|
|
export default defineComponent({
|
2020-08-13 15:18:26 +08:00
|
|
|
props: {
|
|
|
|
data: {
|
|
|
|
type: Array,
|
2021-06-04 13:54:37 +08:00
|
|
|
default: () => [],
|
2020-08-13 15:18:26 +08:00
|
|
|
},
|
|
|
|
base: {
|
|
|
|
type: String,
|
|
|
|
default: '',
|
|
|
|
},
|
|
|
|
},
|
2021-06-04 13:54:37 +08:00
|
|
|
setup() {
|
|
|
|
const isSmallScreen = ref(false)
|
|
|
|
const isFade = ref(false)
|
|
|
|
const route = useRoute()
|
|
|
|
|
|
|
|
bus.$on('fade-nav', () => {
|
|
|
|
isFade.value = true
|
|
|
|
})
|
|
|
|
|
|
|
|
onMounted(() => {
|
|
|
|
handleResize()
|
|
|
|
window.addEventListener('resize', handleResize)
|
|
|
|
})
|
|
|
|
|
|
|
|
onBeforeUnmount(() => {
|
|
|
|
window.removeEventListener('resize', handleResize)
|
|
|
|
})
|
|
|
|
|
|
|
|
const navStyle = computed(() => {
|
2021-08-31 09:40:13 +08:00
|
|
|
const style: CSSProperties = {}
|
2021-06-04 13:54:37 +08:00
|
|
|
if (isSmallScreen.value) {
|
2020-08-13 15:18:26 +08:00
|
|
|
style.paddingBottom = '60px'
|
|
|
|
}
|
2021-06-04 13:54:37 +08:00
|
|
|
style.opacity = isFade.value ? '0.5' : '1'
|
2020-08-13 15:18:26 +08:00
|
|
|
return style
|
2021-06-04 13:54:37 +08:00
|
|
|
})
|
|
|
|
|
|
|
|
const lang = computed(() => {
|
|
|
|
return route.meta.lang
|
|
|
|
})
|
|
|
|
|
|
|
|
const langConfig = computed(() => {
|
|
|
|
return compoLang.filter(config => config.lang === lang.value)[0]['nav']
|
|
|
|
})
|
|
|
|
|
2021-07-22 19:24:00 +08:00
|
|
|
const sponsorIntroR = computed(() => {
|
|
|
|
return lang.value === 'zh-CN' ? '企业级的快速开发平台' : 'Enterprise-class rapid development platform'
|
|
|
|
})
|
|
|
|
|
2021-06-04 13:54:37 +08:00
|
|
|
watch(
|
|
|
|
() => route.path,
|
|
|
|
() => {
|
|
|
|
handlePathChange()
|
|
|
|
},
|
|
|
|
)
|
|
|
|
|
|
|
|
watch(isFade, val => {
|
2020-08-13 15:18:26 +08:00
|
|
|
bus.$emit('nav-fade', val)
|
|
|
|
})
|
2021-06-04 13:54:37 +08:00
|
|
|
|
|
|
|
const handleResize = () => {
|
|
|
|
isSmallScreen.value = document.documentElement.clientWidth < 768
|
|
|
|
handlePathChange()
|
|
|
|
}
|
|
|
|
|
|
|
|
const handlePathChange = async () => {
|
|
|
|
if (!isSmallScreen.value) {
|
|
|
|
expandAllMenu()
|
2020-08-13 15:18:26 +08:00
|
|
|
return
|
|
|
|
}
|
2021-06-04 13:54:37 +08:00
|
|
|
await nextTick()
|
|
|
|
hideAllMenu()
|
|
|
|
let activeAnchor = document.querySelector('a.active')
|
|
|
|
let ul = activeAnchor.parentNode
|
2021-08-31 09:40:13 +08:00
|
|
|
while (ul.nodeName !== 'UL') {
|
2021-06-04 13:54:37 +08:00
|
|
|
ul = ul.parentNode
|
|
|
|
}
|
2021-08-31 09:40:13 +08:00
|
|
|
(ul as HTMLUListElement).style.height = 'auto'
|
2021-06-04 13:54:37 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
const hideAllMenu = () => {
|
|
|
|
[].forEach.call(document.querySelectorAll('.pure-menu-list'), ul => {
|
2020-08-13 15:18:26 +08:00
|
|
|
ul.style.height = '0'
|
|
|
|
})
|
2021-06-04 13:54:37 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
const expandAllMenu = () => {
|
|
|
|
[].forEach.call(document.querySelectorAll('.pure-menu-list'), ul => {
|
2020-08-13 15:18:26 +08:00
|
|
|
ul.style.height = 'auto'
|
|
|
|
})
|
2021-06-04 13:54:37 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
const expandMenu = event => {
|
|
|
|
if (!isSmallScreen.value) return
|
2020-08-13 15:18:26 +08:00
|
|
|
let target = event.currentTarget
|
2021-06-04 13:54:37 +08:00
|
|
|
if (
|
|
|
|
!target.nextElementSibling ||
|
|
|
|
target.nextElementSibling.tagName !== 'UL'
|
|
|
|
)
|
|
|
|
return
|
|
|
|
hideAllMenu()
|
2020-08-13 15:18:26 +08:00
|
|
|
event.currentTarget.nextElementSibling.style.height = 'auto'
|
2021-06-04 13:54:37 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
return {
|
2021-07-22 19:24:00 +08:00
|
|
|
sponsorIntroR,
|
2021-06-04 13:54:37 +08:00
|
|
|
isFade,
|
|
|
|
navStyle,
|
|
|
|
lang,
|
|
|
|
langConfig,
|
|
|
|
expandMenu,
|
|
|
|
}
|
2020-08-13 15:18:26 +08:00
|
|
|
},
|
2021-06-04 13:54:37 +08:00
|
|
|
})
|
2020-08-13 15:18:26 +08:00
|
|
|
</script>
|
|
|
|
<style lang="scss" scoped>
|
2021-06-04 13:54:37 +08:00
|
|
|
.side-nav {
|
|
|
|
width: 100%;
|
|
|
|
box-sizing: border-box;
|
|
|
|
padding-right: 30px;
|
|
|
|
transition: opacity 0.3s;
|
|
|
|
&.is-fade {
|
|
|
|
transition: opacity 3s;
|
|
|
|
}
|
2020-08-13 15:18:26 +08:00
|
|
|
|
2021-06-04 13:54:37 +08:00
|
|
|
li {
|
|
|
|
list-style: none;
|
|
|
|
}
|
2020-08-13 15:18:26 +08:00
|
|
|
|
2021-06-04 13:54:37 +08:00
|
|
|
ul {
|
|
|
|
padding: 0;
|
|
|
|
margin: 0;
|
|
|
|
overflow: hidden;
|
|
|
|
}
|
|
|
|
|
|
|
|
> ul > .nav-item > a {
|
|
|
|
margin-top: 15px;
|
|
|
|
}
|
|
|
|
|
|
|
|
> ul > .nav-item:nth-child(-n + 4) > a {
|
|
|
|
margin-top: 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
.nav-item {
|
|
|
|
a {
|
|
|
|
font-size: 16px;
|
2021-08-26 09:57:56 +08:00
|
|
|
color: var(--el-text-color-primary);
|
2021-06-04 13:54:37 +08:00
|
|
|
line-height: 40px;
|
|
|
|
height: 40px;
|
2020-08-13 15:18:26 +08:00
|
|
|
margin: 0;
|
2021-06-04 13:54:37 +08:00
|
|
|
padding: 0;
|
|
|
|
text-decoration: none;
|
|
|
|
display: block;
|
|
|
|
position: relative;
|
|
|
|
transition: 0.15s ease-out;
|
|
|
|
font-weight: bold;
|
2020-08-13 15:18:26 +08:00
|
|
|
overflow: hidden;
|
2021-06-04 13:54:37 +08:00
|
|
|
white-space: nowrap;
|
|
|
|
text-overflow: ellipsis;
|
|
|
|
font-weight: normal;
|
2020-08-13 15:18:26 +08:00
|
|
|
|
2021-06-04 13:54:37 +08:00
|
|
|
&.active {
|
|
|
|
color: #409eff;
|
|
|
|
}
|
2020-08-13 15:18:26 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
.nav-item {
|
|
|
|
a {
|
|
|
|
display: block;
|
2021-06-04 13:54:37 +08:00
|
|
|
height: 40px;
|
|
|
|
color: #444;
|
|
|
|
line-height: 40px;
|
|
|
|
font-size: 14px;
|
2021-05-21 15:34:14 +08:00
|
|
|
overflow: hidden;
|
|
|
|
white-space: nowrap;
|
|
|
|
text-overflow: ellipsis;
|
|
|
|
font-weight: normal;
|
2020-08-13 15:18:26 +08:00
|
|
|
|
2021-06-04 13:54:37 +08:00
|
|
|
&:hover,
|
2020-08-13 15:18:26 +08:00
|
|
|
&.active {
|
2021-06-04 13:54:37 +08:00
|
|
|
color: #409eff;
|
2020-08-13 15:18:26 +08:00
|
|
|
}
|
|
|
|
}
|
2021-06-04 13:54:37 +08:00
|
|
|
}
|
2020-08-13 15:18:26 +08:00
|
|
|
|
2021-06-04 13:54:37 +08:00
|
|
|
&.sponsors {
|
|
|
|
& > .sub-nav {
|
|
|
|
margin-top: -10px;
|
2020-08-13 15:18:26 +08:00
|
|
|
}
|
|
|
|
|
2021-06-04 13:54:37 +08:00
|
|
|
& > a {
|
|
|
|
color: #777;
|
|
|
|
font-weight: 300;
|
|
|
|
font-size: 14px;
|
|
|
|
}
|
2020-08-13 15:18:26 +08:00
|
|
|
|
2021-06-04 13:54:37 +08:00
|
|
|
.nav-item {
|
|
|
|
display: inline-block;
|
2020-08-13 15:18:26 +08:00
|
|
|
|
2021-06-04 13:54:37 +08:00
|
|
|
a {
|
|
|
|
height: auto;
|
2020-08-13 15:18:26 +08:00
|
|
|
display: inline-block;
|
2021-06-04 13:54:37 +08:00
|
|
|
vertical-align: middle;
|
2021-07-22 19:24:00 +08:00
|
|
|
margin: 8px 10px 4px 0;
|
2020-08-13 15:18:26 +08:00
|
|
|
|
2021-06-04 13:54:37 +08:00
|
|
|
img {
|
|
|
|
width: 36px;
|
2020-08-13 15:18:26 +08:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2021-06-04 13:54:37 +08:00
|
|
|
}
|
2020-08-13 15:18:26 +08:00
|
|
|
|
2021-06-04 13:54:37 +08:00
|
|
|
.nav-group__title {
|
|
|
|
font-size: 12px;
|
2021-08-26 09:57:56 +08:00
|
|
|
color: var(--el-text-color-secondary);
|
2021-06-04 13:54:37 +08:00
|
|
|
line-height: 26px;
|
|
|
|
margin-top: 15px;
|
|
|
|
}
|
2020-08-13 15:18:26 +08:00
|
|
|
|
2021-06-04 13:54:37 +08:00
|
|
|
#code-sponsor-widget {
|
|
|
|
margin: 0 0 0 -20px;
|
2020-08-13 15:18:26 +08:00
|
|
|
}
|
2021-06-04 13:54:37 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
.nav-dropdown-list {
|
|
|
|
width: 120px;
|
|
|
|
margin-top: -8px;
|
|
|
|
|
|
|
|
li {
|
|
|
|
font-size: 14px;
|
2020-08-13 15:18:26 +08:00
|
|
|
}
|
2021-06-04 13:54:37 +08:00
|
|
|
}
|
2020-08-13 15:18:26 +08:00
|
|
|
</style>
|