diff --git a/docs/.vuepress/config.js b/docs/.vuepress/config.js
index b40a3a54d27b153fef9ce7f1f2ab82b8eac4c948..1132d850bb8e8516a5ea934a6d59362709bcdc7a 100644
--- a/docs/.vuepress/config.js
+++ b/docs/.vuepress/config.js
@@ -36,6 +36,7 @@ const config = {
docsDir: 'docs',
editLinks: true,
editLinkText: '帮助我们改善此页面!',
+ lastUpdated: '上次更新',
// smoothScroll: true,
algolia: {
apiKey: '2fdcc4e76c8e260671ad70065e60b2e7',
diff --git a/docs/.vuepress/markdown/createMarkdownArray.js b/docs/.vuepress/markdown/createMarkdownArray.js
index f92dcd3fcec99e878ee51a2a30aaed92bef4d58d..efc565cfd58d44b884bc65b77d7980788dad6838 100644
--- a/docs/.vuepress/markdown/createMarkdownArray.js
+++ b/docs/.vuepress/markdown/createMarkdownArray.js
@@ -45,15 +45,13 @@ function createMarkdownArray(contents = [], childrenName = 'children') {
}
}
- function removeParent(childs = []) {
+ // 移除最后一项 parent 节点,防止循环引用报错
+ (function removeParent(childs = []) {
childs.forEach(child => {
if (child.parent) delete child.parent
if (child[childrenName]) removeParent(child[childrenName])
})
- }
-
- // 移除最后一项 parent 节点,防止循环引用报错
- removeParent(markdownArray[markdownArray.length - 1][childrenName])
+ })(markdownArray[markdownArray.length - 1][childrenName])
return markdownArray
}
diff --git a/docs/.vuepress/theme/components/Navbar.vue b/docs/.vuepress/theme/components/Navbar.vue
index d7e8ae8401e06525b51a2ce2d63bcc8f064a0c99..2f512f510663fd880b1e2046d05b4a8dda035106 100644
--- a/docs/.vuepress/theme/components/Navbar.vue
+++ b/docs/.vuepress/theme/components/Navbar.vue
@@ -121,6 +121,7 @@ export default {
this.mainNavBar = document.querySelector('.main-navbar')
this.subNavBar = document.querySelector('.sub-navbar')
this.pageContainer = document.querySelector('.page')
+ this.vuepressToc = document.querySelector('.vuepress-toc')
this.navbarHeight = this.navbar.clientHeight
this.subNavBarHeight = this.subNavBar.clientHeight
this.mainNavBarHeight = this.mainNavBar.clientHeight
@@ -134,6 +135,7 @@ export default {
window.removeEventListener('scroll', this.onWindowScroll)
this.fixedNavbar = false
this.sideBar && this.sideBar.removeAttribute('style')
+ this.vuepressToc && this.vuepressToc.removeAttribute('style')
this.navbar && this.navbar.removeAttribute('style')
this.pageContainer && this.pageContainer.removeAttribute('style')
},
@@ -144,6 +146,7 @@ export default {
let sideTop = this.navbarHeight - scrollTop
sideTop <= this.subNavBarHeight && (sideTop = this.subNavBarHeight)
this.sideBar && (this.sideBar.style.top = `${sideTop + 1}px`)
+ this.vuepressToc && (this.vuepressToc.style.top = `${sideTop + 1}px`)
}
if (scrollTop >= this.mainNavBarHeight) {
@@ -182,6 +185,7 @@ export default {
this.navbarHeight = this.navbar.clientHeight
this.subNavBarHeight = this.subNavBar.clientHeight
this.sideBar.style.top = `${this.navbarHeight + 1}px`
+ this.vuepressToc.style.top = `${this.navbarHeight + 1}px`
})
}
}
diff --git a/docs/.vuepress/theme/components/Sticker.vue b/docs/.vuepress/theme/components/Sticker.vue
new file mode 100644
index 0000000000000000000000000000000000000000..e1ac951045547701f04f77ab320a78022981e2ce
--- /dev/null
+++ b/docs/.vuepress/theme/components/Sticker.vue
@@ -0,0 +1,64 @@
+
+
+
+
+
+
+
+
+
diff --git a/docs/.vuepress/theme/components/Toc.vue b/docs/.vuepress/theme/components/Toc.vue
new file mode 100644
index 0000000000000000000000000000000000000000..b8e6f28ffe8cf429060de3dc57e31e97ae79bb48
--- /dev/null
+++ b/docs/.vuepress/theme/components/Toc.vue
@@ -0,0 +1,166 @@
+
+
+ ON THIS PAGE
+
+
+
+
+
+
+
diff --git a/docs/.vuepress/theme/layouts/Layout.vue b/docs/.vuepress/theme/layouts/Layout.vue
index b2e594975fce7e9adab3d8f71dbb6f71b7470213..687a0718693fc402adfed36418487cd1f857fbb0 100644
--- a/docs/.vuepress/theme/layouts/Layout.vue
+++ b/docs/.vuepress/theme/layouts/Layout.vue
@@ -43,6 +43,8 @@
+
+
@@ -53,6 +55,7 @@ import Page from '@theme/components/Page.vue'
import Sidebar from '@theme/components/Sidebar.vue'
import Footer from '@theme/components/Footer.vue';
import SiderBarBottom from '../components/SiderBarBottom.vue';
+import Toc from '../components/Toc';
import { resolveSidebarItems, forbidScroll, BaiduStat } from '../util'
import navProvider from '../mixin/navProvider';
@@ -65,7 +68,8 @@ export default {
Sidebar,
Navbar,
Footer,
- SiderBarBottom
+ SiderBarBottom,
+ Toc
},
data () {
return {
diff --git a/docs/.vuepress/theme/styles/index.styl b/docs/.vuepress/theme/styles/index.styl
index c5e2831497671c23fc80576e35688b517a64166d..73f99c6f5a00a84cca257ae6aa42aca2dda267b1 100644
--- a/docs/.vuepress/theme/styles/index.styl
+++ b/docs/.vuepress/theme/styles/index.styl
@@ -81,6 +81,11 @@ body.forbid_scroll
main.page
padding-bottom 0px
+ padding-right 0px
+
+ @media (min-width: 1300px)
+ &
+ padding-right $vuepress-toc-width
{$contentClass}:not(.custom)
> *:first-child
diff --git a/docs/.vuepress/theme/styles/palette.styl b/docs/.vuepress/theme/styles/palette.styl
index 82b9623dbbd42d8cb6a971fe6401d4bca732e768..eb2970ff54a7b529fce2f9c5723714549b25e393 100644
--- a/docs/.vuepress/theme/styles/palette.styl
+++ b/docs/.vuepress/theme/styles/palette.styl
@@ -4,4 +4,5 @@ $contentWidth = 1200px
$navbarHeight = 9rem
$navbar-sub-navbar-height = 5rem
$navbar-background-color = #f7f7f7
-$search-container-color = #f5f6f7
\ No newline at end of file
+$search-container-color = #f5f6f7
+$vuepress-toc-width = 220px
\ No newline at end of file
diff --git a/docs/.vuepress/theme/util/index.js b/docs/.vuepress/theme/util/index.js
index 50948fc9e9c14911f2f6bc08b78b51a833b01862..f73dbdc99bd6bce89d57a84c157b7b211125aca2 100644
--- a/docs/.vuepress/theme/util/index.js
+++ b/docs/.vuepress/theme/util/index.js
@@ -300,4 +300,25 @@ export function debounce(fn, delay) {
clearTimeout(timeout)
}
return newFn
+}
+
+/*
+ * find parent vm by ref
+ * @param {String} ref
+ * @param {Vue} vm
+ * @param {any} def default value
+ * @returns {Element}
+ */
+export function findContainerInVm(ref, vm, def) {
+ if (!ref) return def
+ let container
+ let parent = vm
+ while ((parent = parent.$parent) && !container) {
+ container = parent.$refs[ref]
+ }
+ // Ensure it's html element (ref could be component)
+ if (container && container.$el) {
+ container = container.$el
+ }
+ return container || def
}
\ No newline at end of file