Skip to content

Commit

Permalink
💄 style: Support shortcut keys to open session settings (lobehub#5178)
Browse files Browse the repository at this point in the history
  • Loading branch information
Wxh16144 authored and Ubuntu committed Dec 27, 2024
1 parent 2bc3dfa commit fbc9fad
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 0 deletions.
7 changes: 7 additions & 0 deletions src/app/(main)/chat/(workspace)/_layout/Desktop/HotKeys.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import isEqual from 'fast-deep-equal';
import { useHotkeys } from 'react-hotkeys-hook';

import { HOTKEYS } from '@/const/hotkeys';
import { useOpenChatSettings } from '@/hooks/useInterceptingRoutes';
import { useChatStore } from '@/store/chat';
import { chatSelectors } from '@/store/chat/selectors';
import { useGlobalStore } from '@/store/global';
Expand All @@ -13,12 +14,18 @@ const HotKeys = () => {
const lastMessage = useChatStore(chatSelectors.latestMessage, isEqual);

const toggleZenMode = useGlobalStore((s) => s.toggleZenMode);
const openChatSettings = useOpenChatSettings();

useHotkeys(HOTKEYS.zenMode, toggleZenMode, {
enableOnFormTags: true,
preventDefault: true,
});

useHotkeys(HOTKEYS.chatSettings, () => openChatSettings(), {
enableOnFormTags: true,
preventDefault: true,
});

useHotkeys(
HOTKEYS.regenerate,
() => {
Expand Down
1 change: 1 addition & 0 deletions src/const/hotkeys.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ export const SAVE_TOPIC_KEY = 'n';
export const CLEAN_MESSAGE_KEY = 'backspace';

export const HOTKEYS = {
chatSettings: 'mod+comma',
regenerate: 'alt+r',
saveTopic: 'alt+n',
zenMode: 'mod+\\',
Expand Down

0 comments on commit fbc9fad

Please sign in to comment.