fix(site): Fix the problem that official website table type switching route can't be displayed, and add Types anchor point. (#879)

This commit is contained in:
ajaxzheng 2023-11-20 01:11:25 -08:00 committed by GitHub
parent 140a3a3a32
commit 3e0dd3a23f
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 11 additions and 6 deletions

View File

@ -129,12 +129,11 @@
<script lang="jsx">
import { defineComponent, reactive, computed, toRefs, watch, onMounted, onUnmounted, nextTick } from 'vue'
import { marked } from 'marked'
import { Loading, Anchor, ButtonGroup } from '@opentiny/vue'
import { Loading, Anchor, ButtonGroup, ColumnListGroup } from '@opentiny/vue'
import debounce from '@opentiny/vue-renderless/common/deps/debounce'
import { $t, $t2, $clone, $split, fetchDemosFile, useApiMode, useTemplateMode } from '@/tools'
import demo from '@/views/components/demo'
import { router } from '@/router.js'
import { getAllComponents } from '@/menus.jsx'
import { Collapse, CollapseItem } from '@opentiny/vue'
import { faqMdConfig, staticDemoPath, getWebdocPath } from './cmpConfig'
import AsyncHighlight from './async-highlight.vue'
@ -169,8 +168,8 @@ export default defineComponent({
title: demo.name[state.langKey],
link: `#${demo.demoId}`
})) || []
if (apiModeState.demoMode !== 'single' && state.currJson?.apis?.length) {
links.push({ key: 'API', title: 'API', link: '#API' })
if (state.currJson?.apis?.length) {
links.push({ key: 'API', title: 'API', link: '#API' }, { key: 'Types', title: 'Types', link: '#types' })
}
if (state.cmpFAQMd) {
links.push({
@ -281,6 +280,7 @@ export default defineComponent({
fetchDemosFile(`${staticDemoPath}/grid/webdoc/grid.js`).then((data) => {
const gridJson = eval('(' + data.slice(15) + ')')
state.currJson.apis = gridJson.apis
state.currJson.types = gridJson.types
})
} else if (state.cmpId?.startsWith('chart-')) {
fetchDemosFile(`${staticDemoPath}/chart/webdoc/chart.js`).then((data) => {
@ -341,10 +341,15 @@ export default defineComponent({
if (apiModeState.demoMode === 'single' && data.link.startsWith('#')) {
e.preventDefault()
const hash = data.link.slice(1)
state.singleDemo = state.currJson.demos.find((d) => d.demoId === hash)
const singleDemo = state.currJson.demos.find((d) => d.demoId === hash)
// id
if (singleDemo) {
state.singleDemo = singleDemo
scrollToLayoutTop()
}
router.push(data.link)
scrollToLayoutTop()
} else if (apiModeState.demoMode === 'default' && data.link.startsWith('#')) {
// singleDemo
const hash = data.link.slice(1)