diff --git a/src/app/vol/list/[category]/[[...page]]/page.tsx b/src/app/vol/list/[category]/[[...page]]/page.tsx index cccb148..bd7554b 100644 --- a/src/app/vol/list/[category]/[[...page]]/page.tsx +++ b/src/app/vol/list/[category]/[[...page]]/page.tsx @@ -13,7 +13,23 @@ export const metadata: Metadata = { const getCategoryList = async () => { const result = await apiSearchCategoryList(); if (result.code !== 200) return notFound(); - return result.data; + + // 去除空格 + const list: Category[] = result.data.map((item) => { + return { ...item, nameEn: item.nameEn.replace(/ /g, '') }; + }); + + // 添加“全部”tag + list.unshift({ + id: '0', + nameCh: '全部', + nameEn: 'all', + image: '', + thumbnail: '', + description: '', + }); + + return list; }; const getRecommendList = async () => { @@ -45,7 +61,7 @@ export default async function Journal({ params }: { params: { category?: string; {/* 左侧 */}
{/* category */} - + {/* */}
{categoryInfo?.nameCh ?? '全部'}
diff --git a/src/components/Category.tsx b/src/components/Category.tsx index 86e888a..73d0757 100644 --- a/src/components/Category.tsx +++ b/src/components/Category.tsx @@ -1,31 +1,13 @@ import Link from 'next/link'; -import { apiSearchCategoryList } from '@/services/server/journal'; - -const getCategoryList = async () => { - const result = await apiSearchCategoryList(); - return result.code === 200 ? result.data : []; -}; - -const Category = async ({ current = '' }: { current?: string }) => { - const categoryList = await getCategoryList(); - - categoryList.unshift({ - id: '0', - nameCh: '全部', - nameEn: 'all', - image: '', - thumbnail: '', - description: '', - }); - +const Category = async ({ list, current }: { list: Category[]; current: string }) => { return (
- {categoryList.map((item: Category) => ( + {list.map((item: Category) => ( {item.nameCh}