Skip to content

Commit

Permalink
feat: ChatGPTNextWeb#5422 快捷键清除上下文
Browse files Browse the repository at this point in the history
  • Loading branch information
DDMeaqua committed Sep 19, 2024
1 parent b5ba05d commit 4c63ee2
Show file tree
Hide file tree
Showing 4 changed files with 23 additions and 0 deletions.
20 changes: 20 additions & 0 deletions app/components/chat.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -874,6 +874,10 @@ export function ShortcutKeyModal(props: { onClose: () => void }) {
title: Locale.Chat.ShortcutKey.showShortcutKey,
keys: isMac ? ["⌘", "/"] : ["Ctrl", "/"],
},
{
title: Locale.Chat.ShortcutKey.clearContext,
keys: isMac ? ["⌘", "Shift", "Delete"] : ["Ctrl", "Shift", "Delete"],
},
];
return (
<div className="modal-mask">
Expand Down Expand Up @@ -1560,6 +1564,22 @@ function _Chat() {
event.preventDefault();
setShowShortcutKeyModal(true);
}
// 清除上下文 command + shift + delete
else if (
(event.metaKey || event.ctrlKey) &&
event.shiftKey &&
event.key.toLowerCase() === "delete"
) {
event.preventDefault();
chatStore.updateCurrentSession((session) => {
if (session.clearContextIndex === session.messages.length) {
session.clearContextIndex = undefined;
} else {
session.clearContextIndex = session.messages.length;
session.memoryPrompt = ""; // will clear memory
}
});
}
};

window.addEventListener("keydown", handleKeyDown);
Expand Down
1 change: 1 addition & 0 deletions app/locales/cn.ts
Original file line number Diff line number Diff line change
Expand Up @@ -95,6 +95,7 @@ const cn = {
copyLastMessage: "复制最后一个回复",
copyLastCode: "复制最后一个代码块",
showShortcutKey: "显示快捷方式",
clearContext: "清除上下文",
},
},
Export: {
Expand Down
1 change: 1 addition & 0 deletions app/locales/en.ts
Original file line number Diff line number Diff line change
Expand Up @@ -97,6 +97,7 @@ const en: LocaleType = {
copyLastMessage: "Copy Last Reply",
copyLastCode: "Copy Last Code Block",
showShortcutKey: "Show Shortcuts",
clearContext: "Clear Context",
},
},
Export: {
Expand Down
1 change: 1 addition & 0 deletions app/locales/tw.ts
Original file line number Diff line number Diff line change
Expand Up @@ -90,6 +90,7 @@ const tw = {
copyLastMessage: "複製最後一個回覆",
copyLastCode: "複製最後一個代碼塊",
showShortcutKey: "顯示快捷方式",
clearContext: "清除上下文",
},
},
Export: {
Expand Down

0 comments on commit 4c63ee2

Please sign in to comment.