vitepress-theme-element-plus 0.0.1 → 0.0.2
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/client/components/A11yTag.vue +29 -0
- package/client/components/ApiTyping.vue +54 -0
- package/client/components/Backdrop.vue +41 -0
- package/client/components/Bili.vue +94 -0
- package/client/components/Content.vue +150 -0
- package/client/components/DeprecatedTag.vue +19 -0
- package/client/components/Doc.vue +181 -0
- package/client/components/DocAside.vue +46 -0
- package/client/components/DocAsideOutline.vue +82 -0
- package/client/components/DocFooter.vue +159 -0
- package/client/components/Footer.vue +77 -0
- package/client/components/FooterCopyright.vue +27 -0
- package/client/components/Layout.vue +156 -0
- package/client/components/Link.vue +41 -0
- package/client/components/LocalNav.vue +160 -0
- package/client/components/Nav.vue +69 -0
- package/client/components/NavBar.vue +203 -0
- package/client/components/NavBarTitle.vue +75 -0
- package/client/components/Sidebar.vue +129 -0
- package/client/components/SidebarGroup.vue +51 -0
- package/client/components/SidebarItem.vue +302 -0
- package/client/components/Tag.vue +25 -0
- package/client/components/VPNavBarSearch.vue +23 -0
- package/client/components/VersionTag.vue +18 -0
- package/client/hooks/useBackTop.ts +74 -0
- package/client/hooks/useLangs.ts +50 -0
- package/client/hooks/useSidebar.ts +105 -0
- package/client/hooks/useSidebarControl.ts +78 -0
- package/client/hooks/useSize.ts +69 -0
- package/client/utils/client/common.ts +49 -0
- package/client/utils/client/outline.ts +113 -0
- package/client/utils/common.ts +86 -0
- package/dist/index.d.mts +5 -0
- package/dist/index.mjs +6 -0
- package/dist/markdown/plugins/external-link-icon.d.mts +6 -0
- package/dist/markdown/plugins/external-link-icon.mjs +26 -0
- package/dist/markdown/plugins/table-wrapper.d.mts +6 -0
- package/dist/markdown/plugins/table-wrapper.mjs +8 -0
- package/dist/markdown/plugins/tag.d.mts +6 -0
- package/dist/markdown/plugins/tag.mjs +25 -0
- package/dist/markdown/plugins/tooltip.d.mts +6 -0
- package/dist/markdown/plugins/tooltip.mjs +24 -0
- package/package.json +5 -5
- package/shared/constants.ts +3 -0
- package/styles/base.scss +37 -0
- package/styles/code.scss +283 -0
- package/styles/doc-content.scss +161 -0
- package/styles/index.scss +69 -0
- package/styles/tag-content.scss +30 -0
|
@@ -0,0 +1,159 @@
|
|
|
1
|
+
<script setup lang="ts">
|
|
2
|
+
import { ArrowLeft, ArrowRight } from '@element-plus/icons-vue'
|
|
3
|
+
import { ElIcon } from 'element-plus'
|
|
4
|
+
import { useData } from 'vitepress'
|
|
5
|
+
import VPDocFooterLastUpdated from 'vitepress/dist/client/theme-default/components/VPDocFooterLastUpdated.vue'
|
|
6
|
+
import VPLink from 'vitepress/dist/client/theme-default/components/VPLink.vue'
|
|
7
|
+
import { useEditLink } from 'vitepress/dist/client/theme-default/composables/edit-link.js'
|
|
8
|
+
import { usePrevNext } from 'vitepress/dist/client/theme-default/composables/prev-next.js'
|
|
9
|
+
import { computed } from 'vue'
|
|
10
|
+
|
|
11
|
+
const { theme, page, frontmatter } = useData()
|
|
12
|
+
|
|
13
|
+
const editLink = useEditLink()
|
|
14
|
+
const control = usePrevNext()
|
|
15
|
+
|
|
16
|
+
const hasEditLink = computed(
|
|
17
|
+
() => theme.value.editLink && frontmatter.value.editLink !== false,
|
|
18
|
+
)
|
|
19
|
+
const hasLastUpdated = computed(() => page.value.lastUpdated)
|
|
20
|
+
const showFooter = computed(
|
|
21
|
+
() =>
|
|
22
|
+
hasEditLink.value
|
|
23
|
+
|| hasLastUpdated.value
|
|
24
|
+
|| control.value.prev
|
|
25
|
+
|| control.value.next,
|
|
26
|
+
)
|
|
27
|
+
</script>
|
|
28
|
+
|
|
29
|
+
<template>
|
|
30
|
+
<footer v-if="showFooter" class="VPDocFooter">
|
|
31
|
+
<slot name="doc-footer-before" />
|
|
32
|
+
|
|
33
|
+
<div v-if="hasEditLink || hasLastUpdated" class="edit-info">
|
|
34
|
+
<div v-if="hasEditLink" class="edit-link">
|
|
35
|
+
<VPLink class="edit-link-button" :href="editLink.url" :no-icon="true">
|
|
36
|
+
<span class="vpi-square-pen edit-link-icon" />
|
|
37
|
+
{{ editLink.text }}
|
|
38
|
+
</VPLink>
|
|
39
|
+
</div>
|
|
40
|
+
|
|
41
|
+
<div v-if="hasLastUpdated" class="last-updated">
|
|
42
|
+
<VPDocFooterLastUpdated />
|
|
43
|
+
</div>
|
|
44
|
+
</div>
|
|
45
|
+
|
|
46
|
+
<nav
|
|
47
|
+
v-if="control.prev?.link || control.next?.link"
|
|
48
|
+
class="prev-next"
|
|
49
|
+
aria-labelledby="doc-footer-aria-label"
|
|
50
|
+
>
|
|
51
|
+
<span id="doc-footer-aria-label" class="visually-hidden">Pager</span>
|
|
52
|
+
|
|
53
|
+
<div class="pager prev">
|
|
54
|
+
<a v-if="control.prev?.link" :href="control.prev.link">
|
|
55
|
+
<ElIcon>
|
|
56
|
+
<ArrowLeft />
|
|
57
|
+
</ElIcon>
|
|
58
|
+
<span class="title" v-html="control.prev.text" />
|
|
59
|
+
</a>
|
|
60
|
+
</div>
|
|
61
|
+
<div class="pager next">
|
|
62
|
+
<a v-if="control.next?.link" :href="control.next.link">
|
|
63
|
+
<span class="title" v-html="control.next.text" />
|
|
64
|
+
<ElIcon>
|
|
65
|
+
<ArrowRight />
|
|
66
|
+
</ElIcon>
|
|
67
|
+
</a>
|
|
68
|
+
</div>
|
|
69
|
+
</nav>
|
|
70
|
+
</footer>
|
|
71
|
+
</template>
|
|
72
|
+
|
|
73
|
+
<style scoped>
|
|
74
|
+
.VPDocFooter {
|
|
75
|
+
margin-top: 64px;
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
.edit-info {
|
|
79
|
+
padding-bottom: 18px;
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
@media (min-width: 640px) {
|
|
83
|
+
.edit-info {
|
|
84
|
+
display: flex;
|
|
85
|
+
justify-content: space-between;
|
|
86
|
+
align-items: center;
|
|
87
|
+
padding-bottom: 14px;
|
|
88
|
+
}
|
|
89
|
+
}
|
|
90
|
+
|
|
91
|
+
.edit-link-button {
|
|
92
|
+
display: flex;
|
|
93
|
+
align-items: center;
|
|
94
|
+
border: 0;
|
|
95
|
+
line-height: 32px;
|
|
96
|
+
font-size: 14px;
|
|
97
|
+
font-weight: 500;
|
|
98
|
+
color: var(--vp-c-brand-1);
|
|
99
|
+
transition: color 0.25s;
|
|
100
|
+
}
|
|
101
|
+
|
|
102
|
+
.edit-link-button:hover {
|
|
103
|
+
color: var(--vp-c-brand-2);
|
|
104
|
+
}
|
|
105
|
+
|
|
106
|
+
.edit-link-icon {
|
|
107
|
+
margin-right: 8px;
|
|
108
|
+
}
|
|
109
|
+
|
|
110
|
+
.prev-next {
|
|
111
|
+
display: flex;
|
|
112
|
+
justify-content: space-between;
|
|
113
|
+
padding-top: 16px;
|
|
114
|
+
border-top: 1px solid var(--vp-c-divider);
|
|
115
|
+
}
|
|
116
|
+
|
|
117
|
+
.pager {
|
|
118
|
+
display: flex;
|
|
119
|
+
flex-shrink: 0;
|
|
120
|
+
width: 50%;
|
|
121
|
+
}
|
|
122
|
+
|
|
123
|
+
.pager a {
|
|
124
|
+
display: inline-flex;
|
|
125
|
+
justify-content: center;
|
|
126
|
+
align-items: center;
|
|
127
|
+
max-width: 100%;
|
|
128
|
+
height: 24px;
|
|
129
|
+
font-size: 14px;
|
|
130
|
+
font-weight: 500;
|
|
131
|
+
}
|
|
132
|
+
|
|
133
|
+
.pager.next {
|
|
134
|
+
justify-content: flex-end;
|
|
135
|
+
padding-right: 12px;
|
|
136
|
+
}
|
|
137
|
+
|
|
138
|
+
.next .el-icon {
|
|
139
|
+
margin-left: 4px;
|
|
140
|
+
}
|
|
141
|
+
|
|
142
|
+
.pager.prev {
|
|
143
|
+
justify-content: flex-start;
|
|
144
|
+
padding-left: 12px;
|
|
145
|
+
}
|
|
146
|
+
|
|
147
|
+
.prev .el-icon {
|
|
148
|
+
margin-right: 4px;
|
|
149
|
+
}
|
|
150
|
+
|
|
151
|
+
.title {
|
|
152
|
+
display: block;
|
|
153
|
+
line-height: 20px;
|
|
154
|
+
font-size: 14px;
|
|
155
|
+
font-weight: 500;
|
|
156
|
+
color: var(--vp-c-brand-1);
|
|
157
|
+
transition: color 0.25s;
|
|
158
|
+
}
|
|
159
|
+
</style>
|
|
@@ -0,0 +1,77 @@
|
|
|
1
|
+
<script lang="ts" setup>
|
|
2
|
+
import { ElLink } from 'element-plus'
|
|
3
|
+
import { useData } from 'vitepress'
|
|
4
|
+
import { useLayout } from 'vitepress/theme'
|
|
5
|
+
|
|
6
|
+
const { isHome } = useLayout()
|
|
7
|
+
const { theme } = useData()
|
|
8
|
+
const blogroll = theme.value.footer?.blogroll
|
|
9
|
+
</script>
|
|
10
|
+
|
|
11
|
+
<template>
|
|
12
|
+
<footer v-if="blogroll && blogroll.length" class="footer" :class="{ 'is-home': isHome }">
|
|
13
|
+
<div v-for="item of blogroll" :key="item.title" class="footer-main">
|
|
14
|
+
<h4>{{ item.title }}</h4>
|
|
15
|
+
<ElLink
|
|
16
|
+
v-for="child of item.children"
|
|
17
|
+
:key="child.title"
|
|
18
|
+
class="footer-main-link"
|
|
19
|
+
target="_blank"
|
|
20
|
+
type="info"
|
|
21
|
+
:href="child.href"
|
|
22
|
+
:underline="false"
|
|
23
|
+
>
|
|
24
|
+
{{ child.title }}
|
|
25
|
+
</ElLink>
|
|
26
|
+
</div>
|
|
27
|
+
</footer>
|
|
28
|
+
</template>
|
|
29
|
+
|
|
30
|
+
<style lang="scss">
|
|
31
|
+
.footer {
|
|
32
|
+
background-color: var(--vp-c-bg-soft);
|
|
33
|
+
box-sizing: border-box;
|
|
34
|
+
padding: 42px 64px 64px;
|
|
35
|
+
|
|
36
|
+
&.is-home {
|
|
37
|
+
background-color: var(--bg-color);
|
|
38
|
+
max-width: 1200px;
|
|
39
|
+
margin: 0 auto;
|
|
40
|
+
padding: 40px 0;
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
.container {
|
|
44
|
+
box-sizing: border-box;
|
|
45
|
+
width: auto;
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
.footer-main {
|
|
49
|
+
font-size: 0;
|
|
50
|
+
display: inline-block;
|
|
51
|
+
vertical-align: top;
|
|
52
|
+
margin-right: 130px;
|
|
53
|
+
|
|
54
|
+
h4 {
|
|
55
|
+
font-size: 18px;
|
|
56
|
+
line-height: 1;
|
|
57
|
+
margin: 0 0 15px;
|
|
58
|
+
font-weight: 400;
|
|
59
|
+
color: var(--el-text-color-primary);
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
.footer-main-link {
|
|
63
|
+
display: block;
|
|
64
|
+
margin: 0;
|
|
65
|
+
line-height: 2;
|
|
66
|
+
}
|
|
67
|
+
}
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
@media (max-width: 768px) {
|
|
71
|
+
.footer {
|
|
72
|
+
.footer-main {
|
|
73
|
+
margin-bottom: 30px;
|
|
74
|
+
}
|
|
75
|
+
}
|
|
76
|
+
}
|
|
77
|
+
</style>
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
<script lang="ts" setup>
|
|
2
|
+
import { ElDivider } from 'element-plus'
|
|
3
|
+
import { useData } from 'vitepress'
|
|
4
|
+
|
|
5
|
+
const { theme } = useData()
|
|
6
|
+
</script>
|
|
7
|
+
|
|
8
|
+
<template>
|
|
9
|
+
<template v-if="theme.footer?.message || theme.footer?.copyright">
|
|
10
|
+
<ElDivider style="margin-bottom: 0px" />
|
|
11
|
+
<div class="footer-copyright">
|
|
12
|
+
<p>{{ theme.footer?.message }}</p>
|
|
13
|
+
<p>{{ theme.footer?.copyright }}</p>
|
|
14
|
+
</div>
|
|
15
|
+
</template>
|
|
16
|
+
</template>
|
|
17
|
+
|
|
18
|
+
<style scoped lang="scss">
|
|
19
|
+
.footer-copyright {
|
|
20
|
+
display: flex;
|
|
21
|
+
flex-direction: column;
|
|
22
|
+
align-items: center;
|
|
23
|
+
padding: 24px 0;
|
|
24
|
+
font-size: 12px;
|
|
25
|
+
line-height: 24px;
|
|
26
|
+
}
|
|
27
|
+
</style>
|
|
@@ -0,0 +1,156 @@
|
|
|
1
|
+
<script setup lang="ts">
|
|
2
|
+
import { useData, useRoute } from 'vitepress'
|
|
3
|
+
import VPBackdrop from 'vitepress/dist/client/theme-default/components/VPBackdrop.vue'
|
|
4
|
+
import VPSkipLink from 'vitepress/dist/client/theme-default/components/VPSkipLink.vue'
|
|
5
|
+
import { layoutInfoInjectionKey, registerWatchers } from 'vitepress/dist/client/theme-default/composables/layout'
|
|
6
|
+
import { useSidebarControl } from 'vitepress/dist/client/theme-default/composables/sidebar'
|
|
7
|
+
import { computed, provide, useSlots, watch } from 'vue'
|
|
8
|
+
import { useCloseSidebarOnEscape } from '../hooks/useSidebar'
|
|
9
|
+
import Content from './Content.vue'
|
|
10
|
+
import LocalNav from './LocalNav.vue'
|
|
11
|
+
import Nav from './Nav.vue'
|
|
12
|
+
import Sidebar from './Sidebar.vue'
|
|
13
|
+
|
|
14
|
+
const { frontmatter } = useData()
|
|
15
|
+
|
|
16
|
+
useCloseSidebarOnEscape()
|
|
17
|
+
const {
|
|
18
|
+
isOpen: isSidebarOpen,
|
|
19
|
+
open: openSidebar,
|
|
20
|
+
close: closeSidebar,
|
|
21
|
+
} = useSidebarControl()
|
|
22
|
+
|
|
23
|
+
const route = useRoute()
|
|
24
|
+
watch(() => route.path, closeSidebar)
|
|
25
|
+
|
|
26
|
+
registerWatchers({ closeSidebar })
|
|
27
|
+
|
|
28
|
+
const slots = useSlots()
|
|
29
|
+
const heroImageSlotExists = computed(() => !!slots['home-hero-image'])
|
|
30
|
+
|
|
31
|
+
provide(layoutInfoInjectionKey, heroImageSlotExists)
|
|
32
|
+
</script>
|
|
33
|
+
|
|
34
|
+
<template>
|
|
35
|
+
<div v-if="frontmatter.layout !== false" class="Layout VMLayout" :class="frontmatter.pageClass">
|
|
36
|
+
<slot name="layout-top" />
|
|
37
|
+
<VPSkipLink />
|
|
38
|
+
<VPBackdrop class="backdrop" :show="isSidebarOpen" @click="closeSidebar()" />
|
|
39
|
+
<Nav>
|
|
40
|
+
<template #nav-bar-title-before>
|
|
41
|
+
<slot name="nav-bar-title-before" />
|
|
42
|
+
</template>
|
|
43
|
+
<template #nav-bar-title-after>
|
|
44
|
+
<slot name="nav-bar-title-after" />
|
|
45
|
+
</template>
|
|
46
|
+
<template #nav-bar-content-before>
|
|
47
|
+
<slot name="nav-bar-content-before" />
|
|
48
|
+
</template>
|
|
49
|
+
<template #nav-bar-content-after>
|
|
50
|
+
<slot name="nav-bar-content-after" />
|
|
51
|
+
</template>
|
|
52
|
+
<template #nav-screen-content-before>
|
|
53
|
+
<slot name="nav-screen-content-before" />
|
|
54
|
+
</template>
|
|
55
|
+
<template #nav-screen-content-after>
|
|
56
|
+
<slot name="nav-screen-content-after" />
|
|
57
|
+
</template>
|
|
58
|
+
</Nav>
|
|
59
|
+
<LocalNav :open="isSidebarOpen" @open-menu="openSidebar" />
|
|
60
|
+
|
|
61
|
+
<Sidebar :open="isSidebarOpen">
|
|
62
|
+
<template #sidebar-nav-before>
|
|
63
|
+
<slot name="sidebar-nav-before" />
|
|
64
|
+
</template>
|
|
65
|
+
<template #sidebar-nav-after>
|
|
66
|
+
<slot name="sidebar-nav-after" />
|
|
67
|
+
</template>
|
|
68
|
+
</Sidebar>
|
|
69
|
+
|
|
70
|
+
<Content>
|
|
71
|
+
<template #page-top>
|
|
72
|
+
<slot name="page-top" />
|
|
73
|
+
</template>
|
|
74
|
+
<template #page-bottom>
|
|
75
|
+
<slot name="page-bottom" />
|
|
76
|
+
</template>
|
|
77
|
+
|
|
78
|
+
<template #not-found>
|
|
79
|
+
<slot name="not-found" />
|
|
80
|
+
</template>
|
|
81
|
+
<template #home-hero-before>
|
|
82
|
+
<slot name="home-hero-before" />
|
|
83
|
+
</template>
|
|
84
|
+
<template #home-hero-info-before>
|
|
85
|
+
<slot name="home-hero-info-before" />
|
|
86
|
+
</template>
|
|
87
|
+
<template #home-hero-info>
|
|
88
|
+
<slot name="home-hero-info" />
|
|
89
|
+
</template>
|
|
90
|
+
<template #home-hero-info-after>
|
|
91
|
+
<slot name="home-hero-info-after" />
|
|
92
|
+
</template>
|
|
93
|
+
<template #home-hero-actions-after>
|
|
94
|
+
<slot name="home-hero-actions-after" />
|
|
95
|
+
</template>
|
|
96
|
+
<template #home-hero-image>
|
|
97
|
+
<slot name="home-hero-image" />
|
|
98
|
+
</template>
|
|
99
|
+
<template #home-hero-after>
|
|
100
|
+
<slot name="home-hero-after" />
|
|
101
|
+
</template>
|
|
102
|
+
<template #home-features-before>
|
|
103
|
+
<slot name="home-features-before" />
|
|
104
|
+
</template>
|
|
105
|
+
<template #home-features-after>
|
|
106
|
+
<slot name="home-features-after" />
|
|
107
|
+
</template>
|
|
108
|
+
|
|
109
|
+
<template #doc-footer-before>
|
|
110
|
+
<slot name="doc-footer-before" />
|
|
111
|
+
</template>
|
|
112
|
+
<template #doc-before>
|
|
113
|
+
<slot name="doc-before" />
|
|
114
|
+
</template>
|
|
115
|
+
<template #doc-after>
|
|
116
|
+
<slot name="doc-after" />
|
|
117
|
+
</template>
|
|
118
|
+
<template #doc-top>
|
|
119
|
+
<slot name="doc-top" />
|
|
120
|
+
</template>
|
|
121
|
+
<template #doc-bottom>
|
|
122
|
+
<slot name="doc-bottom" />
|
|
123
|
+
</template>
|
|
124
|
+
|
|
125
|
+
<template #aside-top>
|
|
126
|
+
<slot name="aside-top" />
|
|
127
|
+
</template>
|
|
128
|
+
<template #aside-bottom>
|
|
129
|
+
<slot name="aside-bottom" />
|
|
130
|
+
</template>
|
|
131
|
+
<template #aside-outline-before>
|
|
132
|
+
<slot name="aside-outline-before" />
|
|
133
|
+
</template>
|
|
134
|
+
<template #aside-outline-after>
|
|
135
|
+
<slot name="aside-outline-after" />
|
|
136
|
+
</template>
|
|
137
|
+
<template #aside-ads-before>
|
|
138
|
+
<slot name="aside-ads-before" />
|
|
139
|
+
</template>
|
|
140
|
+
<template #aside-ads-after>
|
|
141
|
+
<slot name="aside-ads-after" />
|
|
142
|
+
</template>
|
|
143
|
+
</Content>
|
|
144
|
+
|
|
145
|
+
<slot name="layout-bottom" />
|
|
146
|
+
</div>
|
|
147
|
+
<Content v-else />
|
|
148
|
+
</template>
|
|
149
|
+
|
|
150
|
+
<style scoped lang="scss">
|
|
151
|
+
.Layout {
|
|
152
|
+
display: flex;
|
|
153
|
+
flex-direction: column;
|
|
154
|
+
min-height: 100vh;
|
|
155
|
+
}
|
|
156
|
+
</style>
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
<script lang="ts" setup>
|
|
2
|
+
import { ElIcon } from 'element-plus'
|
|
3
|
+
import { EXTERNAL_URL_RE } from 'vitepress/dist/client/shared.js'
|
|
4
|
+
import { normalizeLink } from 'vitepress/dist/client/theme-default/support/utils.js'
|
|
5
|
+
import { computed } from 'vue'
|
|
6
|
+
|
|
7
|
+
const props = defineProps<{
|
|
8
|
+
tag?: string
|
|
9
|
+
href?: string
|
|
10
|
+
noIcon?: boolean
|
|
11
|
+
target?: string
|
|
12
|
+
rel?: string
|
|
13
|
+
}>()
|
|
14
|
+
|
|
15
|
+
const tag = computed(() => props.tag ?? (props.href ? 'a' : 'span'))
|
|
16
|
+
const isExternal = computed(
|
|
17
|
+
() =>
|
|
18
|
+
(props.href && EXTERNAL_URL_RE.test(props.href))
|
|
19
|
+
|| props.target === '_blank',
|
|
20
|
+
)
|
|
21
|
+
</script>
|
|
22
|
+
|
|
23
|
+
<template>
|
|
24
|
+
<component
|
|
25
|
+
:is="tag"
|
|
26
|
+
class="VPLink"
|
|
27
|
+
:class="{
|
|
28
|
+
'link': href,
|
|
29
|
+
'vp-external-link-icon': isExternal,
|
|
30
|
+
'no-icon': noIcon,
|
|
31
|
+
}"
|
|
32
|
+
:href="href ? normalizeLink(href) : undefined"
|
|
33
|
+
:target="target ?? (isExternal ? '_blank' : undefined)"
|
|
34
|
+
:rel="rel ?? (isExternal ? 'noreferrer' : undefined)"
|
|
35
|
+
>
|
|
36
|
+
<slot />
|
|
37
|
+
<ElIcon v-if="href && isExternal && !noIcon">
|
|
38
|
+
<svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewBox="0 0 24 24"><path fill="currentColor" d="M10 6v2H5v11h11v-5h2v6a1 1 0 0 1-1 1H4a1 1 0 0 1-1-1V7a1 1 0 0 1 1-1zm11-3v8h-2V6.413l-7.793 7.794l-1.414-1.414L17.585 5H13V3z" /></svg>
|
|
39
|
+
</ElIcon>
|
|
40
|
+
</component>
|
|
41
|
+
</template>
|
|
@@ -0,0 +1,160 @@
|
|
|
1
|
+
<script lang="ts" setup>
|
|
2
|
+
import { useWindowScroll } from '@vueuse/core'
|
|
3
|
+
import { ElButton } from 'element-plus'
|
|
4
|
+
import { useData } from 'vitepress'
|
|
5
|
+
import { useLayout } from 'vitepress/theme'
|
|
6
|
+
import { computed, onMounted, ref } from 'vue'
|
|
7
|
+
import { useBackTop } from '../hooks/useBackTop'
|
|
8
|
+
import 'element-plus/theme-chalk/el-button.css'
|
|
9
|
+
|
|
10
|
+
defineProps<{
|
|
11
|
+
open: boolean
|
|
12
|
+
}>()
|
|
13
|
+
|
|
14
|
+
defineEmits<{
|
|
15
|
+
(e: 'openMenu'): void
|
|
16
|
+
}>()
|
|
17
|
+
|
|
18
|
+
const { theme } = useData()
|
|
19
|
+
const { isHome, hasSidebar, hasLocalNav } = useLayout()
|
|
20
|
+
const { y } = useWindowScroll()
|
|
21
|
+
|
|
22
|
+
const navHeight = ref(0)
|
|
23
|
+
|
|
24
|
+
onMounted(() => {
|
|
25
|
+
navHeight.value = Number.parseInt(
|
|
26
|
+
getComputedStyle(document.documentElement).getPropertyValue(
|
|
27
|
+
'--vp-nav-height',
|
|
28
|
+
),
|
|
29
|
+
)
|
|
30
|
+
})
|
|
31
|
+
|
|
32
|
+
const classes = computed(() => {
|
|
33
|
+
return {
|
|
34
|
+
'VPLocalNav': true,
|
|
35
|
+
'has-sidebar': hasSidebar.value,
|
|
36
|
+
'empty': !hasLocalNav.value,
|
|
37
|
+
'fixed': !hasLocalNav.value && !hasSidebar.value,
|
|
38
|
+
}
|
|
39
|
+
})
|
|
40
|
+
|
|
41
|
+
const { shouldShow, scrollToTop } = useBackTop()
|
|
42
|
+
</script>
|
|
43
|
+
|
|
44
|
+
<template>
|
|
45
|
+
<div
|
|
46
|
+
v-if="!isHome && (hasLocalNav || hasSidebar || y >= navHeight)"
|
|
47
|
+
:class="classes"
|
|
48
|
+
>
|
|
49
|
+
<div class="container">
|
|
50
|
+
<button
|
|
51
|
+
v-if="hasSidebar"
|
|
52
|
+
class="menu"
|
|
53
|
+
:aria-expanded="open"
|
|
54
|
+
aria-controls="VPSidebarNav"
|
|
55
|
+
@click="$emit('openMenu')"
|
|
56
|
+
>
|
|
57
|
+
<span class="vpi-align-left menu-icon" />
|
|
58
|
+
<span class="menu-text">
|
|
59
|
+
{{ theme.sidebarMenuLabel || 'Menu' }}
|
|
60
|
+
</span>
|
|
61
|
+
</button>
|
|
62
|
+
<Transition name="shifting">
|
|
63
|
+
<ElButton
|
|
64
|
+
:class="{ show: shouldShow }"
|
|
65
|
+
link
|
|
66
|
+
class="height-5 go-back-top"
|
|
67
|
+
@click.prevent.stop="scrollToTop"
|
|
68
|
+
>
|
|
69
|
+
Back to top
|
|
70
|
+
</ElButton>
|
|
71
|
+
</Transition>
|
|
72
|
+
</div>
|
|
73
|
+
</div>
|
|
74
|
+
</template>
|
|
75
|
+
|
|
76
|
+
<style scoped>
|
|
77
|
+
.VPLocalNav {
|
|
78
|
+
position: sticky;
|
|
79
|
+
top: 0;
|
|
80
|
+
/*rtl:ignore*/
|
|
81
|
+
left: 0;
|
|
82
|
+
z-index: var(--vp-z-index-local-nav);
|
|
83
|
+
border-bottom: 1px solid var(--vp-c-gutter);
|
|
84
|
+
padding-top: var(--vp-layout-top-height, 0px);
|
|
85
|
+
width: 100%;
|
|
86
|
+
background-color: var(--vp-local-nav-bg-color);
|
|
87
|
+
overflow: hidden;
|
|
88
|
+
}
|
|
89
|
+
|
|
90
|
+
.VPLocalNav.fixed {
|
|
91
|
+
position: fixed;
|
|
92
|
+
}
|
|
93
|
+
|
|
94
|
+
@media (min-width: 960px) {
|
|
95
|
+
.VPLocalNav {
|
|
96
|
+
display: none;
|
|
97
|
+
}
|
|
98
|
+
}
|
|
99
|
+
|
|
100
|
+
@media (min-width: 1440px) {
|
|
101
|
+
.VPLocalNav {
|
|
102
|
+
display: none;
|
|
103
|
+
}
|
|
104
|
+
}
|
|
105
|
+
|
|
106
|
+
.container {
|
|
107
|
+
display: flex;
|
|
108
|
+
justify-content: space-between;
|
|
109
|
+
align-items: center;
|
|
110
|
+
}
|
|
111
|
+
|
|
112
|
+
.menu {
|
|
113
|
+
display: flex;
|
|
114
|
+
align-items: center;
|
|
115
|
+
line-height: 24px;
|
|
116
|
+
font-size: 16px;
|
|
117
|
+
font-weight: 500;
|
|
118
|
+
color: var(--vp-c-text-2);
|
|
119
|
+
transition: color 0.5s;
|
|
120
|
+
}
|
|
121
|
+
|
|
122
|
+
.menu:hover {
|
|
123
|
+
color: var(--vp-c-text-1);
|
|
124
|
+
transition: color 0.25s;
|
|
125
|
+
}
|
|
126
|
+
|
|
127
|
+
@media (min-width: 960px) {
|
|
128
|
+
.menu {
|
|
129
|
+
display: none;
|
|
130
|
+
}
|
|
131
|
+
}
|
|
132
|
+
|
|
133
|
+
.menu-icon {
|
|
134
|
+
margin-right: 8px;
|
|
135
|
+
font-size: 16px;
|
|
136
|
+
}
|
|
137
|
+
|
|
138
|
+
.menu,
|
|
139
|
+
:deep(.VPLocalNavOutlineDropdown > button) {
|
|
140
|
+
padding: 12px 24px 11px;
|
|
141
|
+
}
|
|
142
|
+
|
|
143
|
+
@media (min-width: 768px) {
|
|
144
|
+
.menu,
|
|
145
|
+
:deep(.VPLocalNavOutlineDropdown > button) {
|
|
146
|
+
padding: 12px 32px 11px;
|
|
147
|
+
}
|
|
148
|
+
}
|
|
149
|
+
|
|
150
|
+
.go-back-top {
|
|
151
|
+
transform: translateY(100%);
|
|
152
|
+
opacity: 0;
|
|
153
|
+
padding: 12px 32px 11px;
|
|
154
|
+
|
|
155
|
+
&.show {
|
|
156
|
+
transform: translateY(0);
|
|
157
|
+
opacity: 1;
|
|
158
|
+
}
|
|
159
|
+
}
|
|
160
|
+
</style>
|
|
@@ -0,0 +1,69 @@
|
|
|
1
|
+
<script setup lang="ts">
|
|
2
|
+
import { inBrowser } from 'vitepress'
|
|
3
|
+
import { useData } from 'vitepress/client'
|
|
4
|
+
import VPNavScreen from 'vitepress/dist/client/theme-default/components/VPNavScreen.vue'
|
|
5
|
+
import { navInjectionKey, useNav } from 'vitepress/dist/client/theme-default/composables/nav'
|
|
6
|
+
import { computed, provide, watchEffect } from 'vue'
|
|
7
|
+
import NavBar from './NavBar.vue'
|
|
8
|
+
|
|
9
|
+
const { isScreenOpen, closeScreen, toggleScreen } = useNav()
|
|
10
|
+
const { frontmatter } = useData()
|
|
11
|
+
|
|
12
|
+
const hasNavbar = computed(() => {
|
|
13
|
+
return frontmatter.value.navbar !== false
|
|
14
|
+
})
|
|
15
|
+
|
|
16
|
+
provide(navInjectionKey, { closeScreen })
|
|
17
|
+
|
|
18
|
+
watchEffect(() => {
|
|
19
|
+
if (inBrowser) {
|
|
20
|
+
document.documentElement.classList.toggle('hide-nav', !hasNavbar.value)
|
|
21
|
+
}
|
|
22
|
+
})
|
|
23
|
+
</script>
|
|
24
|
+
|
|
25
|
+
<template>
|
|
26
|
+
<header v-if="hasNavbar" class="VPNav">
|
|
27
|
+
<NavBar :is-screen-open="isScreenOpen" @toggle-screen="toggleScreen">
|
|
28
|
+
<template #nav-bar-title-before>
|
|
29
|
+
<slot name="nav-bar-title-before" />
|
|
30
|
+
</template>
|
|
31
|
+
<template #nav-bar-title-after>
|
|
32
|
+
<slot name="nav-bar-title-after" />
|
|
33
|
+
</template>
|
|
34
|
+
<template #nav-bar-content-before>
|
|
35
|
+
<slot name="nav-bar-content-before" />
|
|
36
|
+
</template>
|
|
37
|
+
<template #nav-bar-content-after>
|
|
38
|
+
<slot name="nav-bar-content-after" />
|
|
39
|
+
</template>
|
|
40
|
+
</NavBar>
|
|
41
|
+
<VPNavScreen :open="isScreenOpen">
|
|
42
|
+
<template #nav-screen-content-before>
|
|
43
|
+
<slot name="nav-screen-content-before" />
|
|
44
|
+
</template>
|
|
45
|
+
<template #nav-screen-content-after>
|
|
46
|
+
<slot name="nav-screen-content-after" />
|
|
47
|
+
</template>
|
|
48
|
+
</VPNavScreen>
|
|
49
|
+
</header>
|
|
50
|
+
</template>
|
|
51
|
+
|
|
52
|
+
<style scoped>
|
|
53
|
+
.VPNav {
|
|
54
|
+
position: relative;
|
|
55
|
+
top: var(--vp-layout-top-height, 0px);
|
|
56
|
+
/*rtl:ignore*/
|
|
57
|
+
left: 0;
|
|
58
|
+
z-index: var(--vp-z-index-nav);
|
|
59
|
+
width: 100%;
|
|
60
|
+
pointer-events: none;
|
|
61
|
+
transition: background-color 0.5s;
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
@media (min-width: 960px) {
|
|
65
|
+
.VPNav {
|
|
66
|
+
position: fixed;
|
|
67
|
+
}
|
|
68
|
+
}
|
|
69
|
+
</style>
|