11<script >
2- import * as AllDemo from ' ../demo'
2+ import Vue from ' vue'
3+ import AllDemo from ' ../demo'
34import Header from ' ./header'
45import zhCN from ' antd/locale-provider/zh_CN'
56import enUS from ' antd/locale-provider/default'
@@ -19,6 +20,8 @@ const docsList = [
1920export default {
2021 props: {
2122 name: String ,
23+ showDemo: Boolean ,
24+ showApi: Boolean ,
2225 },
2326 data () {
2427 this .store = create ({
@@ -29,6 +32,11 @@ export default {
2932 currentSubMenu: [],
3033 }
3134 },
35+ provide () {
36+ return {
37+ demoContext: this ,
38+ }
39+ },
3240 beforeDestroy () {
3341 if (this .unsubscribe ) {
3442 this .unsubscribe ()
@@ -117,6 +125,7 @@ export default {
117125 document .title = titleStr
118126 },
119127 },
128+
120129 render () {
121130 const name = this .name
122131 const isCN = isZhCN (name)
@@ -136,11 +145,18 @@ export default {
136145 const type = d .type || ' Other'
137146 const key = ` ${ title .replace (/ (\B [A-Z ] )/ g , ' -$1' ).toLowerCase ()} `
138147 titleMap[key] = title
148+ AllDemo[title].key = key
139149 menuConfig[type] = menuConfig[type] || []
140150 menuConfig[type].push (d)
141151 }
142152 const reName = name .replace (/ -cn\/ ? $ / , ' ' )
143- const Demo = AllDemo[titleMap[reName]]
153+ // const Demo = new Vue({
154+ // template: '<demo-component/>',
155+ // components: {
156+ // 'demo-component': () => import(`../../components/${AllDemo[titleMap[reName]].key}/demo/index.vue`),
157+ // },
158+ // })
159+ // AllDemo[titleMap[reName]]
144160 const MenuGroup = []
145161 for (const [type , menus ] of Object .entries (menuConfig)) {
146162 const MenuItems = []
@@ -167,7 +183,7 @@ export default {
167183 if (! isCN) {
168184 locale = enUS
169185 }
170- this .resetDocumentTitle (Demo , reName, isCN)
186+ this .resetDocumentTitle (AllDemo[titleMap[reName]] , reName, isCN)
171187 return (
172188 < div class = ' page-wrapper' >
173189 < Header searchData= {searchData} name= {name}/ >
@@ -192,17 +208,18 @@ export default {
192208 < div class = ' toc-affix' style= ' width: 110px;' >
193209 {this .getSubMenu (isCN)}
194210 < / div>
195- {Demo ? < Provider store= {this .store }>
196- < Demo key = {isCN ? ' cn ' : ' en ' } / >
211+ {this . showDemo ? < Provider store= {this .store } key = {isCN ? ' cn ' : ' en ' }>
212+ < router - view >< / router - view >
197213 < / Provider> : ' ' }
198- < div class = ' markdown api-container' ref= ' doc' >
214+ { this . showApi ? < div class = ' markdown api-container' ref= ' doc' >
199215 < router- view>< / router- view>
200- < / div>
216+ < / div> : ' ' }
201217 < / div>
202218 < / a- col>
203219 < / a- row>
204220 < / div>
205221 < / a- locale- provider>
222+ { name .indexOf (' back-top' ) === - 1 ? < a- back- top / > : null }
206223 < / div>
207224 )
208225 },
0 commit comments