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="搜索课程" placeholder="搜索课程"
className="w-96 rounded-full" className="w-96 rounded-full"
value={searchValue} value={searchValue}
onClick={(e) => {
if (!window.location.pathname.startsWith("/search")) {
navigate(`/search`);
window.scrollTo({
top: 0,
behavior: "smooth",
});
}
}}
onChange={(e) => setSearchValue(e.target.value)} onChange={(e) => setSearchValue(e.target.value)}
onPressEnter={(e) => { onPressEnter={(e) => {
if ( if (!window.location.pathname.startsWith("/search")) {
!window.location.pathname.startsWith("/courses/") && navigate(`/search`);
!window.location.pathname.startsWith("/my") &&
!window.location.pathname.startsWith("/path")
) {
navigate(`/courses/`);
window.scrollTo({ window.scrollTo({
top: 0, top: 0,
behavior: "smooth", behavior: "smooth",