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