File tree Expand file tree Collapse file tree 3 files changed +28
-24
lines changed Expand file tree Collapse file tree 3 files changed +28
-24
lines changed Original file line number Diff line number Diff line change 1+ <template >
2+ <ClientOnly >
3+ <div
4+ :style =" {
5+ width: '100%',
6+ borderRadius: '8px',
7+ padding: '20px',
8+ backgroundColor: '#FFF',
9+ border: '1px solid lightgray',
10+ }"
11+ >
12+ <component :is =" vueComponent" />
13+ </div >
14+ </ClientOnly >
15+ </template >
16+
17+ <script setup lang="ts">
18+ const props = defineProps <{
19+ component: string
20+ }>()
21+
22+ const vueComponent = (await import (` ../code/${props .component }.vue ` )).default
23+ </script >
Original file line number Diff line number Diff line change 1- <ClientOnly >
2- <div
3- :style="{
4- width: '100%',
5- borderRadius: '8px',
6- padding: '20px',
7- backgroundColor: '#FFF',
8- border: '1px solid lightgray',
9- }"
10- >
11- <component :is="component" />
12- </div>
13- </ClientOnly>
1+ <Suspense >
2+ <DemoRender :component =" component " />
3+ </Suspense >
144
155<ClientOnly >
166 <div :style =" { margin: '16px 0' } " >
2818import { ref } from ' vue'
2919import { useData } from ' vitepress'
3020
21+ import DemoRender from ' ./DemoRender.vue'
3122import PlaygroundLink from ' ./PlaygroundLink.vue'
3223import { data as sourceCodeMap } from ' ../data/code.data'
3324import { codeDemoI18n } from ' ../constants/i18n'
Original file line number Diff line number Diff line change @@ -7,19 +7,9 @@ import '@wsfe/vue-tree/style.css'
77
88export default {
99 extends : DefaultTheme ,
10- async enhanceApp ( { app } ) {
10+ enhanceApp ( { app } ) {
1111 // 注册自定义全局组件
1212 app . component ( 'CodeDemo' , CodeDemo )
1313 app . component ( 'PlaygroundLink' , PlaygroundLink )
14-
15- const codeDemoComponents = import . meta. glob ( '../code/*.vue' )
16-
17- for ( const path in codeDemoComponents ) {
18- const component = await codeDemoComponents [ path ] ( )
19- const componentName = path . match ( / ^ (?: .* \/ ) ? ( .+ ) \. v u e $ / ) ?. [ 1 ]
20- if ( componentName && component ?. default ) {
21- app . component ( componentName , component . default )
22- }
23- }
2414 }
2515} satisfies Theme
You can’t perform that action at this time.
0 commit comments