forked from opentiny/tiny-vue
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:
parent
140a3a3a32
commit
3e0dd3a23f
|
@ -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)
|
||||||
|
|
Loading…
Reference in New Issue