@@ -61,6 +67,7 @@ import MainNavbarLink from './MainNavbarLink.vue';
import NavbarLogo from './NavbarLogo.vue';
import DcloudSearchPage from './DcloudSearchPage';
import navInject from '../mixin/navInject';
+import DropdownLink from '@theme/components/DropdownLink.vue'
import { forbidScroll, os } from '../util';
export default {
@@ -75,14 +82,16 @@ export default {
SearchBox,
AlgoliaSearchBox,
NavbarLogo,
- DcloudSearchPage
+ DcloudSearchPage,
+ DropdownLink
},
data () {
return {
linksWrapMaxWidth: null,
showMobilePanel: false,
- fixedNavbar: false
+ fixedNavbar: false,
+ SearchBoxTop: 0
}
},
@@ -93,6 +102,18 @@ export default {
isAlgoliaSearch () {
return this.algolia && this.algolia.apiKey && this.algolia.indexName
+ },
+
+ SearchBoxStyle () {
+ const initStyle = {
+ top: `${this.SearchBoxTop}px`,
+ zIndex: 100
+ };
+ return this.linksWrapMaxWidth
+ ? Object.assign({}, initStyle, {
+ 'max-width': this.linksWrapMaxWidth + 'px',
+ })
+ : initStyle;
}
},
@@ -148,7 +169,7 @@ export default {
this.vuepressToc && this.vuepressToc.removeAttribute('style')
this.navbar && this.navbar.removeAttribute('style')
if (this.pageContainer) {
- this.pageContainer.style.marginTop = this.showSubNavBar ? 'auto' : `${this.navbarHeight}px`
+ this.pageContainer.style.marginTop = this.showSubNavBar || !os.pc ? 'auto' : `${this.navbarHeight}px`
}
},
onWindowScroll () {
@@ -165,6 +186,7 @@ export default {
if (!this.fixedNavbar) {
this.fixedNavbar = true
this.navbar.style.top = `-${this.mainNavBarHeight}px`
+ this.SearchBoxTop = this.mainNavBarHeight + (this.subNavBarHeight - this.mainNavBarHeight) / 2
this.$nextTick(() => {
this.pageContainer && (this.pageContainer.style.marginTop = `${this.navbarHeight}px`)
})
@@ -173,6 +195,7 @@ export default {
if (this.fixedNavbar) {
this.fixedNavbar = false
this.pageContainer && (this.pageContainer.style.marginTop = 'auto')
+ this.SearchBoxTop = 0
}
}
},
@@ -264,6 +287,7 @@ $navbar-horizontal-padding = 1.5rem
display none !important
.links
padding-left 0rem // 1.5rem
+ top 0 !important
.site-name
width calc(100vw - 9.4rem)
overflow hidden
diff --git a/docs/.vuepress/theme/config/navbar.js b/docs/.vuepress/theme/config/navbar.js
index 599bb2795..9082f27eb 100644
--- a/docs/.vuepress/theme/config/navbar.js
+++ b/docs/.vuepress/theme/config/navbar.js
@@ -10,6 +10,7 @@
export const navbar = [
{
text: 'uni-app',
+ link: '/',
items: [
{
text: '介绍',
diff --git a/docs/.vuepress/theme/styles/navbar.styl b/docs/.vuepress/theme/styles/navbar.styl
index cb9bc5357..83bd8ba6c 100644
--- a/docs/.vuepress/theme/styles/navbar.styl
+++ b/docs/.vuepress/theme/styles/navbar.styl
@@ -20,6 +20,7 @@ $navbar-logo-height = $navbar-main-navbar-height - 2rem
&
display none
.sub-navbar
+ position relative
line-height $navbar-sub-navbar-height
border-top-width 1px
.mobile-main-navbar
@@ -76,6 +77,20 @@ $navbar-logo-height = $navbar-main-navbar-height - 2rem
color inherit
&:hover
color $accentColor
+
+ .custom-main-navbar
+ position absolute
+ height 30px
+ top calc(50% - 15px)
+ left 2rem
+ @media (max-width: 1200px)
+ display none
+ a
+ color inherit
+ .nav-dropdown
+ right auto
+ left 0
+ z-index 12
@media (max-width: $MQMobile)
$navbar-a-color = #222;
--
GitLab