Skip to content
This repository has been archived by the owner on Sep 30, 2024. It is now read-only.

Commit

Permalink
chore: update docs
Browse files Browse the repository at this point in the history
  • Loading branch information
anncwb committed Sep 28, 2024
1 parent c587f59 commit 90e09e5
Show file tree
Hide file tree
Showing 2 changed files with 142 additions and 120 deletions.
239 changes: 119 additions & 120 deletions .vitepress/theme-default/Layout.vue
Original file line number Diff line number Diff line change
@@ -1,6 +1,19 @@
<template>
<div class="theme" :class="pageClasses">
<NavBar v-if="showNavbar" @toggle="toggleSidebar">
<V5 />
<div
class="theme"
:class="pageClasses"
:style="{
paddingTop: '60px',
}"
>
<NavBar
v-if="showNavbar"
@toggle="toggleSidebar"
:style="{
top: '60px',
}"
>
<template #search>
<slot name="navbar-search">
<AlgoliaSearchBox
Expand Down Expand Up @@ -41,10 +54,7 @@
<Page v-else>
<template #top>
<slot name="page-top-ads">
<div
id="ads-container"
v-if="theme.carbonAds && theme.carbonAds.carbon"
>
<div id="ads-container" v-if="theme.carbonAds && theme.carbonAds.carbon">
<CarbonAds
:key="'carbon' + page.relativePath"
:code="theme.carbonAds.carbon"
Expand Down Expand Up @@ -72,129 +82,118 @@
</template>

<script setup lang="ts">
import { ref, computed, watch, defineAsyncComponent } from 'vue'
import {
useRoute,
useSiteData,
usePageData,
useSiteDataByRoute
} from 'vitepress'
import { isSideBarEmpty, getSideBarConfig } from './support/sideBar'
import type { DefaultTheme } from './config'
// components
import NavBar from './components/NavBar.vue'
import SideBar from './components/SideBar.vue'
import Page from './components/Page.vue'
const Home = defineAsyncComponent(() => import('./components/Home.vue'))
const NoopComponent = () => null
const CarbonAds = __CARBON__
? defineAsyncComponent(() => import('./components/CarbonAds.vue'))
: NoopComponent
const BuySellAds = __BSA__
? defineAsyncComponent(() => import('./components/BuySellAds.vue'))
: NoopComponent
const AlgoliaSearchBox = __ALGOLIA__
? defineAsyncComponent(() => import('./components/AlgoliaSearchBox.vue'))
: NoopComponent
// generic state
const route = useRoute()
const siteData = useSiteData<DefaultTheme.Config>()
const siteRouteData = useSiteDataByRoute()
const theme = computed(() => siteData.value.themeConfig)
const page = usePageData()
// custom layout
const isCustomLayout = computed(() => !!route.data.frontmatter.customLayout)
// home
const enableHome = computed(() => !!route.data.frontmatter.home)
// navbar
const showNavbar = computed(() => {
const { themeConfig } = siteRouteData.value
const { frontmatter } = route.data
if (frontmatter.navbar === false || themeConfig.navbar === false) {
return false
}
return (
siteData.value.title ||
themeConfig.logo ||
themeConfig.repo ||
themeConfig.nav
)
})
// sidebar
const openSideBar = ref(false)
const showSidebar = computed(() => {
const { frontmatter } = route.data
if (frontmatter.home || frontmatter.sidebar === false) {
return false
}
import V5 from './V5.vue';
import { ref, computed, watch, defineAsyncComponent } from 'vue';
import { useRoute, useSiteData, usePageData, useSiteDataByRoute } from 'vitepress';
import { isSideBarEmpty, getSideBarConfig } from './support/sideBar';
import type { DefaultTheme } from './config';
// components
import NavBar from './components/NavBar.vue';
import SideBar from './components/SideBar.vue';
import Page from './components/Page.vue';
const Home = defineAsyncComponent(() => import('./components/Home.vue'));
const NoopComponent = () => null;
const CarbonAds = __CARBON__
? defineAsyncComponent(() => import('./components/CarbonAds.vue'))
: NoopComponent;
const BuySellAds = __BSA__
? defineAsyncComponent(() => import('./components/BuySellAds.vue'))
: NoopComponent;
const AlgoliaSearchBox = __ALGOLIA__
? defineAsyncComponent(() => import('./components/AlgoliaSearchBox.vue'))
: NoopComponent;
// generic state
const route = useRoute();
const siteData = useSiteData<DefaultTheme.Config>();
const siteRouteData = useSiteDataByRoute();
const theme = computed(() => siteData.value.themeConfig);
const page = usePageData();
// custom layout
const isCustomLayout = computed(() => !!route.data.frontmatter.customLayout);
// home
const enableHome = computed(() => !!route.data.frontmatter.home);
// navbar
const showNavbar = computed(() => {
const { themeConfig } = siteRouteData.value;
const { frontmatter } = route.data;
if (frontmatter.navbar === false || themeConfig.navbar === false) {
return false;
}
return siteData.value.title || themeConfig.logo || themeConfig.repo || themeConfig.nav;
});
// sidebar
const openSideBar = ref(false);
const { themeConfig } = siteRouteData.value
return !isSideBarEmpty(
getSideBarConfig(themeConfig.sidebar, route.data.relativePath)
)
})
const toggleSidebar = (to?: boolean) => {
openSideBar.value = typeof to === 'boolean' ? to : !openSideBar.value
}
const hideSidebar = toggleSidebar.bind(null, false)
// close the sidebar when navigating to a different location
watch(route, hideSidebar)
// TODO: route only changes when the pathname changes
// listening to hashchange does nothing because it's prevented in router
// page classes
const pageClasses = computed(() => {
return [
{
'no-navbar': !showNavbar.value,
'sidebar-open': openSideBar.value,
'no-sidebar': !showSidebar.value
const showSidebar = computed(() => {
const { frontmatter } = route.data;
if (frontmatter.home || frontmatter.sidebar === false) {
return false;
}
]
})
const { themeConfig } = siteRouteData.value;
return !isSideBarEmpty(getSideBarConfig(themeConfig.sidebar, route.data.relativePath));
});
const toggleSidebar = (to?: boolean) => {
openSideBar.value = typeof to === 'boolean' ? to : !openSideBar.value;
};
const hideSidebar = toggleSidebar.bind(null, false);
// close the sidebar when navigating to a different location
watch(route, hideSidebar);
// TODO: route only changes when the pathname changes
// listening to hashchange does nothing because it's prevented in router
// page classes
const pageClasses = computed(() => {
return [
{
'no-navbar': !showNavbar.value,
'sidebar-open': openSideBar.value,
'no-sidebar': !showSidebar.value,
},
];
});
</script>

<style>
#ads-container {
margin: 0 auto;
}
@media (min-width: 420px) {
#ads-container {
position: relative;
right: 0;
float: right;
margin: -8px -8px 24px 24px;
width: 146px;
margin: 0 auto;
}
}
@media (max-width: 420px) {
#ads-container {
/* Avoid layout shift */
height: 105px;
margin: 1.75rem 0;
@media (min-width: 420px) {
#ads-container {
position: relative;
right: 0;
float: right;
margin: -8px -8px 24px 24px;
width: 146px;
}
}
}
@media (min-width: 1400px) {
#ads-container {
position: fixed;
right: 8px;
bottom: 8px;
@media (max-width: 420px) {
#ads-container {
/* Avoid layout shift */
height: 105px;
margin: 1.75rem 0;
}
}
@media (min-width: 1400px) {
#ads-container {
position: fixed;
right: 8px;
bottom: 8px;
}
}
}
</style>
23 changes: 23 additions & 0 deletions .vitepress/theme-default/V5.vue
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
<template>
<div class="vben-v5">
你正在查看的是 2.0 版本文档,当前最新版本为 v5.0,预览地址为
<a href="https://vben.pro" target="_blank">预览地址</a>。 如果你想要查看新版本文档,请点击
<a href="https://doc.vben.pro/" target="_blank"> V5 文档 </a> 查看最新文档。
</div>
</template>

<style scoped>
.vben-v5 {
position: fixed;
height: 60px;
z-index: 1000;
top: 0;
left: 0;
background: rgb(246, 197, 20);
width: 100%;
display: flex;
justify-content: center;
align-items: center;
color: #333;
}
</style>

0 comments on commit 90e09e5

Please sign in to comment.