From 6da5a12ab9bcfbfc4a26f94f4c1aef1e98711c08 Mon Sep 17 00:00:00 2001 From: longdayi <13477510+longdayilongdayi@user.noreply.gitee.com> Date: Wed, 26 Feb 2025 23:18:14 +0800 Subject: [PATCH] 02262318 --- apps/server/src/models/post/post.service.ts | 7 +- apps/web/package.json | 1 + .../courses/components/CoursesContainer.tsx | 8 +- .../main/home/components/CoursesSection.tsx | 64 ++-- apps/web/src/app/main/layout/MainFooter.tsx | 4 +- apps/web/src/app/main/layout/MainHeader.tsx | 134 ++++---- apps/web/src/app/main/layout/MainLayout.tsx | 6 +- .../src/app/main/layout/NavigationMenu.tsx | 2 +- .../src/app/main/path/components/PathCard.tsx | 94 ++++++ .../app/main/path/components/PathFilter.tsx | 44 +++ .../path/components/PathListContainer.tsx | 54 ++++ apps/web/src/app/main/path/editor/page.tsx | 10 + .../app/main/path/layout/PathListLayout.tsx | 20 ++ apps/web/src/app/main/path/page.tsx | 5 + apps/web/src/app/main/paths/page.tsx | 6 - .../components/common/editor/MindEditor.tsx | 208 +++++++++++-- .../src/components/common/editor/NodeMenu.tsx | 195 ++++++++++++ apps/web/src/components/common/editor/i18n.ts | 152 +++++++++ .../web/src/components/common/editor/types.ts | 14 + .../common/uploader/TusUploader.tsx | 1 - .../list/{CourseList.tsx => PostList.tsx} | 29 +- apps/web/src/hooks/useTusUpload.ts | 22 +- apps/web/src/index.css | 25 +- apps/web/src/routes/index.tsx | 25 +- config/nginx/conf.d/web.conf | 2 +- package.json | 3 +- packages/client/src/api/hooks/index.ts | 2 +- packages/client/src/api/hooks/usePost.ts | 11 +- packages/common/prisma/schema.prisma | 1 - packages/common/src/models/post.ts | 3 + packages/common/src/models/select.ts | 15 + pnpm-lock.yaml | 289 ++++++++++++++++++ 32 files changed, 1268 insertions(+), 188 deletions(-) create mode 100755 apps/web/src/app/main/path/components/PathCard.tsx create mode 100755 apps/web/src/app/main/path/components/PathFilter.tsx create mode 100644 apps/web/src/app/main/path/components/PathListContainer.tsx create mode 100644 apps/web/src/app/main/path/editor/page.tsx create mode 100644 apps/web/src/app/main/path/layout/PathListLayout.tsx create mode 100755 apps/web/src/app/main/path/page.tsx delete mode 100755 apps/web/src/app/main/paths/page.tsx create mode 100644 apps/web/src/components/common/editor/NodeMenu.tsx create mode 100644 apps/web/src/components/common/editor/i18n.ts create mode 100644 apps/web/src/components/common/editor/types.ts rename apps/web/src/components/models/course/list/{CourseList.tsx => PostList.tsx} (80%) diff --git a/apps/server/src/models/post/post.service.ts b/apps/server/src/models/post/post.service.ts index 675dda4..b9d4a21 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) { @@ -131,6 +127,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 9e2d871..47cf21a 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 { searchValue, selectedTerms } = useMainContext(); @@ -16,7 +17,8 @@ export function CoursesContainer() { }; return ( <> - } params={{ pageSize: 12, where: { @@ -44,7 +46,7 @@ export function CoursesContainer() { ], }, }} - 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 902e979..3aaec9e 100755 --- a/apps/web/src/app/main/home/components/CoursesSection.tsx +++ b/apps/web/src/app/main/home/components/CoursesSection.tsx @@ -3,40 +3,40 @@ 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 PostList from "@web/src/components/models/course/list/PostList"; import LookForMore from "./LookForMore"; 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, - }, - }, - take: 10, // 只取前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, + }, + }, + take: 10, // 只取前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({ @@ -52,7 +52,7 @@ const CoursesSection: React.FC = ({ className="font-bold text-5xl mb-6 bg-gradient-to-r from-blue-600 to-purple-600 bg-clip-text text-transparent"> {title} - + @@ -80,22 +80,22 @@ const CoursesSection: React.FC = ({ )} - + cols={4}> diff --git a/apps/web/src/app/main/layout/MainFooter.tsx b/apps/web/src/app/main/layout/MainFooter.tsx index e37d149..b08449a 100755 --- a/apps/web/src/app/main/layout/MainFooter.tsx +++ b/apps/web/src/app/main/layout/MainFooter.tsx @@ -1,8 +1,8 @@ import { CloudOutlined, FileSearchOutlined, HomeOutlined, MailOutlined, PhoneOutlined } from '@ant-design/icons'; -import { Layout, Typography } from 'antd'; + export function MainFooter() { return ( -