From 73757c0ee904959c3c0bcd598bdf522a318ebea9 Mon Sep 17 00:00:00 2001 From: ditiqi Date: Thu, 27 Feb 2025 12:21:35 +0800 Subject: [PATCH] add --- apps/web/src/app/main/layout/MainHeader.tsx | 17 +++++++++++------ 1 file changed, 11 insertions(+), 6 deletions(-) diff --git a/apps/web/src/app/main/layout/MainHeader.tsx b/apps/web/src/app/main/layout/MainHeader.tsx index de0d1ce..f0d27c1 100755 --- a/apps/web/src/app/main/layout/MainHeader.tsx +++ b/apps/web/src/app/main/layout/MainHeader.tsx @@ -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",