vuepress-theme-uniapp-official 1.4.37 → 1.4.39

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -69,11 +69,11 @@
69
69
  flex-direction column
70
70
  justify-content center
71
71
  #docsearch span
72
- @media (min-width: 1200px)
72
+ @media (min-width: $DocSearch_MQMobile)
73
73
  &
74
74
  display flex
75
75
 
76
- @media (max-width: 1200px)
76
+ @media (max-width: $DocSearch_MQMobile)
77
77
  :root
78
78
  --docsearch-spacing 10px
79
79
  --docsearch-footer-height 40px
@@ -128,6 +128,7 @@ export default {
128
128
 
129
129
  <style lang="stylus">
130
130
  .nav-links
131
+ max-width 90%
131
132
  display inline-block
132
133
  a
133
134
  line-height 1.4rem
@@ -186,6 +186,7 @@ export default {
186
186
  src: this.src,
187
187
  frameborder: '0',
188
188
  allow: 'geolocation https://hellouniappx.dcloud.net.cn',
189
+ loading: 'lazy'
189
190
  },
190
191
  ref: 'codeIframe',
191
192
  }),
@@ -6,49 +6,41 @@
6
6
  @touchend="onTouchEnd"
7
7
  @keydown.ctrl="openSearch = true"
8
8
  >
9
- <Navbar
10
- v-if="shouldShowNavbar"
11
- @toggle-sidebar="toggleSidebar"
12
- />
9
+ <Navbar v-if="shouldShowNavbar" @toggle-sidebar="toggleSidebar" />
13
10
 
14
- <div
15
- class="sidebar-mask"
16
- @click="toggleSidebar(false)"
17
- />
11
+ <div class="sidebar-mask" @click="toggleSidebar(false)" />
18
12
 
19
- <Sidebar
20
- ref="sidebar"
21
- :items="sidebarItems"
22
- @toggle-sidebar="toggleSidebar"
23
- @hook:mounted="activeSidebarLinkVisible"
24
- >
25
- <template #top>
26
- <slot name="sidebar-top" />
27
- </template>
28
- <template #bottom>
29
- <slot name="sidebar-bottom" />
30
- <SiderBarBottom v-if="$lang === LOCALE_ZH_HANS" />
31
- </template>
32
- </Sidebar>
13
+ <div class="content-container">
14
+ <Sidebar
15
+ ref="sidebar"
16
+ :items="sidebarItems"
17
+ @toggle-sidebar="toggleSidebar"
18
+ @hook:mounted="activeSidebarLinkVisible"
19
+ >
20
+ <template #top>
21
+ <slot name="sidebar-top" />
22
+ </template>
23
+ <template #bottom>
24
+ <slot name="sidebar-bottom" />
25
+ <SiderBarBottom v-if="$lang === LOCALE_ZH_HANS" />
26
+ </template>
27
+ </Sidebar>
33
28
 
34
- <Home v-if="$page.frontmatter.home" />
29
+ <Home v-if="$page.frontmatter.home" />
35
30
 
36
- <Page
37
- v-else
38
- :sidebar-items="sidebarItems"
39
- :style="pageStyle"
40
- >
41
- <template #top>
42
- <slot name="page-top" />
43
- <TocTop/>
44
- </template>
45
- <template #bottom>
46
- <slot name="page-bottom" />
47
- <Footer />
48
- </template>
49
- </Page>
31
+ <Page v-else :sidebar-items="sidebarItems" :style="pageStyle">
32
+ <template #top>
33
+ <slot name="page-top" />
34
+ <TocTop />
35
+ </template>
36
+ <template #bottom>
37
+ <slot name="page-bottom" />
38
+ <Footer />
39
+ </template>
40
+ </Page>
50
41
 
51
- <Toc />
42
+ <Toc />
43
+ </div>
52
44
  </div>
53
45
  </template>
54
46
 
@@ -57,18 +49,18 @@ import Home from '@theme/components/Home.vue'
57
49
  import Navbar from '@theme/components/Navbar.vue'
58
50
  import Page from '@theme/components/Page.vue'
59
51
  import Sidebar from '@theme/components/Sidebar.vue'
60
- import Footer from '@theme/components/Footer.vue';
61
- import SiderBarBottom from '../components/SiderBarBottom.vue';
62
- import Toc from '../components/Toc';
63
- import TocTop from '../components/Toc-top';
52
+ import Footer from '@theme/components/Footer.vue'
53
+ import SiderBarBottom from '../components/SiderBarBottom.vue'
54
+ import Toc from '../components/Toc'
55
+ import TocTop from '../components/Toc-top'
64
56
  import { resolveSidebarItems, forbidScroll } from '../util'
65
- import navProvider from '../mixin/navProvider';
66
- import toc from '../mixin/toc';
67
- import { LOCALE_ZH_HANS } from '@theme-config/i18n';
57
+ import navProvider from '../mixin/navProvider'
58
+ import toc from '../mixin/toc'
59
+ import { LOCALE_ZH_HANS } from '@theme-config/i18n'
68
60
 
69
61
  export default {
70
62
  name: 'Layout',
71
- mixins: [ navProvider, toc ],
63
+ mixins: [navProvider, toc],
72
64
  components: {
73
65
  Home,
74
66
  Page,
@@ -77,67 +69,50 @@ export default {
77
69
  Footer,
78
70
  SiderBarBottom,
79
71
  Toc,
80
- TocTop
72
+ TocTop,
81
73
  },
82
- data () {
74
+ data() {
83
75
  return {
84
76
  isSidebarOpen: false,
85
- LOCALE_ZH_HANS
77
+ LOCALE_ZH_HANS,
86
78
  }
87
79
  },
88
80
  computed: {
89
- shouldShowNavbar () {
81
+ shouldShowNavbar() {
90
82
  const { themeConfig } = this.$site
91
83
  const { frontmatter } = this.$page
92
- if (
93
- frontmatter.navbar === false
94
- || themeConfig.navbar === false) {
84
+ if (frontmatter.navbar === false || themeConfig.navbar === false) {
95
85
  return false
96
86
  }
97
- return (
98
- this.$title
99
- || themeConfig.logo
100
- || themeConfig.repo
101
- || themeConfig.nav
102
- || this.$themeLocaleConfig.nav
103
- )
87
+ return this.$title || themeConfig.logo || themeConfig.repo || themeConfig.nav || this.$themeLocaleConfig.nav
104
88
  },
105
- shouldShowSidebar () {
89
+ shouldShowSidebar() {
106
90
  const { frontmatter } = this.$page
107
- return (
108
- !frontmatter.home
109
- && frontmatter.sidebar !== false
110
- && this.sidebarItems.length
111
- )
91
+ return !frontmatter.home && frontmatter.sidebar !== false && this.sidebarItems.length
112
92
  },
113
- sidebarItems () {
114
- return resolveSidebarItems(
115
- this.$page,
116
- this.$page.regularPath,
117
- this.$site,
118
- this.$localePath
119
- )
93
+ sidebarItems() {
94
+ return resolveSidebarItems(this.$page, this.$page.regularPath, this.$site, this.$localePath)
120
95
  },
121
- pageClasses () {
96
+ pageClasses() {
122
97
  const userPageClass = this.$page.frontmatter.pageClass
123
98
  return [
124
99
  {
125
100
  'no-navbar': !this.shouldShowNavbar,
126
101
  'sidebar-open': this.isSidebarOpen,
127
- 'no-sidebar': !this.shouldShowSidebar
102
+ 'no-sidebar': !this.shouldShowSidebar,
128
103
  },
129
- userPageClass
104
+ userPageClass,
130
105
  ]
131
106
  },
132
- pageStyle () {
133
- const style = {};
107
+ pageStyle() {
108
+ const style = {}
134
109
 
135
- !this.visible && (style.paddingRight = '0px');
110
+ !this.visible && (style.paddingRight = '0px')
136
111
 
137
- return style;
138
- }
112
+ return style
113
+ },
139
114
  },
140
- mounted () {
115
+ mounted() {
141
116
  this.$router.afterEach(() => {
142
117
  this.isSidebarOpen = false
143
118
  })
@@ -145,18 +120,18 @@ export default {
145
120
  this.renderNavLinkState()
146
121
  },
147
122
  methods: {
148
- toggleSidebar (to) {
123
+ toggleSidebar(to) {
149
124
  this.isSidebarOpen = typeof to === 'boolean' ? to : !this.isSidebarOpen
150
125
  this.$emit('toggle-sidebar', this.isSidebarOpen)
151
126
  },
152
127
  // side swipe
153
- onTouchStart (e) {
128
+ onTouchStart(e) {
154
129
  this.touchStart = {
155
130
  x: e.changedTouches[0].clientX,
156
- y: e.changedTouches[0].clientY
131
+ y: e.changedTouches[0].clientY,
157
132
  }
158
133
  },
159
- onTouchEnd (e) {
134
+ onTouchEnd(e) {
160
135
  const dx = e.changedTouches[0].clientX - this.touchStart.x
161
136
  const dy = e.changedTouches[0].clientY - this.touchStart.y
162
137
  if (Math.abs(dx) > Math.abs(dy) && Math.abs(dx) > 40) {
@@ -172,16 +147,18 @@ export default {
172
147
  const navs = document.querySelectorAll('nav')
173
148
  const navLinks = []
174
149
  const sidebarLinks = Object.keys(this.$themeConfig.sidebar)
175
- const matchSidebar = sidebarLinks.filter(i => this.$page.path.includes(i)).sort((a,b) => b.length -a.length)[0]
150
+ const matchSidebar = sidebarLinks
151
+ .filter(i => this.$page.path.includes(i))
152
+ .sort((a, b) => b.length - a.length)[0]
176
153
  navs.forEach(nav => {
177
154
  nav.querySelectorAll('a').forEach(navLink => {
178
- if(navLink.className.indexOf('external') === -1) {
155
+ if (navLink.className.indexOf('external') === -1) {
179
156
  navLinks.push(navLink)
180
157
  }
181
158
  })
182
159
  })
183
160
 
184
- navLinks.forEach((navLink,index) => {
161
+ navLinks.forEach((navLink, index) => {
185
162
  navLink.classList.remove('router-link-active')
186
163
  const matchWithoutMatchSidebar = sidebarLinks
187
164
  .filter(i => i !== matchSidebar && i !== '/')
@@ -191,10 +168,7 @@ export default {
191
168
  if (path) {
192
169
  if (
193
170
  navLink.href.match(matchSidebar) !== null &&
194
- (
195
- typeof matchWithoutMatchSidebar === 'undefined' ||
196
- matchWithoutMatchSidebar.length < matchSidebar.length
197
- )
171
+ (typeof matchWithoutMatchSidebar === 'undefined' || matchWithoutMatchSidebar.length < matchSidebar.length)
198
172
  ) {
199
173
  navLink.classList.add('router-link-active')
200
174
  }
@@ -204,7 +178,7 @@ export default {
204
178
  } else {
205
179
  // 0 => PC
206
180
  // navLinks.length / 2 => mobile
207
- if(index === 0 || index === navLinks.length / 2) {
181
+ if (index === 0 || index === navLinks.length / 2) {
208
182
  navLink.classList.add('router-link-active')
209
183
  return
210
184
  }
@@ -220,19 +194,19 @@ export default {
220
194
  const sidebarScrollTop = sidebarEL.scrollTop
221
195
  const windowInnerHeight = window.innerHeight
222
196
  const { height, top, bottom } = activeLink.getBoundingClientRect()
223
- if ((sidebarScrollTop + 50) > activeLink.offsetTop || (bottom + height) > windowInnerHeight) {
224
- activeLink.scrollIntoView({ block: "center" })
197
+ if (sidebarScrollTop + 50 > activeLink.offsetTop || bottom + height > windowInnerHeight) {
198
+ activeLink.scrollIntoView({ block: 'center' })
225
199
  }
226
200
  }
227
201
  })
228
- }
202
+ },
229
203
  },
230
204
  watch: {
231
205
  isSidebarOpen: forbidScroll,
232
206
  $route() {
233
207
  this.renderNavLinkState()
234
208
  this.activeSidebarLinkVisible()
235
- }
236
- }
209
+ },
210
+ },
237
211
  }
238
212
  </script>
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "vuepress-theme-uniapp-official",
3
- "version": "1.4.37",
3
+ "version": "1.4.39",
4
4
  "description": "uni-app official website theme for vuepress",
5
5
  "main": "index.js",
6
6
  "repository": {
@@ -16,7 +16,7 @@ $navbar-logo-height = $navbar-main-navbar-height - 2rem
16
16
  .title-logo
17
17
  padding-left 20px
18
18
  border-left 1px solid #ccc
19
- @media (max-width: 1080px)
19
+ @media (max-width: $DocSearch_MQMobile)
20
20
  &
21
21
  display none
22
22
  .sub-navbar
@@ -35,8 +35,7 @@ $navbar-logo-height = $navbar-main-navbar-height - 2rem
35
35
  justify-content center
36
36
  align-items center
37
37
  .main-navbar-links
38
- width 50%
39
- white-space: nowrap;
38
+ width 55%
40
39
  display inline-block
41
40
  @media (min-width: 1080px) and (max-width: 1680px)
42
41
  &
@@ -77,7 +76,7 @@ $navbar-logo-height = $navbar-main-navbar-height - 2rem
77
76
  color inherit
78
77
  &:hover
79
78
  color $accentColor
80
-
79
+
81
80
  .custom-main-navbar
82
81
  position absolute
83
82
  height 30px
@@ -87,7 +86,7 @@ $navbar-logo-height = $navbar-main-navbar-height - 2rem
87
86
  display none
88
87
  a
89
88
  color inherit
90
- .nav-dropdown
89
+ .nav-dropdown
91
90
  right auto
92
91
  left 0
93
92
  z-index 12
@@ -100,7 +99,7 @@ $navbar-logo-height = $navbar-main-navbar-height - 2rem
100
99
  user-select none
101
100
  position absolute
102
101
  right 12.5rem
103
- @media (max-width: 1200px)
102
+ @media (max-width: $DocSearch_MQMobile)
104
103
  &
105
104
  right 4.5rem
106
105
  &>div:nth-child(1)
@@ -237,7 +236,7 @@ $navbar-logo-height = $navbar-main-navbar-height - 2rem
237
236
  height 1px
238
237
  background-color #e4e8eb
239
238
  transform scaleY(.5)
240
- .subnavbar__item
239
+ .subnavbar__item
241
240
  a
242
241
  display block
243
242
  padding 0 16px
@@ -290,4 +289,4 @@ emphasize()
290
289
 
291
290
  .sidebar-group.depth-1
292
291
  .sidebar-links>li>.sidebar-link.active:not(.data-no-emphasize)
293
- emphasize()
292
+ emphasize()
@@ -8,3 +8,4 @@ $search-container-color = #f5f6f7
8
8
  $vuepress-toc-width = 14rem
9
9
  $vuepress-display-min-width = 1500px
10
10
  $MQMobile = 768px
11
+ $DocSearch_MQMobile = 1400px