Skip to content

Commit

Permalink
chore: update
Browse files Browse the repository at this point in the history
  • Loading branch information
DDMeaqua committed Dec 31, 2024
1 parent 5b5dea1 commit 6d84f9d
Showing 1 changed file with 8 additions and 6 deletions.
14 changes: 8 additions & 6 deletions app/components/chat.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -876,7 +876,9 @@ export function ShortcutKeyModal(props: { onClose: () => void }) {
},
{
title: Locale.Chat.ShortcutKey.clearContext,
keys: isMac ? ["⌘", "Shift", "k"] : ["Ctrl", "Shift", "k"],
keys: isMac
? ["⌘", "Shift", "Backspace"]
: ["Ctrl", "Shift", "Backspace"],
},
];
return (
Expand Down Expand Up @@ -1513,7 +1515,7 @@ function _Chat() {
const [showShortcutKeyModal, setShowShortcutKeyModal] = useState(false);

useEffect(() => {
const handleKeyDown = (event: any) => {
const handleKeyDown = (event: KeyboardEvent) => {
// 打开新聊天 command + shift + o
if (
(event.metaKey || event.ctrlKey) &&
Expand Down Expand Up @@ -1564,11 +1566,11 @@ function _Chat() {
event.preventDefault();
setShowShortcutKeyModal(true);
}
// 清除上下文 command + shift + delete
// 清除上下文 command + shift + Backspace
else if (
(event.metaKey || event.ctrlKey) &&
event.shiftKey &&
event.key.toLowerCase() === "k"
event.key.toLowerCase() === "backspace"
) {
event.preventDefault();
chatStore.updateCurrentSession((session) => {
Expand All @@ -1582,10 +1584,10 @@ function _Chat() {
}
};

window.addEventListener("keydown", handleKeyDown);
document.addEventListener("keydown", handleKeyDown);

return () => {
window.removeEventListener("keydown", handleKeyDown);
document.removeEventListener("keydown", handleKeyDown);
};
}, [messages, chatStore, navigate]);

Expand Down

0 comments on commit 6d84f9d

Please sign in to comment.