mirror of
https://github.com/iflytek/skillhub.git
synced 2026-10-09 03:17:52 +00:00
fix: show download error on skill detail
This commit is contained in:
parent
0904f0feda
commit
96c2f53283
5 changed files with 22 additions and 2 deletions
12
web/src/features/skill/skill-action-error.test.ts
Normal file
12
web/src/features/skill/skill-action-error.test.ts
Normal file
|
|
@ -0,0 +1,12 @@
|
|||
import { describe, expect, it } from 'vitest'
|
||||
import { resolveSkillActionErrorTitle } from './skill-action-error'
|
||||
|
||||
describe('resolveSkillActionErrorTitle', () => {
|
||||
it('returns the download error title key for download failures', () => {
|
||||
expect(resolveSkillActionErrorTitle('download')).toBe('skillDetail.downloadErrorTitle')
|
||||
})
|
||||
|
||||
it('returns the report error title key for report failures', () => {
|
||||
expect(resolveSkillActionErrorTitle('report')).toBe('skillDetail.reportErrorTitle')
|
||||
})
|
||||
})
|
||||
5
web/src/features/skill/skill-action-error.ts
Normal file
5
web/src/features/skill/skill-action-error.ts
Normal file
|
|
@ -0,0 +1,5 @@
|
|||
export function resolveSkillActionErrorTitle(action: 'download' | 'report') {
|
||||
return action === 'download'
|
||||
? 'skillDetail.downloadErrorTitle'
|
||||
: 'skillDetail.reportErrorTitle'
|
||||
}
|
||||
|
|
@ -630,6 +630,7 @@
|
|||
"reportReasonRequired": "Please provide a report reason",
|
||||
"reportSuccessTitle": "Report submitted",
|
||||
"reportSuccessDescription": "Administrators will review this report soon.",
|
||||
"downloadErrorTitle": "Download failed",
|
||||
"reportErrorTitle": "Report failed"
|
||||
},
|
||||
"reports": {
|
||||
|
|
|
|||
|
|
@ -630,6 +630,7 @@
|
|||
"reportReasonRequired": "请先填写举报原因",
|
||||
"reportSuccessTitle": "举报已提交",
|
||||
"reportSuccessDescription": "管理员将尽快处理这条举报。",
|
||||
"downloadErrorTitle": "下载失败",
|
||||
"reportErrorTitle": "举报失败"
|
||||
},
|
||||
"reports": {
|
||||
|
|
|
|||
|
|
@ -6,6 +6,7 @@ import { ArrowLeft } from 'lucide-react'
|
|||
import { MarkdownRenderer } from '@/features/skill/markdown-renderer'
|
||||
import { FileTree } from '@/features/skill/file-tree'
|
||||
import { InstallCommand } from '@/features/skill/install-command'
|
||||
import { resolveSkillActionErrorTitle } from '@/features/skill/skill-action-error'
|
||||
import { RatingInput } from '@/features/social/rating-input'
|
||||
import { StarButton } from '@/features/social/star-button'
|
||||
import { useAuth } from '@/features/auth/use-auth'
|
||||
|
|
@ -170,7 +171,7 @@ export function SkillDetailPage() {
|
|||
queryClient.invalidateQueries({ queryKey: ['skills', 'stars'] })
|
||||
queryClient.invalidateQueries({ queryKey: ['skills', 'search'] })
|
||||
} catch (error) {
|
||||
toast.error(t('skillDetail.reportErrorTitle'), error instanceof Error ? error.message : '')
|
||||
toast.error(t(resolveSkillActionErrorTitle('download')), error instanceof Error ? error.message : '')
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -207,7 +208,7 @@ export function SkillDetailPage() {
|
|||
setReportDetails('')
|
||||
toast.success(t('skillDetail.reportSuccessTitle'), t('skillDetail.reportSuccessDescription'))
|
||||
} catch (error) {
|
||||
toast.error(t('skillDetail.reportErrorTitle'), error instanceof Error ? error.message : '')
|
||||
toast.error(t(resolveSkillActionErrorTitle('report')), error instanceof Error ? error.message : '')
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue