This commit is contained in:
ditiqi 2025-02-27 12:21:35 +08:00
parent ed5949a06d
commit 73757c0ee9
1 changed files with 11 additions and 6 deletions

View File

@ -39,14 +39,19 @@ export function MainHeader() {
placeholder="搜索课程"
className="w-96 rounded-full"
value={searchValue}
onClick={(e) => {
if (!window.location.pathname.startsWith("/search")) {
navigate(`/search`);
window.scrollTo({
top: 0,
behavior: "smooth",
});
}
}}
onChange={(e) => setSearchValue(e.target.value)}
onPressEnter={(e) => {
if (
!window.location.pathname.startsWith("/courses/") &&
!window.location.pathname.startsWith("/my") &&
!window.location.pathname.startsWith("/path")
) {
navigate(`/courses/`);
if (!window.location.pathname.startsWith("/search")) {
navigate(`/search`);
window.scrollTo({
top: 0,
behavior: "smooth",