Merge branch 'Yidadaa:main' into main

This commit is contained in:
Gan-Xing 2023-05-12 08:26:45 +08:00 committed by GitHub
commit dbd92b2db9
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 24 additions and 6 deletions

View File

@ -230,7 +230,9 @@ export function PromptHints(props: {
useEffect(() => { useEffect(() => {
const onKeyDown = (e: KeyboardEvent) => { const onKeyDown = (e: KeyboardEvent) => {
if (noPrompts) return; if (noPrompts) return;
if (e.metaKey || e.altKey || e.ctrlKey) {
return;
}
// arrow up / down to select prompt // arrow up / down to select prompt
const changeIndex = (delta: number) => { const changeIndex = (delta: number) => {
e.stopPropagation(); e.stopPropagation();
@ -491,7 +493,11 @@ export function Chat() {
// check if should send message // check if should send message
const onInputKeyDown = (e: React.KeyboardEvent<HTMLTextAreaElement>) => { const onInputKeyDown = (e: React.KeyboardEvent<HTMLTextAreaElement>) => {
// if ArrowUp and no userInput, fill with last input // if ArrowUp and no userInput, fill with last input
if (e.key === "ArrowUp" && userInput.length <= 0) { if (
e.key === "ArrowUp" &&
userInput.length <= 0 &&
!(e.metaKey || e.altKey || e.ctrlKey)
) {
setUserInput(localStorage.getItem(LAST_INPUT_KEY) ?? ""); setUserInput(localStorage.getItem(LAST_INPUT_KEY) ?? "");
e.preventDefault(); e.preventDefault();
return; return;
@ -789,7 +795,14 @@ export function Chat() {
scrollToBottom={scrollToBottom} scrollToBottom={scrollToBottom}
hitBottom={hitBottom} hitBottom={hitBottom}
showPromptHints={() => { showPromptHints={() => {
// Click again to close
if (promptHints.length > 0) {
setPromptHints([]);
return;
}
inputRef.current?.focus(); inputRef.current?.focus();
setUserInput("/");
onSearch(""); onSearch("");
}} }}
/> />

View File

@ -13,7 +13,7 @@ export const metadata = {
title: "ChatGPT Next Web", title: "ChatGPT Next Web",
statusBarStyle: "default", statusBarStyle: "default",
}, },
themeColor: "#fafafa", viewport: "width=device-width, initial-scale=1, maximum-scale=1",
}; };
export default function RootLayout({ export default function RootLayout({
@ -25,8 +25,9 @@ export default function RootLayout({
<html lang="en"> <html lang="en">
<head> <head>
<meta <meta
name="viewport" name="theme-color"
content="width=device-width, user-scalable=no, initial-scale=1.0, maximum-scale=1.0, minimum-scale=1.0" content="#fafafa"
media="(prefers-color-scheme: light)"
/> />
<meta <meta
name="theme-color" name="theme-color"

View File

@ -43,7 +43,7 @@ const makeRequestParam = (
}; };
}; };
function getHeaders() { export function getHeaders() {
const accessStore = useAccessStore.getState(); const accessStore = useAccessStore.getState();
let headers: Record<string, string> = {}; let headers: Record<string, string> = {};

View File

@ -1,6 +1,7 @@
import { create } from "zustand"; import { create } from "zustand";
import { persist } from "zustand/middleware"; import { persist } from "zustand/middleware";
import { StoreKey } from "../constant"; import { StoreKey } from "../constant";
import { getHeaders } from "../requests";
import { BOT_HELLO } from "./chat"; import { BOT_HELLO } from "./chat";
import { ALL_MODELS } from "./config"; import { ALL_MODELS } from "./config";
@ -55,6 +56,9 @@ export const useAccessStore = create<AccessControlStore>()(
fetch("/api/config", { fetch("/api/config", {
method: "post", method: "post",
body: null, body: null,
headers: {
...getHeaders(),
},
}) })
.then((res) => res.json()) .then((res) => res.json())
.then((res: DangerConfig) => { .then((res: DangerConfig) => {