diff --git a/components/AlgoliaSearchModal.js b/components/AlgoliaSearchModal.js index 54465826..ea727a48 100644 --- a/components/AlgoliaSearchModal.js +++ b/components/AlgoliaSearchModal.js @@ -1,4 +1,4 @@ -import { useState, useImperativeHandle, useRef, useEffect } from 'react' +import { useState, useImperativeHandle, useRef, useEffect, Fragment } from 'react' import algoliasearch from 'algoliasearch' import replaceSearchResult from '@/components/Mark' import Link from 'next/link' @@ -7,6 +7,22 @@ import throttle from 'lodash/throttle' import { siteConfig } from '@/lib/config' import { useHotkeys } from 'react-hotkeys-hook'; +const ShortCutActions = [ + { + key: '↑ ↓', + action: '选择' + }, + { + key: 'Enter', + action: '跳转' + }, + { + key: 'Esc', + action: '关闭' + } + +] + /** * 结合 Algolia 实现的弹出式搜索框 * 打开方式 cRef.current.openSearch() @@ -234,6 +250,15 @@ export default function AlgoliaSearchModal({ cRef }) {
+ {totalHit === 0 && (
+ { + ShortCutActions.map((action, index) => { + return
{action.key}
+ {action.action}
+ }) + } +
) + }
{totalHit > 0 && (