不能展开sidebar的问题

This commit is contained in:
huanqing.shao
2019-09-21 23:17:59 +08:00
parent 1e15c83420
commit 3f9cac1484
5 changed files with 179 additions and 21 deletions

View File

@ -0,0 +1,88 @@
<template>
<ul
class="sidebar-links"
v-if="items.length"
>
<li v-for="(item, i) in items" :key="i">
<SidebarGroup
v-if="item.type === 'group'"
:item="item"
:open="i === openGroupIndex"
:collapsable="item.collapsable || item.collapsible"
:depth="depth"
@toggle="toggleGroup(i)"
/>
<SidebarLink
v-else
:sidebarDepth="sidebarDepth"
:item="item"
/>
</li>
</ul>
</template>
<script>
import SidebarGroup from '@theme/components/SidebarGroup.vue'
import SidebarLink from '@theme/components/SidebarLink.vue'
import { isActive } from '../util'
export default {
name: 'SidebarLinks',
components: { SidebarGroup, SidebarLink },
props: [
'items',
'depth', // depth of current sidebar links
'sidebarDepth' // depth of headers to be extracted
],
data () {
return {
openGroupIndex: 0
}
},
created () {
this.refreshIndex()
},
watch: {
'$route' () {
this.refreshIndex()
}
},
methods: {
refreshIndex () {
const index = resolveOpenGroupIndex(
this.$route,
this.items
)
if (index > -1) {
this.openGroupIndex = index
}
},
toggleGroup (index) {
this.openGroupIndex = index === this.openGroupIndex ? -1 : index
},
isActive (page) {
return isActive(this.$route, page.regularPath)
}
}
}
function resolveOpenGroupIndex (route, items) {
for (let i = 0; i < items.length; i++) {
const item = items[i]
if (descendantIsActive(route, item)) {
return i
}
}
return -1
}
function descendantIsActive (route, item) {
if (item.type === 'group') {
return item.children.some(child => {
if (child.type === 'group') {
return descendantIsActive(route, child)
} else {
return child.type === 'page' && isActive(route, child.path)
}
})
}
return false
}
</script>

View File

@ -58,7 +58,7 @@ export default {
localStorage.setItem('FIRST_ACCESS', new Date())
} else {
// console.log('differenceInMinutes', differenceInMinutes(new Date(), new Date(firstAccess)))
if (differenceInMinutes(new Date(), new Date(firstAccess)) >= 20 && !this.dialogVisible) {
if (differenceInMinutes(new Date(), new Date(firstAccess)) >= 10 && !this.dialogVisible) {
this.show()
}
}

View File

@ -191,7 +191,7 @@ module.exports = {
'k8s-intermediate/private-registry',
{
title: '工作负载',
collapsable: false,
collapsable: true,
children: [
'k8s-intermediate/workload/pod',
'k8s-intermediate/workload/pod-lifecycle',
@ -238,7 +238,7 @@ module.exports = {
},
{
title: '服务发现、负载均衡、网络',
collapsable: false,
collapsable: true,
children: [
'k8s-intermediate/service/service',
'k8s-intermediate/service/service-details',
@ -251,7 +251,7 @@ module.exports = {
},
{
title: '存储',
collapsable: false,
collapsable: true,
children: [
'k8s-intermediate/persistent/volume',
'k8s-intermediate/persistent/pv',
@ -261,7 +261,7 @@ module.exports = {
},
{
title: '配置',
collapsable: false,
collapsable: true,
children: [
'k8s-intermediate/config/config-map',
'k8s-intermediate/config/computing-resource',
@ -289,6 +289,14 @@ module.exports = {
}
]
},
{
title: 'Kubernetes 高级',
collapsable: false,
path: 'k8s-advanced/',
children: [
]
},
{
title: 'Kubernetes 实战',
collapsable: false,
@ -308,6 +316,14 @@ module.exports = {
// 'spring-cloud/cloud-eureka'
]
},
{
title: 'Open Capacity Platform',
collapsable: false,
children: [
'k8s-practice/ocp/',
// 'spring-cloud/cloud-eureka'
]
},
]
}
],

77
package-lock.json generated
View File

@ -1163,18 +1163,18 @@
}
},
"@vuepress/plugin-back-to-top": {
"version": "1.0.4",
"resolved": "https://registry.npm.taobao.org/@vuepress/plugin-back-to-top/download/@vuepress/plugin-back-to-top-1.0.4.tgz",
"integrity": "sha1-3tJv+AgKXuXISBDgL6kcsdUaBTI=",
"version": "1.1.0",
"resolved": "https://registry.npm.taobao.org/@vuepress/plugin-back-to-top/download/@vuepress/plugin-back-to-top-1.1.0.tgz",
"integrity": "sha1-x2Xxvhsr0ElWwspifTc37N5qwzc=",
"dev": true,
"requires": {
"lodash.debounce": "^4.0.8"
}
},
"@vuepress/plugin-google-analytics": {
"version": "1.0.4",
"resolved": "https://registry.npm.taobao.org/@vuepress/plugin-google-analytics/download/@vuepress/plugin-google-analytics-1.0.4.tgz",
"integrity": "sha1-HlAjLJQUn5n7TNE4Ha1J6Oqy8tY=",
"version": "1.1.0",
"resolved": "https://registry.npm.taobao.org/@vuepress/plugin-google-analytics/download/@vuepress/plugin-google-analytics-1.1.0.tgz",
"integrity": "sha1-KCMJz2BxtC9XzplvKwfjqervxyc=",
"dev": true
},
"@vuepress/plugin-last-updated": {
@ -1187,18 +1187,18 @@
}
},
"@vuepress/plugin-medium-zoom": {
"version": "1.0.4",
"resolved": "https://registry.npm.taobao.org/@vuepress/plugin-medium-zoom/download/@vuepress/plugin-medium-zoom-1.0.4.tgz",
"integrity": "sha1-kPThuX4Kkm4bxHqo0iIva/i6eW8=",
"version": "1.1.0",
"resolved": "https://registry.npm.taobao.org/@vuepress/plugin-medium-zoom/download/@vuepress/plugin-medium-zoom-1.1.0.tgz",
"integrity": "sha1-yVVgGX//I1ALBJJ4WEuF9POg7T0=",
"dev": true,
"requires": {
"medium-zoom": "^1.0.4"
}
},
"@vuepress/plugin-nprogress": {
"version": "1.0.4",
"resolved": "https://registry.npm.taobao.org/@vuepress/plugin-nprogress/download/@vuepress/plugin-nprogress-1.0.4.tgz",
"integrity": "sha1-ZWKHWKMQVSgGwmbVShNVVfv2cnY=",
"version": "1.1.0",
"resolved": "https://registry.npm.taobao.org/@vuepress/plugin-nprogress/download/@vuepress/plugin-nprogress-1.1.0.tgz",
"integrity": "sha1-ynEGrccBbtDZCiJVUGbBHaWX71k=",
"dev": true,
"requires": {
"nprogress": "^0.2.0"
@ -5037,6 +5037,59 @@
"assert-plus": "^1.0.0"
}
},
"github3": {
"version": "1.2.0",
"resolved": "https://registry.npm.taobao.org/github3/download/github3-1.2.0.tgz",
"integrity": "sha1-7oy7q0L0JRR9t2YE2Yqwk2R6YNM=",
"requires": {
"request": "2.12.0"
},
"dependencies": {
"request": {
"version": "2.12.0",
"resolved": "https://registry.npm.taobao.org/request/download/request-2.12.0.tgz",
"integrity": "sha1-EfRvILPQ9ISMY4OZHIB5CvFsjkg=",
"requires": {
"form-data": "~0.0.3",
"mime": "~1.2.7"
},
"dependencies": {
"form-data": {
"version": "0.0.3",
"bundled": true,
"requires": {
"async": "~0.1.9",
"combined-stream": "0.0.3",
"mime": "~1.2.2"
},
"dependencies": {
"async": {
"version": "0.1.9",
"bundled": true
},
"combined-stream": {
"version": "0.0.3",
"bundled": true,
"requires": {
"delayed-stream": "0.0.5"
},
"dependencies": {
"delayed-stream": {
"version": "0.0.5",
"bundled": true
}
}
}
}
},
"mime": {
"version": "1.2.7",
"bundled": true
}
}
}
}
},
"glob": {
"version": "7.1.4",
"resolved": "https://registry.npm.taobao.org/glob/download/glob-7.1.4.tgz",

View File

@ -4,10 +4,10 @@
"docs:build": "vuepress build ."
},
"devDependencies": {
"@vuepress/plugin-back-to-top": "^1.0.4",
"@vuepress/plugin-google-analytics": "^1.0.4",
"@vuepress/plugin-medium-zoom": "^1.0.4",
"@vuepress/plugin-nprogress": "^1.0.4",
"@vuepress/plugin-back-to-top": "^1.1.0",
"@vuepress/plugin-google-analytics": "^1.1.0",
"@vuepress/plugin-medium-zoom": "^1.1.0",
"@vuepress/plugin-nprogress": "^1.1.0",
"babel-plugin-component": "^1.1.1",
"date-fns": "^1.30.1",
"vuepress": "^1.0.4",
@ -22,6 +22,7 @@
"@vuepress/plugin-active-header-links": "^1.0.0-rc.1",
"element-ui": "^2.12.0",
"esm": "^3.2.25",
"github3": "^1.2.0",
"leancloud-storage": "^3.15.0",
"npm": "^6.11.3",
"valine": "^1.3.10"