This commit is contained in:
longdayi 2025-02-27 23:08:11 +08:00
commit f2c10e6f41
4 changed files with 28 additions and 9 deletions

View File

@ -1,12 +1,10 @@
import React, { useState, useMemo } from "react";
import React, { useState, useMemo, ReactNode } from "react";
import { Typography, Skeleton } from "antd";
import { TaxonomySlug, TermDto } from "@nice/common";
import { api } from "@nice/client";
import { CoursesSectionTag } from "./CoursesSectionTag";
import LookForMore from "./LookForMore";
import PostList from "@web/src/components/models/course/list/PostList";
import PostCard from "@web/src/components/models/post/PostCard";
import CourseCard from "@web/src/components/models/post/SubPost/CourseCard";
interface GetTaxonomyProps {
categories: string[];
isLoading: boolean;
@ -35,11 +33,15 @@ interface CoursesSectionProps {
title: string;
description: string;
initialVisibleCoursesCount?: number;
postType:string;
render?:(post)=>ReactNode
}
const CoursesSection: React.FC<CoursesSectionProps> = ({
title,
description,
initialVisibleCoursesCount = 8,
postType,
render
}) => {
const [selectedCategory, setSelectedCategory] = useState<string>("全部");
const gateGory: GetTaxonomyProps = useGetTaxonomy({
@ -83,7 +85,7 @@ const CoursesSection: React.FC<CoursesSectionProps> = ({
)}
</div>
<PostList
renderItem={(post) => <CourseCard post={post}></CourseCard>}
renderItem={(post) => render(post)}
params={{
page: 1,
pageSize: initialVisibleCoursesCount,
@ -95,6 +97,7 @@ const CoursesSection: React.FC<CoursesSectionProps> = ({
},
}
: {},
type: postType
},
}}
showPagination={false}

View File

@ -1,6 +1,9 @@
import HeroSection from "./components/HeroSection";
import CategorySection from "./components/CategorySection";
import CoursesSection from "./components/CoursesSection";
import { PostType } from "@nice/common";
import PathCard from "@web/src/components/models/post/SubPost/PathCard";
import CourseCard from "@web/src/components/models/post/SubPost/CourseCard";
const HomePage = () => {
@ -8,10 +11,19 @@ const HomePage = () => {
return (
<div className="min-h-screen">
<HeroSection />
<CoursesSection
title="最受欢迎的思维导图"
description="深受追捧的思维导图,点亮你的智慧人生"
postType={PostType.PATH}
render={(post)=><PathCard post={post}></PathCard>}
/>
<CoursesSection
title="推荐课程"
description="最受欢迎的精品课程,助你快速成长"
postType={PostType.COURSE}
render={(post)=> <CourseCard post={post}></CourseCard>}
/>
<CategorySection />
</div>
);

View File

@ -170,9 +170,13 @@ export default function MindEditor({ id }: { id?: string }) {
}, []);
return (
<div className="grid grid-cols-1 flex-col w-[90vw] my-5 h-[80vh] border rounded-lg mx-auto">
{taxonomies && (
<Form form={form} className=" bg-white p-4 ">
<div className={`grid grid-cols-1 flex-col w-[90vw] my-5 h-[${Math.floor(window.innerHeight/1.25)}px] border rounded-lg mx-auto`}>
{canEdit && taxonomies && (
<Form
form={form}
className=" bg-white p-4 ">
<div className="flex items-center justify-between gap-4">
<div className="flex items-center gap-4">
{taxonomies.map((tax, index) => (