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/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 c6a2969..b4938b0 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, @@ -10,14 +10,13 @@ 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 { categories: string[]; isLoading: boolean; } - function useGetTaxonomy({ type }): GetTaxonomyProps { const { data, isLoading }: { data: TermDto[], isLoading: boolean } = api.term.findMany.useQuery({ where: { @@ -40,6 +39,26 @@ function useGetTaxonomy({ type }): GetTaxonomyProps { }, [data]); 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; @@ -60,10 +79,11 @@ interface CoursesSectionProps { title: string; description: string; courses: Course[]; - isLoading:boolean + isLoading: boolean initialVisibleCoursesCount?: number; } + const CoursesSection: React.FC = ({ title, description, @@ -77,40 +97,24 @@ const CoursesSection: React.FC = ({ 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 { data, isLoading: isDataLoading } = useFetchCoursesByCategory(selectedCategory); + useEffect(() => { + console.log('data:', data) + }) + const handleClick = (course: CourseDto) => { + navigate(`/course/${course.id}/detail`); } + useEffect(() => { + console.log('data:', data) + }) 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 (
@@ -140,32 +144,37 @@ const CoursesSection: React.FC = ({ : 'bg-white text-gray-600 hover:bg-gray-100' }`} >全部 - { - gateGory.categories.map((category) => ( - { - 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} - - )) + {gateGory.categories.map((category) => ( + { + 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} + + + )) } + ) }
- {displayedCourses.map((course) => ( + {displayedCourses.length=== 0 ? ( +
+ +
+ ) : displayedCourses?.map((course) => ( handleClick(course)} key={course.id} @@ -176,23 +185,10 @@ const CoursesSection: React.FC = ({
- {course.progress > 0 && ( -
- {/* */} -
- )}
} > @@ -202,19 +198,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} </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 0399c32..f73357d 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 */} diff --git a/apps/web/src/app/main/home/page.tsx b/apps/web/src/app/main/home/page.tsx index 9fcac1d..7250975 100755 --- a/apps/web/src/app/main/home/page.tsx +++ b/apps/web/src/app/main/home/page.tsx @@ -137,7 +137,7 @@ const HomePage = () => { return ( <div className="min-h-screen"> <HeroSection /> - + <CoursesSection title="推荐课程" description="最受欢迎的精品课程,助你快速成长" 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() { {/* 开发组织信息 */} <div className="text-center md:text-left space-y-2"> <h3 className="text-white font-semibold text-sm flex items-center justify-center md:justify-start"> - 创新高地 软件小组 + 软件与数据小组 </h3> <p className="text-gray-400 text-xs italic"> 提供技术支持 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(() => {