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 @@ + + + + + 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 @@