From 1a0a49d276f24127573930a101aee14a9ae16ab9 Mon Sep 17 00:00:00 2001 From: ditiqi Date: Wed, 26 Feb 2025 10:23:53 +0800 Subject: [PATCH 1/8] add --- .gitignore | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/.gitignore b/.gitignore index fcd12c1..2e6bac7 100755 --- a/.gitignore +++ b/.gitignore @@ -68,4 +68,5 @@ yarn-error.log* # Ignore .idea files in the Expo monorepo **/.idea/ uploads -packages/mind-elixir-core \ No newline at end of file +packages/mind-elixir-core +config/nginx/conf.d/web.conf \ No newline at end of file From 6ad65b1e717dbf28dc7d3a07bed8b7d2ccfcdccc Mon Sep 17 00:00:00 2001 From: Li1304553726 <1304553726@qq.com> Date: Wed, 26 Feb 2025 10:25:25 +0800 Subject: [PATCH 2/8] add . --- .../main/courses/components/CourseCard.tsx | 21 --- .../main/home/components/CategorySection.tsx | 2 +- .../main/home/components/CoursesSection.tsx | 170 +++++++++--------- apps/web/src/app/main/layout/MainLayout.tsx | 4 +- 4 files changed, 88 insertions(+), 109 deletions(-) diff --git a/apps/web/src/app/main/courses/components/CourseCard.tsx b/apps/web/src/app/main/courses/components/CourseCard.tsx index 963c691..40aa8da 100755 --- a/apps/web/src/app/main/courses/components/CourseCard.tsx +++ b/apps/web/src/app/main/courses/components/CourseCard.tsx @@ -58,24 +58,6 @@ export default function CourseCard({ course }: CourseCardProps) { ); })} - {/* - {course.terms?.[0].name} - - - - - {course.terms?.[1].name} - */} 1 ?`${course.depts[0].name}等`:course.depts[0].name } - {/* {course?.depts?.map((dept) => {return dept.name.length > 1 ?`${dept.name.slice}等`: dept.name})} */} - {/* {course?.depts?.map((dept)=>{return dept.name})} */} </Text> </div> <span className="text-xs font-medium text-gray-500"> {course?.meta?.views ? `观看次数 ${course?.meta?.views}` : null} </span> </div> - <div className="pt-4 border-t border-gray-100 text-center"> <Button type="primary" diff --git a/apps/web/src/app/main/home/components/CategorySection.tsx b/apps/web/src/app/main/home/components/CategorySection.tsx index f3ed9ec..40043a3 100755 --- a/apps/web/src/app/main/home/components/CategorySection.tsx +++ b/apps/web/src/app/main/home/components/CategorySection.tsx @@ -41,7 +41,7 @@ const CategorySection = () => { window.scrollTo({top: 0,behavior: "smooth",}) },[]); return ( - <section className="py-32 relative overflow-hidden"> + <section className="py-8 relative overflow-hidden"> <div className="max-w-screen-2xl mx-auto px-4 relative"> <div className="text-center mb-24"> <Title diff --git a/apps/web/src/app/main/home/components/CoursesSection.tsx b/apps/web/src/app/main/home/components/CoursesSection.tsx index aa2bf07..e78bc48 100755 --- a/apps/web/src/app/main/home/components/CoursesSection.tsx +++ b/apps/web/src/app/main/home/components/CoursesSection.tsx @@ -6,98 +6,98 @@ import { CoursesSectionTag } from "./CoursesSectionTag"; import CourseList from "@web/src/components/models/course/list/CourseList"; 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<CoursesSectionProps> = ({ - title, - description, - initialVisibleCoursesCount = 8, + title, + description, + initialVisibleCoursesCount = 8, }) => { - const [selectedCategory, setSelectedCategory] = useState<string>("全部"); - const gateGory: GetTaxonomyProps = useGetTaxonomy({ - type: TaxonomySlug.CATEGORY, - }); - return ( - <section className="relative py-20 overflow-hidden bg-gradient-to-b from-gray-50 to-white"> - <div className="max-w-screen-2xl mx-auto px-6 relative"> - <div className="flex justify-between items-end mb-16"> - <div> - <Title - level={2} - className="font-bold text-5xl mb-6 bg-gradient-to-r from-blue-600 to-purple-600 bg-clip-text text-transparent"> - {title} - - - {description} - - - -
- {gateGory.isLoading ? ( - - ) : ( - <> - {["全部", ...gateGory.categories].map( - (category, idx) => ( - - ) - )} - - )} -
- - - - - ); + const [selectedCategory, setSelectedCategory] = useState("全部"); + const gateGory: GetTaxonomyProps = useGetTaxonomy({ + type: TaxonomySlug.CATEGORY, + }); + return ( +
+
+
+
+ + {title} + + + {description} + +
+
+
+ {gateGory.isLoading ? ( + + ) : ( + <> + {["全部", ...gateGory.categories].map( + (category, idx) => ( + + ) + )} + + )} +
+ + +
+
+ ); }; export default CoursesSection; diff --git a/apps/web/src/app/main/layout/MainLayout.tsx b/apps/web/src/app/main/layout/MainLayout.tsx index 0a0074b..b573e2f 100755 --- a/apps/web/src/app/main/layout/MainLayout.tsx +++ b/apps/web/src/app/main/layout/MainLayout.tsx @@ -9,9 +9,9 @@ const { Content } = Layout; export function MainLayout() { return ( - + - + From c45cfe7644635cb73714f85239f99e21cc47120d Mon Sep 17 00:00:00 2001 From: ditiqi Date: Wed, 26 Feb 2025 10:26:21 +0800 Subject: [PATCH 3/8] add --- packages/mind-elixir-core | 1 - 1 file changed, 1 deletion(-) delete mode 160000 packages/mind-elixir-core diff --git a/packages/mind-elixir-core b/packages/mind-elixir-core deleted file mode 160000 index b911b4b..0000000 --- a/packages/mind-elixir-core +++ /dev/null @@ -1 +0,0 @@ -Subproject commit b911b4ba7629da9d6c622abe241fd25299baf1a5 From cd449f43d82f05ede774515c5cc8877b622f9cd6 Mon Sep 17 00:00:00 2001 From: ditiqi Date: Wed, 26 Feb 2025 10:53:06 +0800 Subject: [PATCH 4/8] add --- .../detail/CourseSyllabus/LectureItem.tsx | 7 ++++++- .../editor/context/CourseEditorContext.tsx | 21 ++++++++++--------- .../CourseContentForm/SortableSection.tsx | 3 +++ .../editor/layout/CourseEditorHeader.tsx | 10 ++++++++- 4 files changed, 29 insertions(+), 12 deletions(-) diff --git a/apps/web/src/components/models/course/detail/CourseSyllabus/LectureItem.tsx b/apps/web/src/components/models/course/detail/CourseSyllabus/LectureItem.tsx index f4276bf..ffc0a49 100755 --- a/apps/web/src/components/models/course/detail/CourseSyllabus/LectureItem.tsx +++ b/apps/web/src/components/models/course/detail/CourseSyllabus/LectureItem.tsx @@ -24,7 +24,12 @@ export const LectureItem: React.FC = ({ }, [lectureId, lecture]); return (
onClick(lecture.id)}> {lecture?.meta?.type === LectureType.VIDEO && (
diff --git a/apps/web/src/components/models/course/editor/context/CourseEditorContext.tsx b/apps/web/src/components/models/course/editor/context/CourseEditorContext.tsx index 6b61854..0c8becc 100755 --- a/apps/web/src/components/models/course/editor/context/CourseEditorContext.tsx +++ b/apps/web/src/components/models/course/editor/context/CourseEditorContext.tsx @@ -1,6 +1,7 @@ import { createContext, useContext, ReactNode, useEffect } from "react"; import { Form, FormInstance, message } from "antd"; import { + courseDetailSelect, CourseDto, CourseMeta, CourseStatus, @@ -48,9 +49,7 @@ export function CourseFormProvider({ const { data: course }: { data: CourseDto } = api.post.findFirst.useQuery( { where: { id: editId }, - include: { - terms: true, - }, + select: courseDetailSelect, }, { enabled: Boolean(editId) } ); @@ -65,10 +64,12 @@ export function CourseFormProvider({ useEffect(() => { if (course) { + const deptIds = (course?.depts || [])?.map((dept) => dept.id); const formData = { title: course.title, subTitle: course.subTitle, content: course.content, + deptIds: deptIds, meta: { thumbnail: course?.meta?.thumbnail, }, @@ -91,7 +92,10 @@ export function CourseFormProvider({ const formattedValues = { ...values, meta: { - thumbnail: values?.meta?.thumbnail, + ...((course?.meta as CourseMeta) || {}), + ...(values?.meta?.thumbnail !== undefined && { + thumbnail: values?.meta?.thumbnail, + }), }, terms: { connect: termIds.map((id) => ({ id })), // 转换成 connect 格式 @@ -106,12 +110,9 @@ export function CourseFormProvider({ }); delete formattedValues.sections; delete formattedValues.deptIds; - if (course) { - formattedValues.meta = { - ...(course?.meta as CourseMeta), - thumbnail: values?.meta?.thumbnail, - }; - } + + console.log(course.meta); + console.log(formattedValues?.meta); try { if (editId) { const result = await update.mutateAsync({ diff --git a/apps/web/src/components/models/course/editor/form/CourseContentForm/SortableSection.tsx b/apps/web/src/components/models/course/editor/form/CourseContentForm/SortableSection.tsx index aea9b29..bf6af5b 100755 --- a/apps/web/src/components/models/course/editor/form/CourseContentForm/SortableSection.tsx +++ b/apps/web/src/components/models/course/editor/form/CourseContentForm/SortableSection.tsx @@ -69,6 +69,9 @@ export const SortableSection: React.FC = ({ }); } else { result = await update.mutateAsync({ + where: { + id: field?.id, + }, data: { title: values?.title, }, diff --git a/apps/web/src/components/models/course/editor/layout/CourseEditorHeader.tsx b/apps/web/src/components/models/course/editor/layout/CourseEditorHeader.tsx index 8c23fa7..7ee7866 100755 --- a/apps/web/src/components/models/course/editor/layout/CourseEditorHeader.tsx +++ b/apps/web/src/components/models/course/editor/layout/CourseEditorHeader.tsx @@ -4,6 +4,7 @@ import { useEffect } from "react"; import { useNavigate } from "react-router-dom"; import { CourseStatus, CourseStatusLabel } from "@nice/common"; import { useCourseEditor } from "../context/CourseEditorContext"; +import { useAuth } from "@web/src/providers/auth-provider"; const { Title } = Typography; @@ -16,6 +17,7 @@ const courseStatusVariant: Record = { export default function CourseEditorHeader() { const navigate = useNavigate(); + const {} = useAuth(); const { onSubmit, course, form } = useCourseEditor(); const handleSave = () => { @@ -34,7 +36,13 @@ export default function CourseEditorHeader() {