From 13b8c10c62ac09be71cb60c59b659b9694a3ddf5 Mon Sep 17 00:00:00 2001 From: Rao <1227431568@qq.com> Date: Tue, 25 Feb 2025 20:40:04 +0800 Subject: [PATCH] rht0225 --- .../main/home/components/CategorySection.tsx | 30 ++----------------- 1 file changed, 2 insertions(+), 28 deletions(-) diff --git a/apps/web/src/app/main/home/components/CategorySection.tsx b/apps/web/src/app/main/home/components/CategorySection.tsx index 9584193..f7b3340 100755 --- a/apps/web/src/app/main/home/components/CategorySection.tsx +++ b/apps/web/src/app/main/home/components/CategorySection.tsx @@ -1,17 +1,13 @@ import React, { useState, useCallback, useEffect, useMemo } from "react"; -import { Typography, Button, Spin, Skeleton } from "antd"; +import { Typography, Skeleton } from "antd"; import { stringToColor, TaxonomySlug, TermDto } from "@nice/common"; import { api } from "@nice/client"; -import { ControlOutlined } from "@ant-design/icons"; -import { useNavigate, useSearchParams } from "react-router-dom"; import LookForMore from "./LookForMore"; import CategorySectionCard from "./CategorySectionCard"; const { Title, Text } = Typography; const CategorySection = () => { const [hoveredIndex, setHoveredIndex] = useState(null); - const [showAll, setShowAll] = useState(false); - //获得分类 const { data: courseCategoriesData, isLoading, @@ -21,27 +17,8 @@ const CategorySection = () => { slug: TaxonomySlug.CATEGORY, }, }, - include: { - children: true, - }, - orderBy: { - createdAt: "desc", // 按创建时间降序排列 - }, take: 8, }); - // 分类展示 - const [displayedCategories, setDisplayedCategories] = useState( - [] - ); - useEffect(() => { - if (!isLoading) { - if (showAll) { - setDisplayedCategories(courseCategoriesData); - } else { - setDisplayedCategories(courseCategoriesData.slice(0, 8)); - } - } - }, [courseCategoriesData, showAll]); const handleMouseEnter = useCallback((index: number) => { setHoveredIndex(index); }, []); @@ -49,9 +26,6 @@ const CategorySection = () => { const handleMouseLeave = useCallback(() => { setHoveredIndex(null); }, []); - - const navigate = useNavigate(); - return (
@@ -69,7 +43,7 @@ const CategorySection = () => { {isLoading ? ( ) : ( - displayedCategories.map((category, index) => { + courseCategoriesData.map((category, index) => { const categoryColor = stringToColor(category.name); const isHovered = hoveredIndex === index;