feat: shortcut h to show shortcuts modal (#361)

This commit is contained in:
Stephen Zhou 2024-09-12 17:07:11 +08:00 committed by GitHub
parent a2457a7789
commit e9dc7b2f4c
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
3 changed files with 19 additions and 1 deletions

View File

@ -20,6 +20,10 @@ export const shortcuts = {
name: "Show/Hide Feed Sidebar",
key: "Meta+B",
},
showShortcuts: {
name: "Show Shortcuts",
key: "H",
},
},
entries: {
refetch: {

View File

@ -24,6 +24,7 @@ import { CornerPlayer } from "@renderer/modules/feed-column/corner-player"
import { CmdF } from "@renderer/modules/panel/cmdf"
import { SearchCmdK } from "@renderer/modules/panel/cmdk"
import { CmdNTrigger } from "@renderer/modules/panel/cmdn"
import { useSettingModal } from "@renderer/modules/settings/modal/hooks"
import { throttle } from "lodash-es"
import type { PropsWithChildren } from "react"
import React, { useEffect, useRef, useState } from "react"
@ -168,6 +169,16 @@ const FeedResponsiveResizerContainer = ({
scopes: HotKeyScopeMap.Home,
},
)
const settingModalPresent = useSettingModal()
useHotkeys(
shortcuts.layout.showShortcuts.key,
() => {
settingModalPresent("shortcuts")
},
{
scopes: HotKeyScopeMap.Home,
},
)
const [delayShowSplitter, setDelayShowSplitter] = useState(feedColumnShow)

View File

@ -1,4 +1,4 @@
import { KbdCombined } from "@renderer/components/ui/kbd/Kbd"
import { Kbd, KbdCombined } from "@renderer/components/ui/kbd/Kbd"
import { shortcuts } from "@renderer/constants/shortcuts"
import { cn } from "@renderer/lib/utils"
import { SettingsTitle } from "@renderer/modules/settings/title"
@ -17,6 +17,9 @@ export function Component() {
return (
<>
<SettingsTitle />
<p className="text-sm">
Press <Kbd>H</Kbd> to show this Shortcuts modal.
</p>
<div className="mt-4 space-y-6">
{Object.keys(shortcuts).map((type) => (
<section key={type}>