rht02242142
This commit is contained in:
parent
09a23e3f1e
commit
26fb32a69a
|
@ -12,7 +12,7 @@ export default function CoursesPage() {
|
|||
const [currentPage, setCurrentPage] = useState(1);
|
||||
const [selectedCategory, setSelectedCategory] = useState("");
|
||||
const [selectedLevel, setSelectedLevel] = useState("");
|
||||
const pageSize = 12;
|
||||
const pageSize = 9;
|
||||
const [isAll,setIsAll] = useState(true)
|
||||
const [searchParams, setSearchParams] = useSearchParams();
|
||||
let coursesData = []
|
||||
|
@ -55,8 +55,11 @@ export default function CoursesPage() {
|
|||
isCourseLoading = isLoading
|
||||
}
|
||||
useEffect(() => {
|
||||
console.log(coursesData)
|
||||
}, [coursesData]);
|
||||
if(searchParams.get('searchValue')==''){
|
||||
setSelectedCategory('');
|
||||
setSelectedLevel('')
|
||||
}
|
||||
}, [searchParams.get('searchValue')]);
|
||||
const filteredCourses = useMemo(() => {
|
||||
return isCourseLoading ? [] : coursesData;
|
||||
}, [isCourseLoading, coursesData, selectedCategory, selectedLevel]);
|
||||
|
@ -70,7 +73,9 @@ export default function CoursesPage() {
|
|||
setCurrentPage(page);
|
||||
window.scrollTo({ top: 0, behavior: "smooth" });
|
||||
};
|
||||
|
||||
useEffect(()=>{
|
||||
setCurrentPage(1)
|
||||
},[])
|
||||
|
||||
|
||||
return (
|
||||
|
|
|
@ -63,7 +63,7 @@ const CategorySection = () => {
|
|||
orderBy: {
|
||||
createdAt: 'desc', // 按创建时间降序排列
|
||||
},
|
||||
take:10
|
||||
take:8
|
||||
})
|
||||
// 分类展示
|
||||
const [displayedCategories,setDisplayedCategories] = useState<TermDto[]>([])
|
||||
|
@ -194,7 +194,11 @@ const CategorySection = () => {
|
|||
type="default"
|
||||
size="large"
|
||||
className="px-8 h-12 text-base font-medium hover:shadow-md transition-all duration-300"
|
||||
onClick={() => setShowAll(!showAll)}
|
||||
onClick={() => {
|
||||
//setShowAll(!showAll)
|
||||
navigate("/courses")
|
||||
window.scrollTo({ top: 0, behavior: 'smooth' })
|
||||
}}
|
||||
>
|
||||
{showAll ? '收起' : '查看更多分类'}
|
||||
</Button>
|
||||
|
|
|
@ -35,9 +35,11 @@ export function MainHeader() {
|
|||
className="w-72 rounded-full"
|
||||
value={searchValue}
|
||||
onChange={(e) => setSearchValue(e.target.value)}
|
||||
onPressEnter={()=>{
|
||||
//console.log(searchValue)
|
||||
onPressEnter={(e)=>{
|
||||
//console.log(e)
|
||||
setSearchValue('')
|
||||
navigate(`/courses/?searchValue=${searchValue}`)
|
||||
window.scrollTo({ top: 0, behavior: "smooth" });
|
||||
}}
|
||||
/>
|
||||
</div>
|
||||
|
|
Loading…
Reference in New Issue