mirror of
https://github.com/ChatGPTNextWeb/ChatGPT-Next-Web.git
synced 2025-05-20 20:50:17 +09:00
feat: #5422 快捷键清除上下文
This commit is contained in:
parent
b5ba05dd83
commit
4c63ee23cd
@ -874,6 +874,10 @@ export function ShortcutKeyModal(props: { onClose: () => void }) {
|
|||||||
title: Locale.Chat.ShortcutKey.showShortcutKey,
|
title: Locale.Chat.ShortcutKey.showShortcutKey,
|
||||||
keys: isMac ? ["⌘", "/"] : ["Ctrl", "/"],
|
keys: isMac ? ["⌘", "/"] : ["Ctrl", "/"],
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
title: Locale.Chat.ShortcutKey.clearContext,
|
||||||
|
keys: isMac ? ["⌘", "Shift", "Delete"] : ["Ctrl", "Shift", "Delete"],
|
||||||
|
},
|
||||||
];
|
];
|
||||||
return (
|
return (
|
||||||
<div className="modal-mask">
|
<div className="modal-mask">
|
||||||
@ -1560,6 +1564,22 @@ function _Chat() {
|
|||||||
event.preventDefault();
|
event.preventDefault();
|
||||||
setShowShortcutKeyModal(true);
|
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);
|
window.addEventListener("keydown", handleKeyDown);
|
||||||
|
@ -95,6 +95,7 @@ const cn = {
|
|||||||
copyLastMessage: "复制最后一个回复",
|
copyLastMessage: "复制最后一个回复",
|
||||||
copyLastCode: "复制最后一个代码块",
|
copyLastCode: "复制最后一个代码块",
|
||||||
showShortcutKey: "显示快捷方式",
|
showShortcutKey: "显示快捷方式",
|
||||||
|
clearContext: "清除上下文",
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
Export: {
|
Export: {
|
||||||
|
@ -97,6 +97,7 @@ const en: LocaleType = {
|
|||||||
copyLastMessage: "Copy Last Reply",
|
copyLastMessage: "Copy Last Reply",
|
||||||
copyLastCode: "Copy Last Code Block",
|
copyLastCode: "Copy Last Code Block",
|
||||||
showShortcutKey: "Show Shortcuts",
|
showShortcutKey: "Show Shortcuts",
|
||||||
|
clearContext: "Clear Context",
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
Export: {
|
Export: {
|
||||||
|
@ -90,6 +90,7 @@ const tw = {
|
|||||||
copyLastMessage: "複製最後一個回覆",
|
copyLastMessage: "複製最後一個回覆",
|
||||||
copyLastCode: "複製最後一個代碼塊",
|
copyLastCode: "複製最後一個代碼塊",
|
||||||
showShortcutKey: "顯示快捷方式",
|
showShortcutKey: "顯示快捷方式",
|
||||||
|
clearContext: "清除上下文",
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
Export: {
|
Export: {
|
||||||
|
Loading…
Reference in New Issue
Block a user