Skip to content

Commit c4307a8

Browse files
committed
fix: gallery bug
1 parent 737772c commit c4307a8

File tree

2 files changed

+10
-8
lines changed

2 files changed

+10
-8
lines changed

src/pages/Gallery-N/CategoryDicts.tsx

+6-4
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ import { useCallback, useEffect, useMemo, useState } from 'react'
88

99
export default function DictionaryGroup({ groupedDictsByTag }: { groupedDictsByTag: Record<string, Dictionary[]> }) {
1010
const tagList = useMemo(() => Object.keys(groupedDictsByTag), [groupedDictsByTag])
11-
const [currentTag, setCurrentTag] = useState(tagList[0])
11+
const [currentTag, setCurrentTag] = useState(tagList.length > 0 ? tagList[0] : '')
1212
const currentDictInfo = useAtomValue(currentDictInfoAtom)
1313

1414
const onChangeCurrentTag = useCallback((tag: string) => {
@@ -26,9 +26,11 @@ export default function DictionaryGroup({ groupedDictsByTag }: { groupedDictsByT
2626
<div>
2727
<DictTagSwitcher tagList={tagList} currentTag={currentTag} onChangeCurrentTag={onChangeCurrentTag} />
2828
<div className="mt-8 grid gap-x-5 gap-y-10 px-1 pb-4 sm:grid-cols-1 md:grid-cols-2 dic3:grid-cols-3 dic4:grid-cols-4">
29-
{groupedDictsByTag[currentTag].map((dict) => (
30-
<DictionaryComponent key={dict.id} dictionary={dict} />
31-
))}
29+
{currentTag && groupedDictsByTag[currentTag] ? (
30+
groupedDictsByTag[currentTag].map((dict) => <DictionaryComponent key={dict.id} dictionary={dict} />)
31+
) : (
32+
<div className="col-span-full text-center text-gray-500">当前分类下没有可用的词典</div>
33+
)}
3234
</div>
3335
</div>
3436
)

src/resources/dictionary.ts

+4-4
Original file line numberDiff line numberDiff line change
@@ -3841,15 +3841,15 @@ const programming: DictionaryResource[] = [
38413841
languageCategory: 'code',
38423842
},
38433843
{
3844-
id: 'SoundSfxKey',
3844+
id: 'AudioKey',
38453845
name: '游戏音效库常用英语',
38463846
description: '游戏音效库常用英语',
38473847
category: '代码练习',
3848-
tags: ['RAZ'],
3848+
tags: ['游戏'],
38493849
url: '/dicts/AudioKey.json',
38503850
length: 535,
3851-
language: 'en',
3852-
languageCategory: 'en',
3851+
language: 'code',
3852+
languageCategory: 'code',
38533853
},
38543854
]
38553855

0 commit comments

Comments
 (0)