2
2
<!-- 一个组件的文档: 描述md + demos + apis -->
3
3
<header class =" flex-horizontal docs-header" >
4
4
<div class =" docs-title-wrap" >
5
- <div class =" markdown-body markdown-top-body" size = " medium " v-html =" state.cmpTopMd" ></div >
5
+ <div class =" markdown-body markdown-top-body" v-html =" state.cmpTopMd" ></div >
6
6
<version-tip
7
7
v-if =" state.currJson.meta || state.currJson.versionTipOption"
8
8
:meta =" state.currJson.meta"
194
194
</div >
195
195
</div >
196
196
197
- <h2 id =" FAQ" v-if =" state.cmpFAQMd" class =" ti-f30 ti-fw-normal ti-mt28 ti-mb20" >FAQ</h2 >
198
- <div class =" markdown-body" v-html =" state.cmpFAQMd" ></div >
199
197
<div v-if =" state.currJson.owner" class =" ti-abs ti-right24 ti-top24" @click =" copyText(state.currJson.owner)" >
200
198
{{ i18nByKey('doc-owner') }} : {{ state.currJson.owner }}
201
199
</div >
@@ -210,21 +208,21 @@ import { useRoute } from 'vue-router'
210
208
import { marked } from ' marked'
211
209
import hljs from ' highlight.js'
212
210
import {
213
- Anchor as TinyAnchor ,
214
- ButtonGroup as TinyButtonGroup ,
215
- Grid as TinyGrid ,
216
- GridColumn as TinyGridColumn ,
217
- Tabs as TinyTabs ,
218
- TabItem as TinyTabItem ,
219
- Tooltip as TinyTooltip
211
+ TinyAnchor ,
212
+ TinyButtonGroup ,
213
+ TinyGrid ,
214
+ TinyGridColumn ,
215
+ TinyTabs ,
216
+ TinyTabItem ,
217
+ TinyTooltip
220
218
} from ' @opentiny/vue'
221
219
import { iconOuterLink } from ' @opentiny/vue-icon'
222
220
import debounce from ' @opentiny/vue-renderless/common/deps/debounce'
223
221
import { i18nByKey , getWord , $clone , fetchDemosFile , useApiMode , useTemplateMode , getCmpContributors } from ' @/tools'
224
222
import DemoBox from ' @/views/components/demo'
225
223
import demoConfig from ' @demos/config.js'
226
224
import { router } from ' @/router.js'
227
- import { faqMdConfig , getWebdocPath } from ' ./cmp-config'
225
+ import { getWebdocPath } from ' ./cmp-config'
228
226
import AsyncHighlight from ' ./async-highlight.vue'
229
227
import VersionTip from ' ./VersionTip.vue'
230
228
@@ -247,7 +245,6 @@ const state = reactive({
247
245
observer: null ,
248
246
currJson: { column: 1 , demos: [], apis: [], types: {} },
249
247
cmpTopMd: null ,
250
- cmpFAQMd: null ,
251
248
currDemoId: ' ' ,
252
249
demoAnchorLinks: computed (() => {
253
250
const links =
@@ -256,13 +253,6 @@ const state = reactive({
256
253
title: demo .name [state .langKey ],
257
254
link: ` #${demo .demoId } `
258
255
})) || []
259
- if (state .cmpFAQMd ) {
260
- links .push ({
261
- key: ' FAQ' ,
262
- title: ' FAQ' ,
263
- link: ' #FAQ'
264
- })
265
- }
266
256
return links
267
257
}),
268
258
iframeUrl: ' ' ,
@@ -349,15 +339,15 @@ const demoMounted = () => {
349
339
}
350
340
}
351
341
352
- const getIframeConetent = (demoId , demoName ) => {
342
+ const getIframeContent = (demoId , demoName ) => {
353
343
const frameWindow = iframeRef .value .contentWindow
354
344
frameWindow .postMessage ({ from: ' tiny-vue-site' , component: state .cmpId , demo: demoName })
355
345
router .push (` #${demoId } ` )
356
346
}
357
347
358
348
const getIframeDemo = (demo ) => {
359
349
if (demo ?.codeFiles .length > 0 ) {
360
- getIframeConetent (demo .demoId , demo .codeFiles [0 ])
350
+ getIframeContent (demo .demoId , demo .codeFiles [0 ])
361
351
jumpToMobileDemoAndHash (demo .demoId )
362
352
state .currDemoId = demo .demoId
363
353
}
@@ -551,14 +541,8 @@ const loadPage = debounce(templateModeState.isSaas ? 100 : 0, false, () => {
551
541
promiseArr [1 ] = fetchDemosFile (` ${staticPath .value }/${getWebdocPath (state .cmpId )}/webdoc/${state .cmpId }.js ` )
552
542
}
553
543
554
- if (faqMdConfig [state .cmpId ]) {
555
- promiseArr .push (
556
- fetchDemosFile (` ${staticPath .value }/${getWebdocPath (state .cmpId )}/webdoc/${state .cmpId }.faq.${lang }.md ` )
557
- )
558
- }
559
-
560
544
Promise .all (promiseArr )
561
- .then (([mdData , jsData , apiData , faqData ]) => {
545
+ .then (([mdData , jsData , apiData ]) => {
562
546
// 1、加载顶部md
563
547
state .cmpTopMd = marked (mdData , {
564
548
gfm: true ,
@@ -568,11 +552,6 @@ const loadPage = debounce(templateModeState.isSaas ? 100 : 0, false, () => {
568
552
}
569
553
})
570
554
571
- // 2、加载faq.md
572
- if (faqData ) {
573
- state .cmpFAQMd = marked (faqData )
574
- }
575
-
576
555
// 3、加载cmpId.js 文件
577
556
// eslint-disable-next-line no-eval
578
557
const json = jsData ? eval (' (' + jsData .slice (15 ) + ' )' ) : {}
@@ -590,10 +569,13 @@ const loadPage = debounce(templateModeState.isSaas ? 100 : 0, false, () => {
590
569
591
570
if (apiData ) {
592
571
// eslint-disable-next-line no-eval
593
- const apiJson = eval (' (' + apiData .slice (15 ) + ' )' )
572
+ let apiJson = eval (' (' + apiData .slice (15 ) + ' )' )
594
573
// pc、mobile、mobile-first三种模式
595
574
const demoMode = templateModeState .isSaas ? templateModeState .mode : import .meta .env .VITE_APP_MODE
596
575
const demoKey = demoMode === ' mobile-first' ? ' mfDemo' : ` ${demoMode }Demo `
576
+ if (demoMode === ' mobile' ) {
577
+ apiJson = json
578
+ }
597
579
state .currJson .apis = apiJson .apis .map ((item ) => {
598
580
Object .keys (item ).forEach ((key ) => {
599
581
const apiItem = item [key ]
@@ -742,7 +724,7 @@ const handleAnchorClick = (e, data) => {
742
724
if (demoConfig .isMobile ) {
743
725
// 点击目录列表更新iframe显示
744
726
const hashId = data .link .slice (1 )
745
- getIframeConetent (state .cmpId , hashId + ' .vue' )
727
+ getIframeContent (state .cmpId , hashId + ' .vue' )
746
728
}
747
729
748
730
if (apiModeState .demoMode === ' single' && data .link .startsWith (' #' )) {
0 commit comments