Skip to content

Commit

Permalink
修复进入应用时latest版本跳转错误
Browse files Browse the repository at this point in the history
  • Loading branch information
Val-istar-Guo committed Jun 2, 2024
1 parent dfdafda commit ad4ab1f
Showing 1 changed file with 7 additions and 4 deletions.
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
<script setup lang="ts">
import * as R from 'ramda'
import semver from 'semver'
import { useRouteParams } from '@vueuse/router'
import { queryApiFiles, querySheetById, querySheetVersions } from '~/api/backend'
import { ApiFile, Sheet, SheetVersion } from '~/api/backend/components/schemas'
Expand Down Expand Up @@ -47,14 +49,15 @@ watchEffect(async () => {
if (route.path === prefix.value) {
if (!apiFiles.value.length) return
const version = sheetVersions.value[0].version
const versions = R.sort(semver.rcompare, sheetVersions.value.map(R.prop('version')))
const maxVersion = versions[0]
if (sheet.value.type === 'markdown') {
await router.replace(`${prefix.value}/${version}/markdown`)
await router.replace(`${prefix.value}/${maxVersion}/markdown`)
} else if (sheet.value.type === 'openapi') {
await router.replace(`${prefix.value}/${version}/openapi/operation`)
await router.replace(`${prefix.value}/${maxVersion}/openapi/operation`)
} else if (sheet.value.type === 'asyncapi') {
await router.replace(`${prefix.value}/${version}/asyncapi/schema`)
await router.replace(`${prefix.value}/${maxVersion}/asyncapi/schema`)
}
}
})
Expand Down

0 comments on commit ad4ab1f

Please sign in to comment.