From fd08ce9bb8af2e735f734bf9103c9f430c33bfbe Mon Sep 17 00:00:00 2001 From: Bhwa233 <404174262@qq.com> Date: Tue, 5 Mar 2024 17:27:37 +0800 Subject: [PATCH] =?UTF-8?q?1.=20=E5=A4=9C=E9=97=B4=E6=A8=A1=E5=BC=8F?= =?UTF-8?q?=E6=90=9C=E7=B4=A2=E5=88=B0=E7=9A=84=E5=86=85=E5=AE=B9=E7=9C=8B?= =?UTF-8?q?=E4=B8=8D=E8=A7=81=E3=80=82=202.=20=E8=BE=93=E5=85=A5=E6=90=9C?= =?UTF-8?q?=E7=B4=A2=E5=86=85=E5=AE=B9=E5=90=8E=E6=98=BE=E7=A4=BA=E6=97=A0?= =?UTF-8?q?=E6=B3=95=E6=89=BE=E5=88=B0=E7=9B=B8=E5=85=B3=E7=BB=93=E6=9E=9C?= =?UTF-8?q?"xxx"=20=E5=90=8E=E6=9C=89=E4=B8=80=E5=AE=9A=E7=9A=84=E5=BB=B6?= =?UTF-8?q?=E8=BF=9F=E6=89=8D=E8=83=BD=E6=98=BE=E7=A4=BA=E6=90=9C=E7=B4=A2?= =?UTF-8?q?=E7=BB=93=E6=9E=9C=EF=BC=8C=E6=88=91=E8=A7=89=E5=BE=97=E5=8F=AF?= =?UTF-8?q?=E4=BB=A5=E6=8A=8A=E6=97=A0=E6=B3=95=E6=89=BE=E5=88=B0=E7=9B=B8?= =?UTF-8?q?=E5=85=B3=E7=BB=93=E6=9E=9C=E5=8E=BB=E6=8E=89=E3=80=82=203.=20?= =?UTF-8?q?=E9=80=89=E4=B8=AD=E6=A1=86=E5=BA=94=E5=A2=9E=E5=8A=A0=E5=9C=86?= =?UTF-8?q?=E8=A7=92=EF=BC=8C=E4=B8=8E=E4=B8=BB=E9=A2=98=E4=B8=80=E8=87=B4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- components/AlgoliaSearchModal.js | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/components/AlgoliaSearchModal.js b/components/AlgoliaSearchModal.js index f7bcdeb9..8aaed271 100644 --- a/components/AlgoliaSearchModal.js +++ b/components/AlgoliaSearchModal.js @@ -22,6 +22,7 @@ export default function AlgoliaSearchModal({ cRef }) { const [useTime, setUseTime] = useState(0) const inputRef = useRef(null) const [activeIndex, setActiveIndex] = useState(0) + const [isLoading, setIsLoading] = useState(false) useHotkeys('ctrl+k', (e) => { e.preventDefault() setIsModalOpen(true) @@ -105,7 +106,7 @@ export default function AlgoliaSearchModal({ cRef }) { if (!query || query === '') { return } - + setIsLoading(true) try { const res = await index.search(query, { page, hitsPerPage: 10 }) const { hits, nbHits, nbPages, processingTimeMS } = res @@ -113,6 +114,7 @@ export default function AlgoliaSearchModal({ cRef }) { setTotalPage(nbPages) setTotalHit(nbHits) setSearchResults(hits) + setIsLoading(false) const doms = document.getElementById('search-wrapper').getElementsByClassName('replace') setTimeout(() => { @@ -205,7 +207,7 @@ export default function AlgoliaSearchModal({ cRef }) { { - searchResults.length === 0 && keyword && ( + searchResults.length === 0 && keyword && !isLoading && (

无法找到相关结果 setActiveIndex(index)} onClick={() => onJumpSearchResult(index)} - className={`cursor-pointer replace my-2 p-2 duration-100 ${activeIndex === index ? 'bg-blue-600 dark:bg-yellow-600' : ''}`}> + className={`cursor-pointer replace my-2 p-2 duration-100 + rounded-lg + ${activeIndex === index ? 'bg-blue-600 dark:bg-yellow-600' : ''}`}> @@ -237,7 +241,7 @@ export default function AlgoliaSearchModal({ cRef }) {

)}
-
+
Algolia 提供搜索服务 @@ -294,7 +298,7 @@ function Pagination(props) { {Array.from({ length: totalPage }, (_, i) => { const classNames = page === i ? 'font-bold text-white bg-blue-600 dark:bg-yellow-600 rounded' - : 'hover:text-blue-600 hover:font-bold' + : 'hover:text-blue-600 hover:font-bold dark:text-gray-300' return (