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, }; };