fix: return skill detail back button to search

This commit is contained in:
yun-zhi-ztl 2026-03-17 10:53:00 +08:00
parent 1955fd8b97
commit 71ed31fc46
3 changed files with 23 additions and 5 deletions

View file

@ -13,6 +13,7 @@ import { adminApi, ApiError, skillDownloadApi } from '@/api/client'
import { useSubmitSkillReport } from '@/features/report/use-skill-reports'
import { formatLocalDateTime } from '@/shared/lib/date-time'
import { incrementSkillDownloadCount } from '@/shared/lib/skill-download-cache'
import { getSkillSquareSearch } from '@/shared/lib/skill-navigation'
import { formatCompactCount } from '@/shared/lib/number-format'
import { resolveDocumentationFilePath } from '@/shared/lib/skill-documentation'
import { NamespaceBadge } from '@/shared/components/namespace-badge'
@ -210,11 +211,7 @@ export function SkillDetailPage() {
}
const handleBack = () => {
if (window.history.length > 1) {
window.history.back()
return
}
navigate({ to: '/search', search: { q: '', sort: 'relevance', page: 0, starredOnly: false } })
navigate({ to: '/search', search: getSkillSquareSearch() })
}
const resolveSkillStatusLabel = (status?: string) => {

View file

@ -0,0 +1,13 @@
import { describe, expect, it } from 'vitest'
import { getSkillSquareSearch } from './skill-navigation'
describe('getSkillSquareSearch', () => {
it('returns the default search params for the skill square', () => {
expect(getSkillSquareSearch()).toEqual({
q: '',
sort: 'relevance',
page: 0,
starredOnly: false,
})
})
})

View file

@ -0,0 +1,8 @@
export function getSkillSquareSearch() {
return {
q: '',
sort: 'relevance' as const,
page: 0,
starredOnly: false,
}
}