11<!-- 文章的默认布局 -->
22<script lang="ts" setup>
3- import { computed , onMounted , watch } from " vue" ;
3+ import { computed , defineAsyncComponent , onMounted , watch } from " vue" ;
44import { Layout } from ' vuepress-theme-plume/client'
55import { isMobileDevice } from " ../utils/env" ;
66import Backlink from " ../plugins/BiGraph/client/components/Backlink.vue" ;
77import LocalGraph from " ../plugins/BiGraph/client/components/LocalGraphView.vue" ;
88import GlobalGraph from " ../plugins/BiGraph/client/components/GlobalGraphView.vue" ;
99import AuthorLink from " ../plugins/vuepress-plugin-sillot-author/components/AuthorLink.vue" ;
10- import SiteSettings from " ../plugins/vuepress-plugin-sillot-site-settings/components/SiteSettings.vue" ;
1110import mSiteSettings from " ../plugins/vuepress-plugin-sillot-site-settings/components/mSiteSettings.vue" ;
11+ import NSiteSettings from " ../plugins/vuepress-plugin-sillot-site-settings/components/NSiteSettings.vue" ;
1212// https://theme-plume.vuejs.press/guide/api/client/#usedarkmode
1313import { useDarkMode } from " vuepress-theme-plume/composables" ;
1414// <n-config-provider :theme="isDark ? darkTheme : lightTheme"> 包裹 vuepress-theme-plume/client 的 <Layout>
1515import { darkTheme , lightTheme } from ' naive-ui'
16+ import { useDeviceDetection } from " ../plugins/vuepress-plugin-sillot-site-settings/composables/useDeviceDetection" ;
1617const isDark = useDarkMode ();
1718const updateDarkMode = () => {
1819 if (isDark .value ) {
@@ -23,6 +24,12 @@ const updateDarkMode = () => {
2324 document .documentElement .removeAttribute (" theme-mode" );
2425 }
2526};
27+ const { isMobile, componentKey } = useDeviceDetection ()
28+
29+ const currentComponent = computed (() =>
30+ isMobile .value ? mSiteSettings : NSiteSettings
31+ )
32+
2633watch (isDark , (newValue ) => {
2734 updateDarkMode ();
2835});
@@ -41,22 +48,25 @@ const options = computed(() => {
4148
4249<template >
4350 <n-config-provider :theme =" isDark ? darkTheme : lightTheme" >
44- <global-graph v-if =" options.enableGlobalGraph" ></global-graph >
45- <Layout >
46- <template #doc-footer-before >
47- <backlink ></backlink >
48- </template >
49- <template #nav-bar-content-after >
50- <mSiteSettings v-if =" isMobileDevice()" />
51- <SiteSettings v-if =" !isMobileDevice()" />
52- </template >
53- <template #aside-outline-before >
54- <local-graph v-if =" options.enableLocalGraph" ></local-graph >
55- </template >
56- <template #doc-meta-bottom >
57- <AuthorLink ></AuthorLink >
58- </template >
59- </Layout >
51+ <n-message-provider >
52+ <global-graph v-if =" options.enableGlobalGraph" ></global-graph >
53+ <Layout >
54+ <template #doc-footer-before >
55+ <backlink ></backlink >
56+ </template >
57+ <template #nav-bar-content-after >
58+ <ClientOnly >
59+ <component :is =" currentComponent" :key =" componentKey" />
60+ </ClientOnly >
61+ </template >
62+ <template #aside-outline-before >
63+ <local-graph v-if =" options.enableLocalGraph" ></local-graph >
64+ </template >
65+ <template #doc-meta-bottom >
66+ <AuthorLink ></AuthorLink >
67+ </template >
68+ </Layout >
69+ </n-message-provider >
6070 </n-config-provider >
6171</template >
6272
0 commit comments