This commit is contained in:
Rao 2025-02-27 23:06:17 +08:00
parent 1dd03e5b99
commit 7aea942646
4 changed files with 23 additions and 6 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 { Typography, Skeleton } from "antd";
import { TaxonomySlug, TermDto } from "@nice/common"; import { TaxonomySlug, TermDto } from "@nice/common";
import { api } from "@nice/client"; import { api } from "@nice/client";
import { CoursesSectionTag } from "./CoursesSectionTag"; import { CoursesSectionTag } from "./CoursesSectionTag";
import LookForMore from "./LookForMore"; import LookForMore from "./LookForMore";
import PostList from "@web/src/components/models/course/list/PostList"; 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 { interface GetTaxonomyProps {
categories: string[]; categories: string[];
isLoading: boolean; isLoading: boolean;
@ -35,11 +33,15 @@ interface CoursesSectionProps {
title: string; title: string;
description: string; description: string;
initialVisibleCoursesCount?: number; initialVisibleCoursesCount?: number;
postType:string;
render?:(post)=>ReactNode
} }
const CoursesSection: React.FC<CoursesSectionProps> = ({ const CoursesSection: React.FC<CoursesSectionProps> = ({
title, title,
description, description,
initialVisibleCoursesCount = 8, initialVisibleCoursesCount = 8,
postType,
render
}) => { }) => {
const [selectedCategory, setSelectedCategory] = useState<string>("全部"); const [selectedCategory, setSelectedCategory] = useState<string>("全部");
const gateGory: GetTaxonomyProps = useGetTaxonomy({ const gateGory: GetTaxonomyProps = useGetTaxonomy({
@ -83,7 +85,7 @@ const CoursesSection: React.FC<CoursesSectionProps> = ({
)} )}
</div> </div>
<PostList <PostList
renderItem={(post) => <CourseCard post={post}></CourseCard>} renderItem={(post) => render(post)}
params={{ params={{
page: 1, page: 1,
pageSize: initialVisibleCoursesCount, pageSize: initialVisibleCoursesCount,
@ -95,6 +97,7 @@ const CoursesSection: React.FC<CoursesSectionProps> = ({
}, },
} }
: {}, : {},
type: postType
}, },
}} }}
showPagination={false} showPagination={false}

View File

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

View File

@ -187,7 +187,7 @@ export default function MindEditor({ id }: { id?: string }) {
return ( return (
<div className="grid grid-cols-1 flex-col w-[90vw] my-5 h-[80vh] border rounded-lg mx-auto"> <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 && ( {canEdit && taxonomies && (
<Form <Form

View File

@ -70,7 +70,9 @@ export const routes: CustomRouteObject[] = [
}, },
{ {
path: "editor/:id?", path: "editor/:id?",
element: <PathEditorPage></PathEditorPage>, element: <WithAuth>
<PathEditorPage></PathEditorPage>
</WithAuth>,
}, },
], ],
}, },