diff --git a/apps/server/src/models/post/post.service.ts b/apps/server/src/models/post/post.service.ts index 947ecfc..0df249e 100755 --- a/apps/server/src/models/post/post.service.ts +++ b/apps/server/src/models/post/post.service.ts @@ -101,11 +101,7 @@ export class PostService extends BaseTreeService { }, params: { staff?: UserProfile; tx?: Prisma.TransactionClient }, ) { - // const await db.post.findMany({ - // where: { - // type: PostType.COURSE, - // }, - // }); + const { courseDetail } = args; // If no transaction is provided, create a new one if (!params.tx) { @@ -128,6 +124,7 @@ export class PostService extends BaseTreeService { ) { args.data.authorId = params?.staff?.id; args.data.updatedAt = dayjs().toDate(); + const result = await super.create(args); EventBus.emit('dataChanged', { type: ObjectType.POST, diff --git a/apps/web/package.json b/apps/web/package.json index f10e338..1456e66 100755 --- a/apps/web/package.json +++ b/apps/web/package.json @@ -36,6 +36,7 @@ "@nice/iconer": "workspace:^", "@nice/utils": "workspace:^", "mind-elixir": "workspace:^", + "@mind-elixir/node-menu": "workspace:*", "@nice/ui": "workspace:^", "@tanstack/query-async-storage-persister": "^5.51.9", "@tanstack/react-query": "^5.51.21", diff --git a/apps/web/src/app/main/courses/components/CoursesContainer.tsx b/apps/web/src/app/main/courses/components/CoursesContainer.tsx index a6cc07f..5f16cc1 100644 --- a/apps/web/src/app/main/courses/components/CoursesContainer.tsx +++ b/apps/web/src/app/main/courses/components/CoursesContainer.tsx @@ -1,7 +1,8 @@ -import CourseList from "@web/src/components/models/course/list/CourseList"; import { useMainContext } from "../../layout/MainProvider"; import { PostType, Prisma } from "@nice/common"; +import PostList from "@web/src/components/models/course/list/PostList"; import { useMemo } from "react"; +import CourseCard from "./CourseCard"; export function CoursesContainer() { const { selectedTerms, searchCondition } = useMainContext(); @@ -13,7 +14,8 @@ export function CoursesContainer() { return ( <> - } params={{ pageSize: 12, where: { @@ -30,7 +32,7 @@ export function CoursesContainer() { ...searchCondition, }, }} - cols={4}> + cols={4}> ); } diff --git a/apps/web/src/app/main/home/components/CoursesSection.tsx b/apps/web/src/app/main/home/components/CoursesSection.tsx index 999e931..bd2f45b 100755 --- a/apps/web/src/app/main/home/components/CoursesSection.tsx +++ b/apps/web/src/app/main/home/components/CoursesSection.tsx @@ -3,48 +3,49 @@ import { Typography, Skeleton } from "antd"; import { TaxonomySlug, TermDto } from "@nice/common"; import { api } from "@nice/client"; import { CoursesSectionTag } from "./CoursesSectionTag"; -import CourseList from "@web/src/components/models/course/list/CourseList"; import LookForMore from "./LookForMore"; +import PostList from "@web/src/components/models/course/list/PostList"; +import CourseCard from "../../courses/components/CourseCard"; interface GetTaxonomyProps { - categories: string[]; - isLoading: boolean; + categories: string[]; + isLoading: boolean; } function useGetTaxonomy({ type }): GetTaxonomyProps { - const { data, isLoading }: { data: TermDto[]; isLoading: boolean } = - api.term.findMany.useQuery({ - where: { - taxonomy: { - slug: type, - }, - parentId : null - }, - take: 11, // 只取前10个 - }); - const categories = useMemo(() => { - const allCategories = isLoading - ? [] - : data?.map((course) => course.name); - return [...Array.from(new Set(allCategories))]; - }, [data]); - return { categories, isLoading }; + const { data, isLoading }: { data: TermDto[]; isLoading: boolean } = + api.term.findMany.useQuery({ + where: { + taxonomy: { + slug: type, + }, + parentId: null + }, + take: 11, // 只取前10个 + }); + const categories = useMemo(() => { + const allCategories = isLoading + ? [] + : data?.map((course) => course.name); + return [...Array.from(new Set(allCategories))]; + }, [data]); + return { categories, isLoading }; } const { Title, Text } = Typography; interface CoursesSectionProps { - title: string; - description: string; - initialVisibleCoursesCount?: number; + title: string; + description: string; + initialVisibleCoursesCount?: number; } const CoursesSection: React.FC = ({ - title, - description, - initialVisibleCoursesCount = 8, + title, + description, + initialVisibleCoursesCount = 8, }) => { const [selectedCategory, setSelectedCategory] = useState("全部"); const gateGory: GetTaxonomyProps = useGetTaxonomy({ type: TaxonomySlug.CATEGORY, }); return ( -
+
@@ -80,22 +81,23 @@ const CoursesSection: React.FC = ({ )}
- } params={{ page: 1, pageSize: initialVisibleCoursesCount, where: { terms: !(selectedCategory === "全部") ? { - some: { - name: selectedCategory, - }, - } + some: { + name: selectedCategory, + }, + } : {}, }, }} showPagination={false} - cols={4}> + cols={4}>
diff --git a/apps/web/src/app/main/layout/MainFooter.tsx b/apps/web/src/app/main/layout/MainFooter.tsx index 4720c4f..9d060dc 100755 --- a/apps/web/src/app/main/layout/MainFooter.tsx +++ b/apps/web/src/app/main/layout/MainFooter.tsx @@ -1,5 +1,5 @@ import { CloudOutlined, FileSearchOutlined, HomeOutlined, MailOutlined, PhoneOutlined } from '@ant-design/icons'; -import { Layout, Typography } from 'antd'; + export function MainFooter() { return (