From b1ffa283034cd02e27923be7d7cdacb1643a7254 Mon Sep 17 00:00:00 2001 From: Bhwa233 <404174262@qq.com> Date: Sat, 16 Mar 2024 14:34:03 +0800 Subject: [PATCH] =?UTF-8?q?=E5=A2=9E=E5=8A=A0=E6=93=8D=E4=BD=9C=E6=8F=90?= =?UTF-8?q?=E7=A4=BA?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- components/AlgoliaSearchModal.js | 28 +++++++++++++++++++++++++++- components/ShortcutTag.js | 7 +++++++ 2 files changed, 34 insertions(+), 1 deletion(-) create mode 100644 components/ShortcutTag.js diff --git a/components/AlgoliaSearchModal.js b/components/AlgoliaSearchModal.js index 54465826..49cad8b2 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' @@ -6,6 +6,23 @@ import { useGlobal } from '@/lib/global' import throttle from 'lodash/throttle' import { siteConfig } from '@/lib/config' import { useHotkeys } from 'react-hotkeys-hook'; +import ShortcutTag from '@/components/ShortcutTag' + +const ShortCutActions = [ + { + key: '↑ ↓', + action: '选择' + }, + { + key: 'Enter', + action: '跳转' + }, + { + key: 'Esc', + action: '关闭' + } + +] /** * 结合 Algolia 实现的弹出式搜索框 @@ -234,6 +251,15 @@ export default function AlgoliaSearchModal({ cRef }) {
+ {totalHit === 0 && (
+ { + ShortCutActions.map((action, index) => { + return
{action.key}
+ {action.action}
+ }) + } +
) + }
{totalHit > 0 && (

diff --git a/components/ShortcutTag.js b/components/ShortcutTag.js new file mode 100644 index 00000000..4e36e8be --- /dev/null +++ b/components/ShortcutTag.js @@ -0,0 +1,7 @@ +// 操作提示标签 +import React from 'react'; + +const ShortcutTag = ({ children, className }) => { + return

{children}
+} +export default ShortcutTag \ No newline at end of file