mirror of
https://github.com/Yidadaa/ChatGPT-Next-Web.git
synced 2025-08-11 18:52:55 +08:00
Merge branch 'main' into feat-mcp
This commit is contained in:
@@ -70,9 +70,8 @@ import {
|
||||
isDalle3,
|
||||
isVisionModel,
|
||||
safeLocalStorage,
|
||||
selectOrCopy,
|
||||
showPlugins,
|
||||
useMobileScreen,
|
||||
getModelSizes,
|
||||
supportsCustomSize,
|
||||
} from "../utils";
|
||||
|
||||
import { uploadImage as uploadImageRemote } from "@/app/utils/chat";
|
||||
@@ -80,7 +79,7 @@ import { uploadImage as uploadImageRemote } from "@/app/utils/chat";
|
||||
import dynamic from "next/dynamic";
|
||||
|
||||
import { ChatControllerPool } from "../client/controller";
|
||||
import { DalleQuality, DalleSize, DalleStyle } from "../typing";
|
||||
import { DalleQuality, DalleStyle, ModelSize } from "../typing";
|
||||
import { Prompt, usePromptStore } from "../store/prompt";
|
||||
import Locale from "../locales";
|
||||
|
||||
@@ -557,10 +556,11 @@ export function ChatActions(props: {
|
||||
const [showSizeSelector, setShowSizeSelector] = useState(false);
|
||||
const [showQualitySelector, setShowQualitySelector] = useState(false);
|
||||
const [showStyleSelector, setShowStyleSelector] = useState(false);
|
||||
const dalle3Sizes: DalleSize[] = ["1024x1024", "1792x1024", "1024x1792"];
|
||||
const modelSizes = getModelSizes(currentModel);
|
||||
const dalle3Qualitys: DalleQuality[] = ["standard", "hd"];
|
||||
const dalle3Styles: DalleStyle[] = ["vivid", "natural"];
|
||||
const currentSize = session.mask.modelConfig?.size ?? "1024x1024";
|
||||
const currentSize =
|
||||
session.mask.modelConfig?.size ?? ("1024x1024" as ModelSize);
|
||||
const currentQuality = session.mask.modelConfig?.quality ?? "standard";
|
||||
const currentStyle = session.mask.modelConfig?.style ?? "vivid";
|
||||
|
||||
@@ -711,7 +711,7 @@ export function ChatActions(props: {
|
||||
/>
|
||||
)}
|
||||
|
||||
{isDalle3(currentModel) && (
|
||||
{supportsCustomSize(currentModel) && (
|
||||
<ChatAction
|
||||
onClick={() => setShowSizeSelector(true)}
|
||||
text={currentSize}
|
||||
@@ -722,7 +722,7 @@ export function ChatActions(props: {
|
||||
{showSizeSelector && (
|
||||
<Selector
|
||||
defaultSelectedValue={currentSize}
|
||||
items={dalle3Sizes.map((m) => ({
|
||||
items={modelSizes.map((m) => ({
|
||||
title: m,
|
||||
value: m,
|
||||
}))}
|
||||
@@ -936,6 +936,12 @@ export function ShortcutKeyModal(props: { onClose: () => void }) {
|
||||
title: Locale.Chat.ShortcutKey.showShortcutKey,
|
||||
keys: isMac ? ["⌘", "/"] : ["Ctrl", "/"],
|
||||
},
|
||||
{
|
||||
title: Locale.Chat.ShortcutKey.clearContext,
|
||||
keys: isMac
|
||||
? ["⌘", "Shift", "backspace"]
|
||||
: ["Ctrl", "Shift", "backspace"],
|
||||
},
|
||||
];
|
||||
return (
|
||||
<div className="modal-mask">
|
||||
@@ -1592,7 +1598,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) &&
|
||||
@@ -1643,14 +1649,30 @@ function _Chat() {
|
||||
event.preventDefault();
|
||||
setShowShortcutKeyModal(true);
|
||||
}
|
||||
// 清除上下文 command + shift + backspace
|
||||
else if (
|
||||
(event.metaKey || event.ctrlKey) &&
|
||||
event.shiftKey &&
|
||||
event.key.toLowerCase() === "backspace"
|
||||
) {
|
||||
event.preventDefault();
|
||||
chatStore.updateTargetSession(session, (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);
|
||||
document.addEventListener("keydown", handleKeyDown);
|
||||
|
||||
return () => {
|
||||
window.removeEventListener("keydown", handleKeyDown);
|
||||
document.removeEventListener("keydown", handleKeyDown);
|
||||
};
|
||||
}, [messages, chatStore, navigate]);
|
||||
}, [messages, chatStore, navigate, session]);
|
||||
|
||||
const [showChatSidePanel, setShowChatSidePanel] = useState(false);
|
||||
|
||||
|
Reference in New Issue
Block a user