From 6959424af362cc2cf2a26c0955669e827c07ca9c Mon Sep 17 00:00:00 2001 From: wfc <2146706290@qq.com> Date: Tue, 25 Feb 2025 09:59:22 +0800 Subject: [PATCH 1/5] UserMenu --- apps/server/src/auth/utils.ts | 1 + apps/web/src/app/main/layout/MainFooter.tsx | 2 +- apps/web/src/app/main/layout/UserMenu/UserForm.tsx | 2 +- 3 files changed, 3 insertions(+), 2 deletions(-) diff --git a/apps/server/src/auth/utils.ts b/apps/server/src/auth/utils.ts index 5e8cd9a..b1b2a88 100755 --- a/apps/server/src/auth/utils.ts +++ b/apps/server/src/auth/utils.ts @@ -155,6 +155,7 @@ export class UserProfileService { where: { id }, select: { id: true, + avatar:true, deptId: true, department: true, domainId: true, diff --git a/apps/web/src/app/main/layout/MainFooter.tsx b/apps/web/src/app/main/layout/MainFooter.tsx index 1356335..e37d149 100755 --- a/apps/web/src/app/main/layout/MainFooter.tsx +++ b/apps/web/src/app/main/layout/MainFooter.tsx @@ -8,7 +8,7 @@ export function MainFooter() { {/* 开发组织信息 */}

- 创新高地 软件小组 + 软件与数据小组

提供技术支持 diff --git a/apps/web/src/app/main/layout/UserMenu/UserForm.tsx b/apps/web/src/app/main/layout/UserMenu/UserForm.tsx index e17bffa..efbf12c 100644 --- a/apps/web/src/app/main/layout/UserMenu/UserForm.tsx +++ b/apps/web/src/app/main/layout/UserMenu/UserForm.tsx @@ -84,7 +84,7 @@ export default function StaffForm() { form.setFieldValue("officerId", data.officerId); form.setFieldValue("phoneNumber", data.phoneNumber); form.setFieldValue("enabled", data.enabled); - form.setFieldValue("enabled", data.avatar); + form.setFieldValue("avatar", data.avatar); } }, [data]); // useEffect(() => { From 4eb87d511ada539b3a0227153377b94ec350ed9d Mon Sep 17 00:00:00 2001 From: Rao <1227431568@qq.com> Date: Tue, 25 Feb 2025 10:01:17 +0800 Subject: [PATCH 2/5] rht02251001 --- .../main/home/components/CoursesSection.tsx | 63 +++++++++++-------- .../app/main/home/components/HeroSection.tsx | 18 +++--- 2 files changed, 47 insertions(+), 34 deletions(-) diff --git a/apps/web/src/app/main/home/components/CoursesSection.tsx b/apps/web/src/app/main/home/components/CoursesSection.tsx index c6a2969..9fe682d 100755 --- a/apps/web/src/app/main/home/components/CoursesSection.tsx +++ b/apps/web/src/app/main/home/components/CoursesSection.tsx @@ -10,7 +10,7 @@ import { ArrowRightOutlined, EyeOutlined, } from '@ant-design/icons'; -import { TaxonomySlug, TermDto } from '@nice/common'; +import { CourseDto, TaxonomySlug, TermDto } from '@nice/common'; import { api } from '@nice/client'; // const {courseId} = useParams(); interface GetTaxonomyProps { @@ -41,6 +41,24 @@ function useGetTaxonomy({ type }): GetTaxonomyProps { return { categories, isLoading } } +function useFetchCoursesByCategory(category: string) { + const isAll = category === '全部'; + const { data, isLoading}:{data:CourseDto[],isLoading:boolean} = api.post.findMany.useQuery({ + where: isAll?{}:{ + terms: { + some: { + name:category + }, + }, + }, + take: 8, + include:{ + terms:true + } + }); + + return { data, isLoading}; +} const { Title, Text } = Typography; @@ -77,6 +95,10 @@ const CoursesSection: React.FC = ({ const gateGory: GetTaxonomyProps = useGetTaxonomy({ type: TaxonomySlug.CATEGORY, }) + const { data ,isLoading : isDataLoading} = useFetchCoursesByCategory(selectedCategory); + useEffect(()=>{ + console.log('data:', data) + }) // const { data } = api.post.findMany.useQuery({ // where: {}, // 必选参数 // include: { // 关联查询 @@ -100,17 +122,17 @@ const CoursesSection: React.FC = ({ // id: course.id, // title: course.title // })); - const handleClick = (course: Course) => { + const handleClick = (course: CourseDto) => { navigate(`/course?courseId=${course.id}/detail`); } const filteredCourses = useMemo(() => { return selectedCategory === '全部' - ? courses - : courses.filter((course) => course.category === selectedCategory); - }, [selectedCategory, courses]); + ? data + : data?.filter(c => c.terms.some(t => t.name === selectedCategory)); + }, [selectedCategory, data]); - const displayedCourses = isLoading ? [] : filteredCourses.slice(0, visibleCourses); + const displayedCourses = isDataLoading ? [] : filteredCourses?.slice(0, visibleCourses); return (

@@ -165,7 +187,7 @@ const CoursesSection: React.FC = ({
- {displayedCourses.map((course) => ( + {displayedCourses?.map((course) => ( handleClick(course)} key={course.id} @@ -176,23 +198,10 @@ const CoursesSection: React.FC = ({
- {course.progress > 0 && ( -
- {/* */} -
- )}
} > @@ -202,19 +211,19 @@ const CoursesSection: React.FC = ({ color="blue" className="px-3 py-1 rounded-full bg-blue-100 text-blue-600 border-0" > - {course.category} + {course.terms[0].name} - {course.level} + {course.terms[1].name}
= ({ <TeamOutlined className="text-blue-500 text-lg transform group-hover:scale-110 transition-transform duration-300" /> <div className="ml-2 flex items-center flex-grow"> <Text className="font-medium text-blue-500 hover:text-blue-600 transition-colors duration-300"> - {course.instructor} + {/* {course.} */} </Text> </div> <span className="flex items-center bg-blue-100 px-2 py-1 rounded-full text-blue-600 hover:bg-blue-200 transition-colors duration-300"> <EyeOutlined className="ml-1.5 text-sm" /> - <span className="text-xs font-medium">观看次数{course.progress}次</span> + <span className="text-xs font-medium">观看次数{course?.meta?.views}次</span> </span> </div> <div className="pt-4 border-t border-gray-100 text-center"> diff --git a/apps/web/src/app/main/home/components/HeroSection.tsx b/apps/web/src/app/main/home/components/HeroSection.tsx index 5a58d12..e0e443d 100755 --- a/apps/web/src/app/main/home/components/HeroSection.tsx +++ b/apps/web/src/app/main/home/components/HeroSection.tsx @@ -1,4 +1,4 @@ -import React, { useRef, useCallback } from "react"; +import React, { useRef, useCallback, useEffect } from "react"; import { Button, Carousel, Typography } from "antd"; import { TeamOutlined, @@ -62,7 +62,11 @@ const HeroSection = () => { const handleNext = useCallback(() => { carouselRef.current?.next(); }, []); - //const {slides:carouselItems} = useAppConfig() + const { slides } = useAppConfig() + useEffect(() => { + //slides.push(('https://s.cn.bing.net/th?id=OHR.GiantCuttlefish_ZH-CN0670915878_1920x1080.webp&qlt=50')) + //console.log(slides) + }, []) return ( <section className="relative "> <div className="group"> @@ -74,20 +78,20 @@ const HeroSection = () => { dots={{ className: "carousel-dots !bottom-32 !z-20", }}> - {Array.isArray(carouselItems)? - (carouselItems.map((item, index) => ( + {Array.isArray(slides)? + (slides.map((item, index) => ( <div key={index} className="relative h-[600px]"> <div className="absolute inset-0 bg-cover bg-center transform transition-[transform,filter] duration-[2000ms] group-hover:scale-105 group-hover:brightness-110 will-change-[transform,filter]" style={{ //backgroundImage: `url(https://s.cn.bing.net/th?id=OHR.GiantCuttlefish_ZH-CN0670915878_1920x1080.webp&qlt=50)`, - backgroundImage: `url(${item.image})`, + backgroundImage: `url(${item})`, backfaceVisibility: "hidden", }} /> - <div + {/* <div className={`absolute inset-0 bg-gradient-to-r ${item.color} to-transparent opacity-90 mix-blend-overlay transition-opacity duration-500`} - /> + /> */} <div className="absolute inset-0 bg-gradient-to-t from-black/50 to-transparent" /> {/* Content Container */} From 79f51e1b55216214db36cd8d1d6e4b63f7b5270f Mon Sep 17 00:00:00 2001 From: Li1304553726 <1304553726@qq.com> Date: Tue, 25 Feb 2025 10:02:40 +0800 Subject: [PATCH 3/5] add. --- .../main/home/components/CategorySection.tsx | 3 - .../main/home/components/CoursesSection.tsx | 79 +++++++++++-------- apps/web/src/app/main/home/page.tsx | 6 +- 3 files changed, 49 insertions(+), 39 deletions(-) diff --git a/apps/web/src/app/main/home/components/CategorySection.tsx b/apps/web/src/app/main/home/components/CategorySection.tsx index c2eff20..81b201a 100755 --- a/apps/web/src/app/main/home/components/CategorySection.tsx +++ b/apps/web/src/app/main/home/components/CategorySection.tsx @@ -84,9 +84,6 @@ const CategorySection = () => { // description: term.description // })) || []; // },[data]) - - - const handleMouseEnter = useCallback((index: number) => { setHoveredIndex(index); }, []); diff --git a/apps/web/src/app/main/home/components/CoursesSection.tsx b/apps/web/src/app/main/home/components/CoursesSection.tsx index 1b7edd7..efa7270 100755 --- a/apps/web/src/app/main/home/components/CoursesSection.tsx +++ b/apps/web/src/app/main/home/components/CoursesSection.tsx @@ -1,6 +1,6 @@ import React, { useState, useMemo, useEffect } from 'react'; import { useNavigate, useParams, useSearchParams } from 'react-router-dom'; -import { Button, Card, Typography, Tag, Progress, Spin } from 'antd'; +import { Button, Card, Typography, Tag, Progress, Spin, Empty } from 'antd'; import { PlayCircleOutlined, UserOutlined, @@ -17,7 +17,6 @@ interface GetTaxonomyProps { categories: string[]; isLoading: boolean; } - function useGetTaxonomy({ type }): GetTaxonomyProps { const { data, isLoading }: { data: TermDto[], isLoading: boolean } = api.term.findMany.useQuery({ where: { @@ -40,8 +39,11 @@ function useGetTaxonomy({ type }): GetTaxonomyProps { }, [data]); return { categories, isLoading } } +// 修改useGetName中的查询条件 +// 不同分类跳转 + const { Title, Text } = Typography; interface Course { @@ -63,6 +65,25 @@ interface CoursesSectionProps { isLoading:boolean initialVisibleCoursesCount?: number; } +function useFetchCoursesByCategory(category: string) { + const isAll = category === '全部'; + const { data, isLoading } = api.post.findMany.useQuery({ + where: isAll?{}:{ + terms: { + some: { + name:category + }, + }, + }, + take: 8, + include:{ + terms:true + } + }); + + return { data, isLoading }; +} + const CoursesSection: React.FC<CoursesSectionProps> = ({ title, @@ -77,39 +98,22 @@ const CoursesSection: React.FC<CoursesSectionProps> = ({ const gateGory: GetTaxonomyProps = useGetTaxonomy({ type: TaxonomySlug.CATEGORY, }) - // const { data } = api.post.findMany.useQuery({ - // where: {}, // 必选参数 - // include: { // 关联查询 - // instructors: true - // }, - // orderBy: { // 排序规则 - // createdAt: 'desc' - // }, - // take: 8 - // }) - // useEffect(() => { - // // 添加空值保护 - // if (data && data.length > 0) { - // console.log('有效数据:', data) - // // 执行后续操作 - // } else { - // console.log('无数据或加载中') - // } - // }, [data]) - // const formatted = data?.map(course => ({ - // id: course.id, - // title: course.title - // })); - const handleClick = (course: Course) => { - navigate(`/course?courseId=${course.id}/detail`); - } + const handleClick = (course: Course) => { + navigate(`/course/${course.id}/detail`); + } + const { data } = useFetchCoursesByCategory(selectedCategory); + + useEffect(()=>{ + console.log('data:', data) + }) const filteredCourses = useMemo(() => { return selectedCategory === '全部' ? courses : courses.filter((course) => course.category === selectedCategory); }, [selectedCategory, courses]); + const displayedCourses = isLoading ? [] : filteredCourses.slice(0, visibleCourses); return ( <section className="relative py-20 overflow-hidden bg-gradient-to-b from-gray-50 to-white"> @@ -140,12 +144,22 @@ const CoursesSection: React.FC<CoursesSectionProps> = ({ : 'bg-white text-gray-600 hover:bg-gray-100' }`} >全部</Tag> - { + {gateGory.categories.length === 0 && ( + <Empty + description="暂无课程分类" + image={Empty.PRESENTED_IMAGE_DEFAULT} + /> + )}:{ gateGory.categories.map((category) => ( <Tag key={category} color={selectedCategory === category ? 'blue' : 'default'} - onClick={() => setSelectedCategory(category)} + onClick={() => { + setSelectedCategory(category) + // console.log(gateGory) + } + } + className={`px-6 py-2 text-base cursor-pointer rounded-full transition-all duration-300 ${selectedCategory === category ? 'bg-blue-600 text-white shadow-lg' : 'bg-white text-gray-600 hover:bg-gray-100' @@ -155,6 +169,7 @@ const CoursesSection: React.FC<CoursesSectionProps> = ({ </Tag> )) } + </> ) } @@ -229,7 +244,7 @@ const CoursesSection: React.FC<CoursesSectionProps> = ({ </div> <span className="flex items-center bg-blue-100 px-2 py-1 rounded-full text-blue-600 hover:bg-blue-200 transition-colors duration-300"> <EyeOutlined className="ml-1.5 text-sm" /> - <span className="text-xs font-medium">观看次数{course.progress}次</span> + <span className="text-xs font-medium">观看次数{course.progress}</span> </span> </div> <div className="pt-4 border-t border-gray-100 text-center"> @@ -262,7 +277,7 @@ const CoursesSection: React.FC<CoursesSectionProps> = ({ </Button> </div> </div> - )} +)} </div> </section> ); diff --git a/apps/web/src/app/main/home/page.tsx b/apps/web/src/app/main/home/page.tsx index 3a7b2af..b1a2b82 100755 --- a/apps/web/src/app/main/home/page.tsx +++ b/apps/web/src/app/main/home/page.tsx @@ -127,12 +127,10 @@ const HomePage = () => { }); useEffect(() => { if (data) { - console.log('mockCourses data:', data); + console.log('Courses data:', data); } }, [data]); - - // 数据处理逻辑 -// 修正依赖数组 + return ( <div className="min-h-screen"> <HeroSection /> From 4fda0ecdef0238743cc5a90c198562be254d0f83 Mon Sep 17 00:00:00 2001 From: Li1304553726 <1304553726@qq.com> Date: Tue, 25 Feb 2025 10:08:43 +0800 Subject: [PATCH 4/5] add. --- apps/web/src/app/main/home/components/CoursesSection.tsx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/apps/web/src/app/main/home/components/CoursesSection.tsx b/apps/web/src/app/main/home/components/CoursesSection.tsx index 0c04870..fc7e3a9 100755 --- a/apps/web/src/app/main/home/components/CoursesSection.tsx +++ b/apps/web/src/app/main/home/components/CoursesSection.tsx @@ -126,7 +126,7 @@ const CoursesSection: React.FC<CoursesSectionProps> = ({ // title: course.title // })); const handleClick = (course: CourseDto) => { - navigate(`/course?courseId=${course.id}/detail`); + navigate(`/course/${course.id}/detail`); } useEffect(()=>{ From 9db19fa02a0420527b1795559f70de185f0db884 Mon Sep 17 00:00:00 2001 From: Li1304553726 <1304553726@qq.com> Date: Tue, 25 Feb 2025 10:58:35 +0800 Subject: [PATCH 5/5] li --- .../main/home/components/CoursesSection.tsx | 100 +++++++----------- 1 file changed, 37 insertions(+), 63 deletions(-) diff --git a/apps/web/src/app/main/home/components/CoursesSection.tsx b/apps/web/src/app/main/home/components/CoursesSection.tsx index fc7e3a9..b4938b0 100755 --- a/apps/web/src/app/main/home/components/CoursesSection.tsx +++ b/apps/web/src/app/main/home/components/CoursesSection.tsx @@ -39,28 +39,27 @@ function useGetTaxonomy({ type }): GetTaxonomyProps { }, [data]); return { categories, isLoading } } -// 修改useGetName中的查询条件 - +// 不同分类跳转 function useFetchCoursesByCategory(category: string) { const isAll = category === '全部'; - const { data, isLoading}:{data:CourseDto[],isLoading:boolean} = api.post.findMany.useQuery({ - where: isAll?{}:{ + const { data, isLoading }: { data: CourseDto[], isLoading: boolean } = api.post.findMany.useQuery({ + where: isAll ? {} : { terms: { some: { - name:category + name: category }, }, }, take: 8, - include:{ - terms:true + include: { + terms: true } }); - return { data, isLoading}; + return { data, isLoading }; } -// 不同分类跳转 + const { Title, Text } = Typography; @@ -80,7 +79,7 @@ interface CoursesSectionProps { title: string; description: string; courses: Course[]; - isLoading:boolean + isLoading: boolean initialVisibleCoursesCount?: number; } @@ -98,38 +97,15 @@ const CoursesSection: React.FC<CoursesSectionProps> = ({ const gateGory: GetTaxonomyProps = useGetTaxonomy({ type: TaxonomySlug.CATEGORY, }) - const { data ,isLoading : isDataLoading} = useFetchCoursesByCategory(selectedCategory); - useEffect(()=>{ + const { data, isLoading: isDataLoading } = useFetchCoursesByCategory(selectedCategory); + useEffect(() => { console.log('data:', data) }) - // const { data } = api.post.findMany.useQuery({ - // where: {}, // 必选参数 - // include: { // 关联查询 - // instructors: true - // }, - // orderBy: { // 排序规则 - // createdAt: 'desc' - // }, - // take: 8 - // }) - // useEffect(() => { - // // 添加空值保护 - // if (data && data.length > 0) { - // console.log('有效数据:', data) - // // 执行后续操作 - // } else { - // console.log('无数据或加载中') - // } - // }, [data]) - // const formatted = data?.map(course => ({ - // id: course.id, - // title: course.title - // })); const handleClick = (course: CourseDto) => { navigate(`/course/${course.id}/detail`); } - useEffect(()=>{ + useEffect(() => { console.log('data:', data) }) const filteredCourses = useMemo(() => { @@ -168,38 +144,37 @@ const CoursesSection: React.FC<CoursesSectionProps> = ({ : 'bg-white text-gray-600 hover:bg-gray-100' }`} >全部</Tag> - {gateGory.categories.length === 0 && ( - <Empty - description="暂无课程分类" - image={Empty.PRESENTED_IMAGE_DEFAULT} - /> - )}:{ - gateGory.categories.map((category) => ( - <Tag - key={category} - color={selectedCategory === category ? 'blue' : 'default'} - onClick={() => { - setSelectedCategory(category) - console.log(category) - }} - className={`px-6 py-2 text-base cursor-pointer rounded-full transition-all duration-300 ${selectedCategory === category - ? 'bg-blue-600 text-white shadow-lg' - : 'bg-white text-gray-600 hover:bg-gray-100' - }`} - - > - {category} - </Tag> - )) + {gateGory.categories.map((category) => ( + <Tag + key={category} + color={selectedCategory === category ? 'blue' : 'default'} + onClick={() => { + setSelectedCategory(category) + console.log(category) + }} + className={`px-6 py-2 text-base cursor-pointer rounded-full transition-all duration-300 ${selectedCategory === category + ? 'bg-blue-600 text-white shadow-lg' + : 'bg-white text-gray-600 hover:bg-gray-100' + }`} + + > + {category} + </Tag> + + )) } - + </> ) } </div> <div className="grid grid-cols-1 md:grid-cols-2 lg:grid-cols-4 gap-8"> - {displayedCourses?.map((course) => ( + {displayedCourses.length=== 0 ? ( + <div className="col-span-full"> + <Empty description="暂无课程" image={Empty.PRESENTED_IMAGE_DEFAULT} /> + </div> + ) : displayedCourses?.map((course) => ( <Card onClick={() => handleClick(course)} key={course.id} @@ -249,7 +224,6 @@ const CoursesSection: React.FC<CoursesSectionProps> = ({ <TeamOutlined className="text-blue-500 text-lg transform group-hover:scale-110 transition-transform duration-300" /> <div className="ml-2 flex items-center flex-grow"> <Text className="font-medium text-blue-500 hover:text-blue-600 transition-colors duration-300"> - {/* {course.} */} </Text> </div> <span className="flex items-center bg-blue-100 px-2 py-1 rounded-full text-blue-600 hover:bg-blue-200 transition-colors duration-300"> @@ -287,7 +261,7 @@ const CoursesSection: React.FC<CoursesSectionProps> = ({ </Button> </div> </div> -)} + )} </div> </section> );