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