From 415fb934aea431ff1f52be33e7618de50f37557e Mon Sep 17 00:00:00 2001 From: ecwu Date: Wed, 17 Jul 2024 02:06:13 +0800 Subject: [PATCH] clean up setting panel --- src/chatbox.tsx | 4 +- src/message.tsx | 19 +- src/settings.tsx | 579 +++++++++++++++++++++++++++++------------------ 3 files changed, 366 insertions(+), 236 deletions(-) diff --git a/src/chatbox.tsx b/src/chatbox.tsx index 7a93b0c..af2afc9 100644 --- a/src/chatbox.tsx +++ b/src/chatbox.tsx @@ -798,7 +798,7 @@ export default function ChatBOX(props: {

{chatStore.history.length > 0 && ( { @@ -229,17 +230,17 @@ export default function Message(props: Props) { setChatStore({ ...chatStore }); }} > - + setRenderWorkdown(!renderMarkdown)} > - + setRenderColor(!renderColor)}> - + diff --git a/src/settings.tsx b/src/settings.tsx index 7a836f0..f8fdcf7 100644 --- a/src/settings.tsx +++ b/src/settings.tsx @@ -20,6 +20,14 @@ import { InformationCircleIcon, CheckIcon, NoSymbolIcon, + CogIcon, + KeyIcon, + EyeIcon, + EllipsisHorizontalCircleIcon, + HandRaisedIcon, + AdjustmentsHorizontalIcon, + Cog6ToothIcon, + ListBulletIcon, } from "@heroicons/react/24/outline"; import { themeChange } from "theme-change"; @@ -34,10 +42,10 @@ const TTS_VOICES: string[] = [ ]; const TTS_FORMAT: string[] = ["mp3", "opus", "aac", "flac"]; -const Help = (props: { children: any; help: string }) => { +const Help = (props: { children: any; help: string; field: string }) => { return ( -

-

{props.children}

+
+
); }; @@ -55,46 +63,64 @@ const SelectModel = (props: { } const [useCustomModel, setUseCustomModel] = useState(shouldIUseCustomModel); return ( - - - { - setUseCustomModel(!useCustomModel); - }} - className="m-2 p-2" - > - - - - {useCustomModel ? ( - { - const model = event.target.value as string; - props.chatStore.model = model; - props.setChatStore({ ...props.chatStore }); - }} - /> - ) : ( - - )} + +
+ + + Model + {" "} +
+ + + + {Tr("Custom")} + + + + { + setUseCustomModel(!useCustomModel); + }} + /> + +
+ {/* Top Right label */} +
+ +
); }; @@ -152,25 +178,50 @@ const Input = (props: { }) => { const [hideInput, setHideInput] = useState(true); return ( - - - - { - props.chatStore[props.field] = event.target.value; - props.setChatStore({ ...props.chatStore }); - }} - > + +
+ {props.field} + + + +
+
+ +
); }; @@ -202,42 +253,63 @@ const Slicer = (props: { props.setChatStore({ ...props.chatStore }); }; return ( - + - - { - setEnabled(!enabled); - }} - /> +
+ +
- { - const value = parseFloat(event.target.value); - props.chatStore[props.field] = value; - props.setChatStore({ ...props.chatStore }); - }} - /> - { - const value = parseFloat(event.target.value); - props.chatStore[props.field] = value; - props.setChatStore({ ...props.chatStore }); - }} - /> + {enabled ? ( +
+ { + const value = parseFloat(event.target.value); + props.chatStore[props.field] = value; + props.setChatStore({ ...props.chatStore }); + }} + /> + { + const value = parseFloat(event.target.value); + props.chatStore[props.field] = value; + props.setChatStore({ ...props.chatStore }); + }} + /> +
+ ) : ( + "" + )}
); }; @@ -257,21 +329,35 @@ const Number = (props: { help: string; }) => { return ( - + - - {props.field === "maxGenTokens" && ( - { - const newChatStore = { ...props.chatStore }; - newChatStore.maxGenTokens_enabled = - !newChatStore.maxGenTokens_enabled; - props.setChatStore({ ...newChatStore }); + { console.log("type", typeof event.target.value); @@ -300,17 +386,29 @@ const Choice = (props: { help: string; }) => { return ( - - - { - props.chatStore[props.field] = event.target.checked; - props.setChatStore({ ...props.chatStore }); - }} - > + +
+ +
); }; @@ -394,9 +492,7 @@ export default (props: { {Tr("Close")}
- -
-
+
-

- {Tr("Accumulated cost in all sessions")} ${totalCost.toFixed(4)} -

- +
+

+ {Tr("Accumulated cost in all sessions")} $ + {totalCost.toFixed(4)} +

+ +