diff --git a/README.md b/README.md index 1346585b8..55a6da404 100644 --- a/README.md +++ b/README.md @@ -7,7 +7,7 @@ One-Click to deploy well-designed ChatGPT web UI on Vercel. 一键免费部署你的私人 ChatGPT 网页应用。 -[演示 Demo](https://chat-gpt-next-web.vercel.app/) / [反馈 Issues](https://github.com/Yidadaa/ChatGPT-Next-Web/issues) / [Join Discord](https://discord.gg/zrhvHCr79N) / [QQ 群](https://user-images.githubusercontent.com/16968934/228190818-7dd00845-e9b9-4363-97e5-44c507ac76da.jpeg) / [打赏开发者](https://user-images.githubusercontent.com/16968934/227772541-5bcd52d8-61b7-488c-a203-0330d8006e2b.jpg) +[演示 Demo](https://chat-gpt-next-web.vercel.app/) / [反馈 Issues](https://github.com/Yidadaa/ChatGPT-Next-Web/issues) / [Join Discord](https://discord.gg/zrhvHCr79N) / [QQ 群](https://user-images.githubusercontent.com/16968934/228190818-7dd00845-e9b9-4363-97e5-44c507ac76da.jpeg) / [打赏开发者](https://user-images.githubusercontent.com/16968934/227772541-5bcd52d8-61b7-488c-a203-0330d8006e2b.jpg) / [Buy Me a Coffee](https://www.buymeacoffee.com/yidadaa) [![Deploy with Vercel](https://vercel.com/button)](https://vercel.com/new/clone?repository-url=https%3A%2F%2Fgithub.com%2FYidadaa%2FChatGPT-Next-Web&env=OPENAI_API_KEY&env=CODE&project-name=chatgpt-next-web&repository-name=ChatGPT-Next-Web) @@ -169,6 +169,8 @@ bash <(curl -s https://raw.githubusercontent.com/Yidadaa/ChatGPT-Next-Web/main/s ![More](./docs/images/more.png) +## Donation +[Buy Me a Coffee](https://www.buymeacoffee.com/yidadaa) ## Special Thanks ### Sponsor @@ -177,6 +179,11 @@ bash <(curl -s https://raw.githubusercontent.com/Yidadaa/ChatGPT-Next-Web/main/s [@ClarenceDan](https://github.com/ClarenceDan) [@zhangjia](https://github.com/zhangjia) [@hoochanlon](https://github.com/hoochanlon) +[@relativequantum](https://github.com/relativequantum) +[@desenmeng](https://github.com/desenmeng) +[@webees](https://github.com/webees) +[@chazzhou](https://github.com/chazzhou) +[@hauy](https://github.com/hauy) ### Contributor diff --git a/app/components/chat.tsx b/app/components/chat.tsx index 08f119625..de9854a16 100644 --- a/app/components/chat.tsx +++ b/app/components/chat.tsx @@ -344,6 +344,7 @@ export function Chat(props: {}) { const inputRef = useRef(null); const [userInput, setUserInput] = useState(""); + const [beforeInput, setBeforeInput] = useState(""); const [isLoading, setIsLoading] = useState(false); const { submitKey, shouldSubmit } = useSubmitHandler(); const { scrollRef, setAutoScroll } = useScrollToBottom(); @@ -408,6 +409,7 @@ export function Chat(props: {}) { if (userInput.length <= 0) return; setIsLoading(true); chatStore.onUserInput(userInput).then(() => setIsLoading(false)); + setBeforeInput(userInput); setUserInput(""); setPromptHints([]); if (!isMobileScreen()) inputRef.current?.focus(); @@ -421,6 +423,12 @@ export function Chat(props: {}) { // check if should send message const onInputKeyDown = (e: React.KeyboardEvent) => { + // if ArrowUp and no userInput + if (e.key === "ArrowUp" && userInput.length <= 0) { + setUserInput(beforeInput); + e.preventDefault(); + return; + } if (shouldSubmit(e)) { onUserSubmit(); e.preventDefault(); diff --git a/app/components/settings.tsx b/app/components/settings.tsx index ed1c28ee5..d1d217ead 100644 --- a/app/components/settings.tsx +++ b/app/components/settings.tsx @@ -128,6 +128,19 @@ export function Settings(props: { closeSettings: () => void }) { // eslint-disable-next-line react-hooks/exhaustive-deps }, []); + useEffect(() => { + const keydownEvent = (e: KeyboardEvent) => { + if (e.key === "Escape") { + props.closeSettings(); + } + }; + document.addEventListener("keydown", keydownEvent); + return () => { + document.removeEventListener("keydown", keydownEvent); + }; + // eslint-disable-next-line react-hooks/exhaustive-deps + }, []); + return (