mirror of
https://gitee.com/wanwujie/deer-flow
synced 2026-04-29 00:34:47 +08:00
fix(hotkey):support to open settings with hotkey (#1259)
This commit is contained in:
@@ -26,12 +26,14 @@ import {
|
|||||||
} from "@/components/ui/dialog";
|
} from "@/components/ui/dialog";
|
||||||
import { useI18n } from "@/core/i18n/hooks";
|
import { useI18n } from "@/core/i18n/hooks";
|
||||||
import { useGlobalShortcuts } from "@/hooks/use-global-shortcuts";
|
import { useGlobalShortcuts } from "@/hooks/use-global-shortcuts";
|
||||||
|
import { SettingsDialog } from "./settings";
|
||||||
|
|
||||||
export function CommandPalette() {
|
export function CommandPalette() {
|
||||||
const { t } = useI18n();
|
const { t } = useI18n();
|
||||||
const router = useRouter();
|
const router = useRouter();
|
||||||
const [open, setOpen] = useState(false);
|
const [open, setOpen] = useState(false);
|
||||||
const [shortcutsOpen, setShortcutsOpen] = useState(false);
|
const [shortcutsOpen, setShortcutsOpen] = useState(false);
|
||||||
|
const [settingsOpen, setSettingsOpen] = useState(false);
|
||||||
|
|
||||||
const handleNewChat = useCallback(() => {
|
const handleNewChat = useCallback(() => {
|
||||||
router.push("/workspace/chats/new");
|
router.push("/workspace/chats/new");
|
||||||
@@ -39,9 +41,9 @@ export function CommandPalette() {
|
|||||||
}, [router]);
|
}, [router]);
|
||||||
|
|
||||||
const handleOpenSettings = useCallback(() => {
|
const handleOpenSettings = useCallback(() => {
|
||||||
router.push("/workspace/settings");
|
|
||||||
setOpen(false);
|
setOpen(false);
|
||||||
}, [router]);
|
setSettingsOpen(true);
|
||||||
|
}, []);
|
||||||
|
|
||||||
const handleShowShortcuts = useCallback(() => {
|
const handleShowShortcuts = useCallback(() => {
|
||||||
setOpen(false);
|
setOpen(false);
|
||||||
@@ -60,6 +62,7 @@ export function CommandPalette() {
|
|||||||
|
|
||||||
useGlobalShortcuts(shortcuts);
|
useGlobalShortcuts(shortcuts);
|
||||||
|
|
||||||
|
|
||||||
const isMac =
|
const isMac =
|
||||||
typeof navigator !== "undefined" && navigator.userAgent.includes("Mac");
|
typeof navigator !== "undefined" && navigator.userAgent.includes("Mac");
|
||||||
const metaKey = isMac ? "⌘" : "Ctrl+";
|
const metaKey = isMac ? "⌘" : "Ctrl+";
|
||||||
@@ -67,6 +70,7 @@ export function CommandPalette() {
|
|||||||
|
|
||||||
return (
|
return (
|
||||||
<>
|
<>
|
||||||
|
<SettingsDialog open={settingsOpen} onOpenChange={setSettingsOpen} />
|
||||||
<CommandDialog open={open} onOpenChange={setOpen}>
|
<CommandDialog open={open} onOpenChange={setOpen}>
|
||||||
<CommandInput placeholder={t.shortcuts.searchActions} />
|
<CommandInput placeholder={t.shortcuts.searchActions} />
|
||||||
<CommandList>
|
<CommandList>
|
||||||
|
|||||||
Reference in New Issue
Block a user