fix setting style

This commit is contained in:
2023-03-16 14:04:08 +08:00
parent 648040659b
commit 71dbe86520
2 changed files with 17 additions and 10 deletions

View File

@@ -4,6 +4,7 @@ import "./global.css";
import { Message } from "./chatgpt"; import { Message } from "./chatgpt";
import getDefaultParams from "./getDefaultParam"; import getDefaultParams from "./getDefaultParam";
import ChatBOX from "./chatbox"; import ChatBOX from "./chatbox";
import Settings from "./settings";
export interface ChatStore { export interface ChatStore {
systemMessageContent: string; systemMessageContent: string;
@@ -69,8 +70,16 @@ export function App() {
localStorage.setItem(STORAGE_NAME, JSON.stringify(allChatStore)); localStorage.setItem(STORAGE_NAME, JSON.stringify(allChatStore));
}, [allChatStore]); }, [allChatStore]);
const [showSettings, setShowSettings] = useState(false);
return ( return (
<div className="flex text-sm h-screen bg-slate-200"> <div className="flex text-sm h-screen bg-slate-200">
<Settings
chatStore={chatStore}
setChatStore={setChatStore}
show={showSettings}
setShow={setShowSettings}
/>
<div className="flex flex-col h-full p-4 border-r-indigo-500 border-2"> <div className="flex flex-col h-full p-4 border-r-indigo-500 border-2">
<div className="grow overflow-scroll"> <div className="grow overflow-scroll">
<button <button
@@ -137,7 +146,11 @@ export function App() {
DEL DEL
</button> </button>
</div> </div>
<ChatBOX chatStore={chatStore} setChatStore={setChatStore} /> <ChatBOX
chatStore={chatStore}
setChatStore={setChatStore}
setShowSettings={setShowSettings}
/>
</div> </div>
); );
} }

View File

@@ -1,11 +1,11 @@
import { useState } from "preact/hooks"; import { StateUpdater, useState } from "preact/hooks";
import type { ChatStore } from "./app"; import type { ChatStore } from "./app";
import ChatGPT, { ChunkMessage } from "./chatgpt"; import ChatGPT, { ChunkMessage } from "./chatgpt";
import Settings from "./settings";
export default function ChatBOX(props: { export default function ChatBOX(props: {
chatStore: ChatStore; chatStore: ChatStore;
setChatStore: (cs: ChatStore) => void; setChatStore: (cs: ChatStore) => void;
setShowSettings: StateUpdater<boolean>;
}) { }) {
const { chatStore, setChatStore } = props; const { chatStore, setChatStore } = props;
const [inputMsg, setInputMsg] = useState(""); const [inputMsg, setInputMsg] = useState("");
@@ -127,15 +127,9 @@ export default function ChatBOX(props: {
setChatStore({ ...chatStore }); setChatStore({ ...chatStore });
}; };
const [showSettings, setShowSettings] = useState(false); const { setShowSettings } = props;
return ( return (
<div className="grow flex flex-col p-4"> <div className="grow flex flex-col p-4">
<Settings
chatStore={chatStore}
setChatStore={setChatStore}
show={showSettings}
setShow={setShowSettings}
/>
<p className="cursor-pointer" onClick={() => setShowSettings(true)}> <p className="cursor-pointer" onClick={() => setShowSettings(true)}>
<div> <div>
<button className="underline"> <button className="underline">