|
| 1 | +<!-- |
| 2 | + * @Author: weisheng |
| 3 | + * @Date: 2024-12-07 18:41:41 |
| 4 | + * @LastEditTime: 2024-12-07 21:28:08 |
| 5 | + * @LastEditors: weisheng |
| 6 | + * @Description: |
| 7 | + * @FilePath: /wot-design-uni/docs/.vitepress/theme/components/VPContent.vue |
| 8 | + * 记得注释 |
| 9 | +--> |
| 10 | +<script setup lang="ts"> |
| 11 | +import { useData } from 'vitepress'; |
| 12 | +import NotFound from 'vitepress/dist/client/theme-default//NotFound.vue' |
| 13 | +import VPDoc from './VPDoc.vue' |
| 14 | +import VPHome from 'vitepress/dist/client/theme-default/components/VPHome.vue' |
| 15 | +import VPPage from 'vitepress/dist/client/theme-default/components/VPPage.vue' |
| 16 | +import { useSidebar } from 'vitepress/theme'; |
| 17 | +
|
| 18 | +
|
| 19 | +const { page, frontmatter }:any = useData() |
| 20 | +const { hasSidebar } = useSidebar() |
| 21 | +</script> |
| 22 | + |
| 23 | +<template> |
| 24 | + <div |
| 25 | + class="VPContent" |
| 26 | + id="VPContent" |
| 27 | + :class="{ |
| 28 | + 'has-sidebar': hasSidebar, |
| 29 | + 'is-home': frontmatter.layout === 'home' |
| 30 | + }" |
| 31 | + > |
| 32 | + <slot name="not-found" v-if="page.isNotFound"><NotFound /></slot> |
| 33 | + |
| 34 | + <VPPage v-else-if="frontmatter.layout === 'page'"> |
| 35 | + <template #page-top><slot name="page-top" /></template> |
| 36 | + <template #page-bottom><slot name="page-bottom" /></template> |
| 37 | + </VPPage> |
| 38 | + |
| 39 | + <VPHome v-else-if="frontmatter.layout === 'home'"> |
| 40 | + <template #home-hero-before><slot name="home-hero-before" /></template> |
| 41 | + <template #home-hero-info-before><slot name="home-hero-info-before" /></template> |
| 42 | + <template #home-hero-info><slot name="home-hero-info" /></template> |
| 43 | + <template #home-hero-info-after><slot name="home-hero-info-after" /></template> |
| 44 | + <template #home-hero-actions-after><slot name="home-hero-actions-after" /></template> |
| 45 | + <template #home-hero-image><slot name="home-hero-image" /></template> |
| 46 | + <template #home-hero-after><slot name="home-hero-after" /></template> |
| 47 | + <template #home-features-before><slot name="home-features-before" /></template> |
| 48 | + <template #home-features-after><slot name="home-features-after" /></template> |
| 49 | + </VPHome> |
| 50 | + |
| 51 | + <component |
| 52 | + v-else-if="frontmatter.layout && frontmatter.layout !== 'doc'" |
| 53 | + :is="frontmatter.layout" |
| 54 | + /> |
| 55 | + |
| 56 | + <VPDoc v-else> |
| 57 | + <template #doc-top><slot name="doc-top" /></template> |
| 58 | + <template #doc-bottom><slot name="doc-bottom" /></template> |
| 59 | + |
| 60 | + <template #doc-footer-before><slot name="doc-footer-before" /></template> |
| 61 | + <template #doc-before><slot name="doc-before" /></template> |
| 62 | + <template #doc-after><slot name="doc-after" /></template> |
| 63 | + |
| 64 | + <template #aside-top><slot name="aside-top" /></template> |
| 65 | + <template #aside-outline-before><slot name="aside-outline-before" /></template> |
| 66 | + <template #aside-outline-after><slot name="aside-outline-after" /></template> |
| 67 | + <template #aside-ads-before><slot name="aside-ads-before" /></template> |
| 68 | + <template #aside-ads-after><slot name="aside-ads-after" /></template> |
| 69 | + <template #aside-bottom><slot name="aside-bottom" /></template> |
| 70 | + </VPDoc> |
| 71 | + </div> |
| 72 | +</template> |
| 73 | + |
| 74 | +<style scoped> |
| 75 | +.VPContent { |
| 76 | + flex-grow: 1; |
| 77 | + flex-shrink: 0; |
| 78 | + margin: var(--vp-layout-top-height, 0px) auto 0; |
| 79 | + width: 100%; |
| 80 | +} |
| 81 | +
|
| 82 | +.VPContent.is-home { |
| 83 | + width: 100%; |
| 84 | + max-width: 100%; |
| 85 | +} |
| 86 | +
|
| 87 | +.VPContent.has-sidebar { |
| 88 | + margin: 0; |
| 89 | +} |
| 90 | +
|
| 91 | +.VPNavBar.container{ |
| 92 | + max-width: none; |
| 93 | +} |
| 94 | +
|
| 95 | +@media (min-width: 960px) { |
| 96 | + .VPContent { |
| 97 | + padding-top: var(--vp-nav-height); |
| 98 | + } |
| 99 | +
|
| 100 | + .VPContent.has-sidebar { |
| 101 | + margin: var(--vp-layout-top-height, 0px) 0 0; |
| 102 | + padding-left: var(--vp-sidebar-width); |
| 103 | + } |
| 104 | +} |
| 105 | +</style> |
| 106 | + |
| 107 | + |
0 commit comments