From 7f42d625cefb1fbc44429e2fe1bd76b691f5d97f Mon Sep 17 00:00:00 2001 From: arvinxx Date: Tue, 16 Feb 2021 23:08:52 +0800 Subject: [PATCH] =?UTF-8?q?:children=5Fcrossing:=20fix:=20=E4=BF=AE?= =?UTF-8?q?=E6=AD=A3=E5=9B=9E=E8=BD=A6=E6=97=A0=E6=B3=95=E6=89=93=E5=BC=80?= =?UTF-8?q?=E9=A1=B5=E9=9D=A2=E7=9A=84=20bug?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/contentScripts/searchBar/app/SearchResult/index.tsx | 5 +++-- src/contentScripts/searchBar/app/SearchResult/style.less | 7 +------ .../searchBar/app/SearchResult/useKeyboardResult.ts | 8 +++++++- 3 files changed, 11 insertions(+), 9 deletions(-) diff --git a/src/contentScripts/searchBar/app/SearchResult/index.tsx b/src/contentScripts/searchBar/app/SearchResult/index.tsx index 48dc033..05aa5b1 100644 --- a/src/contentScripts/searchBar/app/SearchResult/index.tsx +++ b/src/contentScripts/searchBar/app/SearchResult/index.tsx @@ -17,6 +17,7 @@ const SearchResult: FC = () => { handleResultIndex, isFocusOnResult, resultRef, + openPage, } = useKeyboardResult(); return ( @@ -32,7 +33,7 @@ const SearchResult: FC = () => { className={styles.skeleton} > {result?.map((item, index) => { - const { title, info, id, url, target, type } = item; + const { title, info, id, target, type } = item; return (
{ [styles.selected]: isFocusOnResult && resultIndex === index, })} onClick={() => { - window.open(url); + openPage(); }} onMouseEnter={() => { handleResultIndex(index); diff --git a/src/contentScripts/searchBar/app/SearchResult/style.less b/src/contentScripts/searchBar/app/SearchResult/style.less index 3b59d09..93b011d 100644 --- a/src/contentScripts/searchBar/app/SearchResult/style.less +++ b/src/contentScripts/searchBar/app/SearchResult/style.less @@ -31,17 +31,12 @@ .selected { background: @item-hover-bg; } -[theme='light'] { - .row:hover { - //.selected; - } -} [theme='dark'] { .desc { .dark-mode-text-color-second; } - .row:hover { + .selected { background: @dark-mode-background-light-hover; } } diff --git a/src/contentScripts/searchBar/app/SearchResult/useKeyboardResult.ts b/src/contentScripts/searchBar/app/SearchResult/useKeyboardResult.ts index 69b0df6..869e5f8 100644 --- a/src/contentScripts/searchBar/app/SearchResult/useKeyboardResult.ts +++ b/src/contentScripts/searchBar/app/SearchResult/useKeyboardResult.ts @@ -42,9 +42,11 @@ export const useKeyboardResult = () => { } }; + const openPage = () => { + window.open(result[resultIndex].url); + }; /** * 按 上下键切换选中的 result - * @param index * @param back */ const switchResultIndex = (back?: boolean) => { @@ -97,6 +99,9 @@ export const useKeyboardResult = () => { case 'Escape': focusOnInput(); break; + case 'Enter': + openPage(); + break; default: } }; @@ -113,5 +118,6 @@ export const useKeyboardResult = () => { resultIndex, handleResultIndex, isFocusOnResult: focusKey === 'result', + openPage, }; };