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 >
14
4
15
5
<ClientOnly >
16
6
<div :style =" { margin: '16px 0' } " >
28
18
import { ref } from ' vue'
29
19
import { useData } from ' vitepress'
30
20
21
+ import DemoRender from ' ./DemoRender.vue'
31
22
import PlaygroundLink from ' ./PlaygroundLink.vue'
32
23
import { data as sourceCodeMap } from ' ../data/code.data'
33
24
import { codeDemoI18n } from ' ../constants/i18n'
Original file line number Diff line number Diff line change @@ -7,19 +7,9 @@ import '@wsfe/vue-tree/style.css'
7
7
8
8
export default {
9
9
extends : DefaultTheme ,
10
- async enhanceApp ( { app } ) {
10
+ enhanceApp ( { app } ) {
11
11
// 注册自定义全局组件
12
12
app . component ( 'CodeDemo' , CodeDemo )
13
13
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
- }
24
14
}
25
15
} satisfies Theme
You can’t perform that action at this time.
0 commit comments