feat(cli): improve nav route
This commit is contained in:
@@ -32,11 +32,8 @@ export default {
|
||||
},
|
||||
|
||||
props: {
|
||||
navConfig: Array,
|
||||
base: {
|
||||
type: String,
|
||||
default: ''
|
||||
}
|
||||
lang: String,
|
||||
navConfig: Array
|
||||
},
|
||||
|
||||
data() {
|
||||
@@ -52,6 +49,10 @@ export default {
|
||||
top: this.top + 'px',
|
||||
bottom: this.bottom + 'px'
|
||||
};
|
||||
},
|
||||
|
||||
base() {
|
||||
return this.lang ? `/${this.lang}` : '';
|
||||
}
|
||||
},
|
||||
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
<template>
|
||||
<router-link v-if="item.path" active-class="active" :to="base + item.path" v-html="itemName" />
|
||||
<router-link v-if="item.path" :class="{ active }" :to="path" v-html="itemName" />
|
||||
<a v-else-if="item.link" :href="item.link" v-html="itemName" />
|
||||
<a v-else v-html="itemName " />
|
||||
</template>
|
||||
@@ -17,6 +17,23 @@ export default {
|
||||
itemName() {
|
||||
const name = (this.item.title || this.item.name).split(' ');
|
||||
return `${name[0]} <span>${name.slice(1).join(' ')}</span>`;
|
||||
},
|
||||
|
||||
path() {
|
||||
const { path } = this.item;
|
||||
return this.base ? `${this.base}/${path}` : path;
|
||||
},
|
||||
|
||||
active() {
|
||||
if (this.$route.path === this.path) {
|
||||
return true;
|
||||
}
|
||||
|
||||
if (this.item.path === 'home') {
|
||||
return this.$route.path === this.base;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
@@ -7,7 +7,7 @@
|
||||
:lang-configs="langConfigs"
|
||||
@switch-version="$emit('switch-version', $event)"
|
||||
/>
|
||||
<doc-nav :base="base" :nav-config="config.nav" />
|
||||
<doc-nav :lang="lang" :nav-config="config.nav" />
|
||||
<doc-container :has-simulator="!!simulator ">
|
||||
<doc-content>
|
||||
<slot />
|
||||
|
||||
Reference in New Issue
Block a user