vuepress-theme-uniapp-official 1.4.11
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.
- package/README.md +22 -0
- package/components/AlgoliaSearchBox.vue +130 -0
- package/components/DcloudSearchPage/components/Result.vue +160 -0
- package/components/DcloudSearchPage/components/Results.vue +66 -0
- package/components/DcloudSearchPage/components/pagination.vue +155 -0
- package/components/DcloudSearchPage/index.styl +183 -0
- package/components/DcloudSearchPage/index.vue +500 -0
- package/components/DcloudSearchPage/styles/ask.styl +272 -0
- package/components/DcloudSearchPage/styles/ext.styl +68 -0
- package/components/DcloudSearchPage/utils/Base64.js +134 -0
- package/components/DcloudSearchPage/utils/mock.js +434 -0
- package/components/DcloudSearchPage/utils/postDcloudServer.js +141 -0
- package/components/DcloudSearchPage/utils/searchClient.js +101 -0
- package/components/DcloudSearchPage/utils/searchUtils.js +52 -0
- package/components/Footer.vue +142 -0
- package/components/MainNavbarLink.vue +57 -0
- package/components/NavLink.vue +95 -0
- package/components/NavLinks.vue +173 -0
- package/components/Navbar.vue +322 -0
- package/components/NavbarLogo.vue +24 -0
- package/components/OutboundLink.vue +45 -0
- package/components/SearchBox/dist/match-query.dev.js +61 -0
- package/components/SearchBox/index.vue +337 -0
- package/components/SearchBox/match-query.js +51 -0
- package/components/SearchBox/search.svg +1 -0
- package/components/SidebarGroup.vue +141 -0
- package/components/SidebarLink.vue +152 -0
- package/components/SidebarLinks.vue +106 -0
- package/components/SiderBarBottom.vue +134 -0
- package/components/Sticker.vue +64 -0
- package/components/Toc-top.vue +95 -0
- package/components/Toc.vue +165 -0
- package/config/copy.js +7 -0
- package/config/footer.js +195 -0
- package/config/i18n/index.js +2 -0
- package/config/navbar.js +163 -0
- package/config/redirectRouter.js +120 -0
- package/config/searchPage.js +48 -0
- package/config/siderbar/index.js +8 -0
- package/config/siderbar/uni-app.js +210 -0
- package/config/siderbar/uniCloud.js +55 -0
- package/config/toc.js +5 -0
- package/enhanceApp.js +142 -0
- package/global-components/CodeSimulator.vue +211 -0
- package/global-components/icons.js +647 -0
- package/global-components/iconsLayouts.vue +117 -0
- package/global-components/uniIcon.vue +85 -0
- package/global-components/uniicons.css +656 -0
- package/global-components/uniicons.ttf +0 -0
- package/index.js +152 -0
- package/layouts/404.vue +22 -0
- package/layouts/Layout.vue +238 -0
- package/layouts/SimpleLayout.vue +18 -0
- package/mixin/navInject.js +21 -0
- package/mixin/navProvider.js +65 -0
- package/mixin/toc.js +36 -0
- package/package.json +50 -0
- package/styles/custom-block.styl +336 -0
- package/styles/footer.styl +248 -0
- package/styles/index.styl +197 -0
- package/styles/navbar.styl +293 -0
- package/styles/palette.styl +9 -0
- package/util/index.js +317 -0
package/index.js
ADDED
|
@@ -0,0 +1,152 @@
|
|
|
1
|
+
function getFormattedDate() {
|
|
2
|
+
const now = new Date();
|
|
3
|
+
|
|
4
|
+
const year = now.getFullYear();
|
|
5
|
+
const month = (now.getMonth() + 1).toString().padStart(2, '0');
|
|
6
|
+
const day = now.getDate().toString().padStart(2, '0');
|
|
7
|
+
const hours = now.getHours().toString().padStart(2, '0');
|
|
8
|
+
const minutes = now.getMinutes().toString().padStart(2, '0');
|
|
9
|
+
const seconds = now.getSeconds().toString().padStart(2, '0');
|
|
10
|
+
|
|
11
|
+
const formattedDate = `${year}-${month}-${day}_${hours}-${minutes}-${seconds}`;
|
|
12
|
+
|
|
13
|
+
return formattedDate;
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
const nowString = getFormattedDate();
|
|
17
|
+
const changeLoaderOptions = (options, key = 'name') => {
|
|
18
|
+
if (options && options[key]) options[key] = `${nowString}/${options[key]}`;
|
|
19
|
+
return options;
|
|
20
|
+
};
|
|
21
|
+
|
|
22
|
+
module.exports = (themeConfig, ctx, pluginAPI) => {
|
|
23
|
+
pluginAPI.options.chainWebpack.add('assets-chunk-timestamp', (config, isServer) => {
|
|
24
|
+
config.output.filename(`${nowString}/${config.output.get('filename')}`); //输出文件名
|
|
25
|
+
config.module.rule('images').use('url-loader').tap(changeLoaderOptions);
|
|
26
|
+
config.module.rule('fonts').use('url-loader').tap(changeLoaderOptions);
|
|
27
|
+
config.module.rule('media').use('url-loader').tap(changeLoaderOptions);
|
|
28
|
+
config.module.rule('svg').use('file-loader').tap(changeLoaderOptions);
|
|
29
|
+
if (!isServer && process.env.NODE_ENV !== 'development') {
|
|
30
|
+
const extract_css_plugin = config.plugin('extract-css');
|
|
31
|
+
const extract_css_plugin_args = extract_css_plugin.get('args');
|
|
32
|
+
if (extract_css_plugin_args) {
|
|
33
|
+
extract_css_plugin.set(
|
|
34
|
+
'args',
|
|
35
|
+
extract_css_plugin_args.map(item =>
|
|
36
|
+
changeLoaderOptions(item, 'filename')
|
|
37
|
+
)
|
|
38
|
+
);
|
|
39
|
+
}
|
|
40
|
+
}
|
|
41
|
+
})
|
|
42
|
+
|
|
43
|
+
pluginAPI.options.extendMarkdown.add('vuepress-theme-uni-app-md-plugins', (md) =>{
|
|
44
|
+
md.use(require('markdown-it-attrs'), {
|
|
45
|
+
leftDelimiter: '#{',
|
|
46
|
+
rightDelimiter: '}',
|
|
47
|
+
});
|
|
48
|
+
md.use(require('markdown-it-task-lists'));
|
|
49
|
+
md.use(require('markdown-it-raw-table'));
|
|
50
|
+
})
|
|
51
|
+
|
|
52
|
+
const klass = 'info'
|
|
53
|
+
const config = {
|
|
54
|
+
extend: '@vuepress/theme-default',
|
|
55
|
+
plugins: [
|
|
56
|
+
'@vuepress/back-to-top',
|
|
57
|
+
'mermaidjs',
|
|
58
|
+
['container', {
|
|
59
|
+
type: 'preview',
|
|
60
|
+
validate: (params) => {
|
|
61
|
+
// return params.trim().match(/^preview\s+(.*)$/);
|
|
62
|
+
return params.trim().match(/^preview/);
|
|
63
|
+
},
|
|
64
|
+
|
|
65
|
+
render: (tokens, idx, opts, event) => {
|
|
66
|
+
var m = tokens[idx].info.trim().match(/^preview\s+(.*)$/);
|
|
67
|
+
if (tokens[idx].nesting === 1) {
|
|
68
|
+
// opening tag
|
|
69
|
+
return `<CodeSimulator class="code" src="${m && m.length > 0 ? m[1] : ''}">`;
|
|
70
|
+
} else {
|
|
71
|
+
// closing tag
|
|
72
|
+
return `</CodeSimulator>`;
|
|
73
|
+
}
|
|
74
|
+
}
|
|
75
|
+
}],
|
|
76
|
+
['container',{
|
|
77
|
+
type: klass,
|
|
78
|
+
render(tokens, idx, opts, env) {
|
|
79
|
+
const token = tokens[idx]
|
|
80
|
+
const info = token.info.trim().slice(klass.length).trim()
|
|
81
|
+
if (token.nesting === 1) {
|
|
82
|
+
return `<div class="custom-block ${klass}"><p class="custom-block-title">${info || 'INFO'}</p>\n`
|
|
83
|
+
} else return `</div>\n`
|
|
84
|
+
}
|
|
85
|
+
}],
|
|
86
|
+
['zooming', {
|
|
87
|
+
selector: '.theme-default-content img.zooming',
|
|
88
|
+
options: {
|
|
89
|
+
scaleBase: 0.9,
|
|
90
|
+
bgColor: 'rgba(0,0,0,0.6)'
|
|
91
|
+
}
|
|
92
|
+
}],
|
|
93
|
+
['named-chunks',{
|
|
94
|
+
layoutChunkName: (layout) => 'layout-' + layout.componentName,
|
|
95
|
+
pageChunkName: page => {
|
|
96
|
+
const _context = page._context
|
|
97
|
+
const pageHeaders = (page.headers || []).map(item => item.title).join(',')
|
|
98
|
+
if (pageHeaders) {
|
|
99
|
+
const originDescription = page.frontmatter.description || ''
|
|
100
|
+
page.frontmatter = {
|
|
101
|
+
...page.frontmatter,
|
|
102
|
+
description: `${_context.siteConfig.description ? `${_context.siteConfig.description},` : ''}${pageHeaders}${originDescription ? `,${originDescription}` : ''}`.slice(0, 150),
|
|
103
|
+
}
|
|
104
|
+
}
|
|
105
|
+
const pagePath = page.path.indexOf('.html') === -1 ? page.path + 'index' : page.path
|
|
106
|
+
const curPath = 'docs/' + pagePath.replace('docs/', '').substring(1).replace(/\.html/g, "")
|
|
107
|
+
return curPath
|
|
108
|
+
}
|
|
109
|
+
}],
|
|
110
|
+
['check-md2',{
|
|
111
|
+
filter({errMsg, fileUrl, fullText, matchUrl, col, line}){
|
|
112
|
+
/**
|
|
113
|
+
* errMsg:"Should use .md instead of .html"、"File is not found"、"Hash should slugify"、"Hash is not found"
|
|
114
|
+
*/
|
|
115
|
+
const hashNotFound = errMsg === 'Hash is not found' && matchUrl.startsWith('#')
|
|
116
|
+
const replaceHtmlExtToMd = errMsg === "Should use .md instead of .html"
|
|
117
|
+
const fileNotFound = errMsg === "File is not found"
|
|
118
|
+
const hashShouldSlugify = errMsg === "Hash should slugify"
|
|
119
|
+
return hashNotFound || replaceHtmlExtToMd || fileNotFound || hashShouldSlugify
|
|
120
|
+
}
|
|
121
|
+
}],
|
|
122
|
+
'expandable-row'
|
|
123
|
+
]
|
|
124
|
+
}
|
|
125
|
+
|
|
126
|
+
if (Array.isArray(themeConfig.plugins) && themeConfig.plugins.length) {
|
|
127
|
+
const vuepressPluginPrefix = 'vuepress-plugin-'
|
|
128
|
+
const configPluginNames = config.plugins.map(item => typeof item === 'string' ? item : item[0])
|
|
129
|
+
|
|
130
|
+
themeConfig.plugins.forEach(item => {
|
|
131
|
+
const pluginName = typeof item === 'string' ? item : item[0]
|
|
132
|
+
let configPluginIndex = configPluginNames.indexOf(pluginName)
|
|
133
|
+
if (configPluginIndex === -1 && pluginName.indexOf(vuepressPluginPrefix) === 0) {
|
|
134
|
+
// vuepress-plugin-${pluginName} -> ${pluginName}
|
|
135
|
+
configPluginIndex = configPluginNames.indexOf(pluginName.replace(vuepressPluginPrefix, ''))
|
|
136
|
+
} else if (configPluginIndex === -1) {
|
|
137
|
+
// ${pluginName} -> vuepress-plugin-${pluginName}
|
|
138
|
+
configPluginIndex = configPluginNames.indexOf(vuepressPluginPrefix + pluginName)
|
|
139
|
+
}
|
|
140
|
+
if (configPluginIndex !== -1 && Array.isArray(item)) {
|
|
141
|
+
const configPlugin = config.plugins[configPluginIndex]
|
|
142
|
+
if (Array.isArray(configPlugin) && typeof item[1] !== 'undefined') {
|
|
143
|
+
configPlugin[1] = Object.assign(configPlugin[1], item[1])
|
|
144
|
+
} else {
|
|
145
|
+
config.plugins[configPluginIndex] = item
|
|
146
|
+
}
|
|
147
|
+
}
|
|
148
|
+
})
|
|
149
|
+
}
|
|
150
|
+
|
|
151
|
+
return config
|
|
152
|
+
}
|
package/layouts/404.vue
ADDED
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
<template>
|
|
2
|
+
<div class="theme-container">
|
|
3
|
+
<!-- <div class="theme-default-content">
|
|
4
|
+
<h1>404</h1>
|
|
5
|
+
|
|
6
|
+
<blockquote>{{ getMsg() }}</blockquote>
|
|
7
|
+
|
|
8
|
+
<RouterLink to="/">Take me home.</RouterLink>
|
|
9
|
+
</div> -->
|
|
10
|
+
</div>
|
|
11
|
+
</template>
|
|
12
|
+
|
|
13
|
+
<script>
|
|
14
|
+
import { isServer } from '../util';
|
|
15
|
+
|
|
16
|
+
export default {
|
|
17
|
+
created() {
|
|
18
|
+
if (isServer) return;
|
|
19
|
+
this.$router.replace('/');
|
|
20
|
+
},
|
|
21
|
+
};
|
|
22
|
+
</script>
|
|
@@ -0,0 +1,238 @@
|
|
|
1
|
+
<template>
|
|
2
|
+
<div
|
|
3
|
+
class="theme-container"
|
|
4
|
+
:class="pageClasses"
|
|
5
|
+
@touchstart="onTouchStart"
|
|
6
|
+
@touchend="onTouchEnd"
|
|
7
|
+
@keydown.ctrl="openSearch = true"
|
|
8
|
+
>
|
|
9
|
+
<Navbar
|
|
10
|
+
v-if="shouldShowNavbar"
|
|
11
|
+
@toggle-sidebar="toggleSidebar"
|
|
12
|
+
/>
|
|
13
|
+
|
|
14
|
+
<div
|
|
15
|
+
class="sidebar-mask"
|
|
16
|
+
@click="toggleSidebar(false)"
|
|
17
|
+
/>
|
|
18
|
+
|
|
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>
|
|
33
|
+
|
|
34
|
+
<Home v-if="$page.frontmatter.home" />
|
|
35
|
+
|
|
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>
|
|
50
|
+
|
|
51
|
+
<Toc />
|
|
52
|
+
</div>
|
|
53
|
+
</template>
|
|
54
|
+
|
|
55
|
+
<script>
|
|
56
|
+
import Home from '@theme/components/Home.vue'
|
|
57
|
+
import Navbar from '@theme/components/Navbar.vue'
|
|
58
|
+
import Page from '@theme/components/Page.vue'
|
|
59
|
+
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';
|
|
64
|
+
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';
|
|
68
|
+
|
|
69
|
+
export default {
|
|
70
|
+
name: 'Layout',
|
|
71
|
+
mixins: [ navProvider, toc ],
|
|
72
|
+
components: {
|
|
73
|
+
Home,
|
|
74
|
+
Page,
|
|
75
|
+
Sidebar,
|
|
76
|
+
Navbar,
|
|
77
|
+
Footer,
|
|
78
|
+
SiderBarBottom,
|
|
79
|
+
Toc,
|
|
80
|
+
TocTop
|
|
81
|
+
},
|
|
82
|
+
data () {
|
|
83
|
+
return {
|
|
84
|
+
isSidebarOpen: false,
|
|
85
|
+
LOCALE_ZH_HANS
|
|
86
|
+
}
|
|
87
|
+
},
|
|
88
|
+
computed: {
|
|
89
|
+
shouldShowNavbar () {
|
|
90
|
+
const { themeConfig } = this.$site
|
|
91
|
+
const { frontmatter } = this.$page
|
|
92
|
+
if (
|
|
93
|
+
frontmatter.navbar === false
|
|
94
|
+
|| themeConfig.navbar === false) {
|
|
95
|
+
return false
|
|
96
|
+
}
|
|
97
|
+
return (
|
|
98
|
+
this.$title
|
|
99
|
+
|| themeConfig.logo
|
|
100
|
+
|| themeConfig.repo
|
|
101
|
+
|| themeConfig.nav
|
|
102
|
+
|| this.$themeLocaleConfig.nav
|
|
103
|
+
)
|
|
104
|
+
},
|
|
105
|
+
shouldShowSidebar () {
|
|
106
|
+
const { frontmatter } = this.$page
|
|
107
|
+
return (
|
|
108
|
+
!frontmatter.home
|
|
109
|
+
&& frontmatter.sidebar !== false
|
|
110
|
+
&& this.sidebarItems.length
|
|
111
|
+
)
|
|
112
|
+
},
|
|
113
|
+
sidebarItems () {
|
|
114
|
+
return resolveSidebarItems(
|
|
115
|
+
this.$page,
|
|
116
|
+
this.$page.regularPath,
|
|
117
|
+
this.$site,
|
|
118
|
+
this.$localePath
|
|
119
|
+
)
|
|
120
|
+
},
|
|
121
|
+
pageClasses () {
|
|
122
|
+
const userPageClass = this.$page.frontmatter.pageClass
|
|
123
|
+
return [
|
|
124
|
+
{
|
|
125
|
+
'no-navbar': !this.shouldShowNavbar,
|
|
126
|
+
'sidebar-open': this.isSidebarOpen,
|
|
127
|
+
'no-sidebar': !this.shouldShowSidebar
|
|
128
|
+
},
|
|
129
|
+
userPageClass
|
|
130
|
+
]
|
|
131
|
+
},
|
|
132
|
+
pageStyle () {
|
|
133
|
+
const style = {};
|
|
134
|
+
|
|
135
|
+
!this.visible && (style.paddingRight = '0px');
|
|
136
|
+
|
|
137
|
+
return style;
|
|
138
|
+
}
|
|
139
|
+
},
|
|
140
|
+
mounted () {
|
|
141
|
+
this.$router.afterEach(() => {
|
|
142
|
+
this.isSidebarOpen = false
|
|
143
|
+
})
|
|
144
|
+
forbidScroll(this.isSidebarOpen)
|
|
145
|
+
this.renderNavLinkState()
|
|
146
|
+
},
|
|
147
|
+
methods: {
|
|
148
|
+
toggleSidebar (to) {
|
|
149
|
+
this.isSidebarOpen = typeof to === 'boolean' ? to : !this.isSidebarOpen
|
|
150
|
+
this.$emit('toggle-sidebar', this.isSidebarOpen)
|
|
151
|
+
},
|
|
152
|
+
// side swipe
|
|
153
|
+
onTouchStart (e) {
|
|
154
|
+
this.touchStart = {
|
|
155
|
+
x: e.changedTouches[0].clientX,
|
|
156
|
+
y: e.changedTouches[0].clientY
|
|
157
|
+
}
|
|
158
|
+
},
|
|
159
|
+
onTouchEnd (e) {
|
|
160
|
+
const dx = e.changedTouches[0].clientX - this.touchStart.x
|
|
161
|
+
const dy = e.changedTouches[0].clientY - this.touchStart.y
|
|
162
|
+
if (Math.abs(dx) > Math.abs(dy) && Math.abs(dx) > 40) {
|
|
163
|
+
if (dx > 0 && this.touchStart.x <= 80) {
|
|
164
|
+
this.toggleSidebar(true)
|
|
165
|
+
} else {
|
|
166
|
+
this.toggleSidebar(false)
|
|
167
|
+
}
|
|
168
|
+
}
|
|
169
|
+
},
|
|
170
|
+
renderNavLinkState() {
|
|
171
|
+
this.$nextTick(() => {
|
|
172
|
+
const navs = document.querySelectorAll('nav')
|
|
173
|
+
const navLinks = []
|
|
174
|
+
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]
|
|
176
|
+
navs.forEach(nav => {
|
|
177
|
+
nav.querySelectorAll('a').forEach(navLink => {
|
|
178
|
+
if(navLink.className.indexOf('external') === -1) {
|
|
179
|
+
navLinks.push(navLink)
|
|
180
|
+
}
|
|
181
|
+
})
|
|
182
|
+
})
|
|
183
|
+
|
|
184
|
+
navLinks.forEach((navLink,index) => {
|
|
185
|
+
navLink.classList.remove('router-link-active')
|
|
186
|
+
const matchWithoutMatchSidebar = sidebarLinks
|
|
187
|
+
.filter(i => i !== matchSidebar && i !== '/')
|
|
188
|
+
.find(i => navLink.href.match(i) !== null)
|
|
189
|
+
// debugger
|
|
190
|
+
const path = (this.$route.fullPath.match(/\/([\w-]+)+\//) || [])[1]
|
|
191
|
+
if (path) {
|
|
192
|
+
if (
|
|
193
|
+
navLink.href.match(matchSidebar) !== null &&
|
|
194
|
+
(
|
|
195
|
+
typeof matchWithoutMatchSidebar === 'undefined' ||
|
|
196
|
+
matchWithoutMatchSidebar.length < matchSidebar.length
|
|
197
|
+
)
|
|
198
|
+
) {
|
|
199
|
+
navLink.classList.add('router-link-active')
|
|
200
|
+
}
|
|
201
|
+
// if (path === href) {
|
|
202
|
+
// navLink.classList.add('router-link-active')
|
|
203
|
+
// }
|
|
204
|
+
} else {
|
|
205
|
+
// 0 => PC
|
|
206
|
+
// navLinks.length / 2 => mobile
|
|
207
|
+
if(index === 0 || index === navLinks.length / 2) {
|
|
208
|
+
navLink.classList.add('router-link-active')
|
|
209
|
+
return
|
|
210
|
+
}
|
|
211
|
+
}
|
|
212
|
+
})
|
|
213
|
+
})
|
|
214
|
+
},
|
|
215
|
+
activeSidebarLinkVisible() {
|
|
216
|
+
this.$nextTick(() => {
|
|
217
|
+
const sidebarEL = this.$refs.sidebar.$el
|
|
218
|
+
const activeLink = sidebarEL.querySelector('.sidebar-link.active')
|
|
219
|
+
if (activeLink) {
|
|
220
|
+
const sidebarScrollTop = sidebarEL.scrollTop
|
|
221
|
+
const windowInnerHeight = window.innerHeight
|
|
222
|
+
const { height, top, bottom } = activeLink.getBoundingClientRect()
|
|
223
|
+
if ((sidebarScrollTop + 50) > activeLink.offsetTop || (bottom + height) > windowInnerHeight) {
|
|
224
|
+
activeLink.scrollIntoView({ block: "center" })
|
|
225
|
+
}
|
|
226
|
+
}
|
|
227
|
+
})
|
|
228
|
+
}
|
|
229
|
+
},
|
|
230
|
+
watch: {
|
|
231
|
+
isSidebarOpen: forbidScroll,
|
|
232
|
+
$route() {
|
|
233
|
+
this.renderNavLinkState()
|
|
234
|
+
this.activeSidebarLinkVisible()
|
|
235
|
+
}
|
|
236
|
+
}
|
|
237
|
+
}
|
|
238
|
+
</script>
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
<template>
|
|
2
|
+
<div class="theme-container">
|
|
3
|
+
<Content class="theme-default-content" />
|
|
4
|
+
<PageEdit />
|
|
5
|
+
|
|
6
|
+
<slot name="bottom" />
|
|
7
|
+
</div>
|
|
8
|
+
</template>
|
|
9
|
+
|
|
10
|
+
<script>
|
|
11
|
+
import PageEdit from '@theme/components/PageEdit.vue'
|
|
12
|
+
export default {
|
|
13
|
+
name: 'SimpleLayout',
|
|
14
|
+
components: {
|
|
15
|
+
PageEdit
|
|
16
|
+
}
|
|
17
|
+
}
|
|
18
|
+
</script>
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
export default {
|
|
2
|
+
inject: ['navConfig', 'customNavBar', 'changeUserNav', 'customNavBarKeys', 'navbarLanguage', 'customNavBarLinks'],
|
|
3
|
+
|
|
4
|
+
computed: {
|
|
5
|
+
showSubNavBar() {
|
|
6
|
+
return !!this.customNavBar[this.navConfig.userNavIndex].items
|
|
7
|
+
},
|
|
8
|
+
mainNavBarText() {
|
|
9
|
+
return this.customNavBar[this.navConfig.userNavIndex].text
|
|
10
|
+
},
|
|
11
|
+
subNavBarText() {
|
|
12
|
+
const curNavBar = this.customNavBar[this.navConfig.userNavIndex]
|
|
13
|
+
// fix: /uni-app-x/api/ 获取不到 subNavBarText
|
|
14
|
+
const curLink = (this.$page.path.match(/\/([^\/]+)\/([^\/]+)?/) || [])[1]
|
|
15
|
+
const item = curNavBar.items ? curNavBar.items.filter(
|
|
16
|
+
item => item.type === 'link' && item.link.indexOf(curLink) !== -1
|
|
17
|
+
)[0] : curNavBar
|
|
18
|
+
return item ? item.text : curNavBar.items[0].text
|
|
19
|
+
}
|
|
20
|
+
}
|
|
21
|
+
}
|
|
@@ -0,0 +1,65 @@
|
|
|
1
|
+
import { navbar, navbarLanguage, userNavIndex } from '@theme-config/navbar';
|
|
2
|
+
|
|
3
|
+
export default {
|
|
4
|
+
data() {
|
|
5
|
+
return { navConfig: { userNavIndex: userNavIndex || 0, languageIndex: navbarLanguage.default } }
|
|
6
|
+
},
|
|
7
|
+
|
|
8
|
+
provide() {
|
|
9
|
+
return {
|
|
10
|
+
navConfig: this.navConfig,
|
|
11
|
+
customNavBar: this.customNavBar,
|
|
12
|
+
changeUserNav: this.changeUserNav,
|
|
13
|
+
customNavBarKeys: this.customNavBarKeys,
|
|
14
|
+
customNavBarLinks: this.customNavBarLinks,
|
|
15
|
+
navbarLanguage: navbarLanguage.items
|
|
16
|
+
}
|
|
17
|
+
},
|
|
18
|
+
|
|
19
|
+
created() {
|
|
20
|
+
this.customNavBar.forEach((item, index) => {
|
|
21
|
+
if (this.$route.path.indexOf(item.link) !== -1 && item.link !== '/') this.navConfig.userNavIndex = index
|
|
22
|
+
})
|
|
23
|
+
},
|
|
24
|
+
|
|
25
|
+
computed: {
|
|
26
|
+
customNavBar() {
|
|
27
|
+
const list = []
|
|
28
|
+
navbar.forEach(item => {
|
|
29
|
+
if (item.items && item.items.length) {
|
|
30
|
+
list.push(item)
|
|
31
|
+
}
|
|
32
|
+
item.type === 'link' && list.push(item)
|
|
33
|
+
})
|
|
34
|
+
return list
|
|
35
|
+
},
|
|
36
|
+
|
|
37
|
+
customNavBarKeys() {
|
|
38
|
+
return this.customNavBar.map(item => item.text)
|
|
39
|
+
},
|
|
40
|
+
|
|
41
|
+
customNavBarLinks() {
|
|
42
|
+
return this.customNavBar.map(item => item.link)
|
|
43
|
+
}
|
|
44
|
+
},
|
|
45
|
+
|
|
46
|
+
methods: {
|
|
47
|
+
changeUserNav(index) {
|
|
48
|
+
this.navConfig.userNavIndex = index
|
|
49
|
+
const curNavBar = this.customNavBar[index]
|
|
50
|
+
const firstItemLink = curNavBar.items ? curNavBar.items[0].link : curNavBar.link
|
|
51
|
+
if (this.$page.path !== firstItemLink) this.$router.push(firstItemLink)
|
|
52
|
+
}
|
|
53
|
+
},
|
|
54
|
+
|
|
55
|
+
watch: {
|
|
56
|
+
$route(after) {
|
|
57
|
+
let navbarIndex = -1
|
|
58
|
+
this.customNavBarLinks.forEach((link, index) => {
|
|
59
|
+
if (after.path.indexOf(link) !== -1) navbarIndex = index
|
|
60
|
+
})
|
|
61
|
+
navbarIndex === -1 && (navbarIndex = 0)
|
|
62
|
+
this.navConfig.userNavIndex !== navbarIndex && navbarIndex !== -1 && (this.navConfig.userNavIndex = navbarIndex)
|
|
63
|
+
}
|
|
64
|
+
}
|
|
65
|
+
}
|
package/mixin/toc.js
ADDED
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
export default {
|
|
2
|
+
data() {
|
|
3
|
+
return {
|
|
4
|
+
paddingLeftOffset: 1,
|
|
5
|
+
pageHeaders: []
|
|
6
|
+
}
|
|
7
|
+
},
|
|
8
|
+
computed: {
|
|
9
|
+
visible() {
|
|
10
|
+
return (
|
|
11
|
+
this.$frontmatter &&
|
|
12
|
+
this.$frontmatter.toc !== false &&
|
|
13
|
+
!!(this.$page && this.$page.headers && this.$page.headers.length)
|
|
14
|
+
);
|
|
15
|
+
},
|
|
16
|
+
},
|
|
17
|
+
methods: {
|
|
18
|
+
createPaddingLeft(level) {
|
|
19
|
+
return level - this.paddingLeftOffset + 'rem';
|
|
20
|
+
},
|
|
21
|
+
},
|
|
22
|
+
watch: {
|
|
23
|
+
"$page.headers": {
|
|
24
|
+
immediate: true,
|
|
25
|
+
handler() {
|
|
26
|
+
if(this.$options.name === 'Layout') return
|
|
27
|
+
this.pageHeaders = (this.$page.headers || []).filter(item => item.level > 1)
|
|
28
|
+
if ((this.pageHeaders || []).length) {
|
|
29
|
+
this.paddingLeftOffset = this.pageHeaders
|
|
30
|
+
.map(item => item.level)
|
|
31
|
+
.sort((a, b) => a - b)[0];
|
|
32
|
+
}
|
|
33
|
+
}
|
|
34
|
+
}
|
|
35
|
+
}
|
|
36
|
+
}
|
package/package.json
ADDED
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "vuepress-theme-uniapp-official",
|
|
3
|
+
"version": "1.4.11",
|
|
4
|
+
"description": "uni-app official website theme for vuepress",
|
|
5
|
+
"main": "index.js",
|
|
6
|
+
"repository": {
|
|
7
|
+
"type": "git",
|
|
8
|
+
"url": "git+https://github.com/StrivingRabbit/vuepress-theme-uni-app.git"
|
|
9
|
+
},
|
|
10
|
+
"keywords": [
|
|
11
|
+
"uni-app"
|
|
12
|
+
],
|
|
13
|
+
"author": "lxh",
|
|
14
|
+
"license": "ISC",
|
|
15
|
+
"bugs": {
|
|
16
|
+
"url": "https://github.com/StrivingRabbit/vuepress-theme-uni-app/issues"
|
|
17
|
+
},
|
|
18
|
+
"homepage": "https://github.com/StrivingRabbit/vuepress-theme-uni-app#readme",
|
|
19
|
+
"files": [
|
|
20
|
+
"components",
|
|
21
|
+
"config",
|
|
22
|
+
"global-components",
|
|
23
|
+
"layouts",
|
|
24
|
+
"mixin",
|
|
25
|
+
"styles",
|
|
26
|
+
"util",
|
|
27
|
+
"enhanceApp.js",
|
|
28
|
+
"index.js"
|
|
29
|
+
],
|
|
30
|
+
"scripts": {
|
|
31
|
+
"publish:patch": "npm version patch && npm publish",
|
|
32
|
+
"publish:minor": "npm version minor && npm publish",
|
|
33
|
+
"publish:major": "npm version major && npm publish",
|
|
34
|
+
"postpublish": "cnpm sync vuepress-theme-uni-app"
|
|
35
|
+
},
|
|
36
|
+
"dependencies": {
|
|
37
|
+
"@vuepress/plugin-back-to-top": "^1.9.5",
|
|
38
|
+
"algoliasearch": "^4.13.1",
|
|
39
|
+
"clipboard": "^2.0.11",
|
|
40
|
+
"vuepress-plugin-check-md2": "^1.0.5",
|
|
41
|
+
"vuepress-plugin-expandable-row": "^1.0.5",
|
|
42
|
+
"vuepress-plugin-juejin-style-copy": "^1.0.4",
|
|
43
|
+
"vuepress-plugin-mermaidjs": "1.9.1",
|
|
44
|
+
"vuepress-plugin-named-chunks": "^1.1.4",
|
|
45
|
+
"vuepress-plugin-zooming": "^1.1.8",
|
|
46
|
+
"markdown-it-attrs": "^4.1.6",
|
|
47
|
+
"markdown-it-raw-table": "^1.0.0",
|
|
48
|
+
"markdown-it-task-lists": "^2.1.1"
|
|
49
|
+
}
|
|
50
|
+
}
|