From 5effd0a3f4267637472bdd45e8d45c8e04c6aba1 Mon Sep 17 00:00:00 2001 From: ecwu Date: Mon, 6 Jan 2025 12:37:29 +0800 Subject: [PATCH] refactor: remove unused buttons and enhance API and Tools display in Settings component --- src/components/ListAPI.tsx | 31 ------ src/components/Settings.tsx | 217 ++++++++++++++++++++++++++++++++++-- src/pages/Chatbox.tsx | 2 - 3 files changed, 210 insertions(+), 40 deletions(-) diff --git a/src/components/ListAPI.tsx b/src/components/ListAPI.tsx index 56398ae..81f29e0 100644 --- a/src/components/ListAPI.tsx +++ b/src/components/ListAPI.tsx @@ -107,37 +107,6 @@ function APIsDropdownList({

-
- - -
))} diff --git a/src/components/Settings.tsx b/src/components/Settings.tsx index cd9b34f..2e74fba 100644 --- a/src/components/Settings.tsx +++ b/src/components/Settings.tsx @@ -3,12 +3,7 @@ import { themeChange } from "theme-change"; import { useRef } from "react"; import { useContext, useEffect, useState, Dispatch } from "react"; import { clearTotalCost, getTotalCost } from "@/utils/totalCost"; -import { - ChatStore, - TemplateChatStore, - TemplateAPI, - TemplateTools, -} from "@/types/chatstore"; +import { ChatStore, TemplateChatStore, TemplateTools } from "@/types/chatstore"; import { models } from "@/types/models"; import { tr, Tr, langCodeContext, LANG_OPTIONS } from "@/translate"; import { isVailedJSON } from "@/utils/isVailedJSON"; @@ -62,13 +57,13 @@ import { DialogTrigger, } from "@/components/ui/dialog"; import { Checkbox } from "@/components/ui/checkbox"; +import { Badge } from "@/components/ui/badge"; import { Textarea } from "@/components/ui/textarea"; import { BanIcon, CheckIcon, CircleEllipsisIcon, CogIcon, - Ellipsis, EyeIcon, InfoIcon, KeyIcon, @@ -478,6 +473,151 @@ const Choice = (props: { ); }; +const APIShowBlock = (props: { + ctx: any; + index: number; + label: string; + type: string; + apiField: string; + keyField: string; +}) => { + return ( +
+ {props.type} +
+
+ {props.apiField} +
+
+ + {props.keyField ? ( + props.keyField + ) : ( + empty + )} +
+
+ + +
+ ); +}; + +const ToolsShowBlock = (props: { + ctx: any; + index: number; + label: string; + content: string; +}) => { + return ( +
+ Tool +
+
+ + +
+              {JSON.stringify(JSON.parse(props.content), null, 2)}
+            
+
+
+
+ + +
+ ); +}; + export default (props: {}) => { const ctx = useContext(AppContext); if (ctx === null) return <>; @@ -1174,6 +1314,69 @@ export default (props: {}) => { + + Saved Template + + {ctx.templateAPIs.map((template, index) => ( +
+ +
+ ))} + {ctx.templateAPIsWhisper.map((template, index) => ( +
+ +
+ ))} + {ctx.templateAPIsTTS.map((template, index) => ( +
+ +
+ ))} + {ctx.templateAPIsImageGen.map((template, index) => ( +
+ +
+ ))} + {ctx.templateTools.map((template, index) => ( +
+ +
+ ))} +
+

diff --git a/src/pages/Chatbox.tsx b/src/pages/Chatbox.tsx index 1891531..3315057 100644 --- a/src/pages/Chatbox.tsx +++ b/src/pages/Chatbox.tsx @@ -33,9 +33,7 @@ import { CornerDownLeftIcon, CornerLeftUpIcon, CornerRightUpIcon, - ImageIcon, InfoIcon, - PaintBucketIcon, ScissorsIcon, } from "lucide-react"; import { Switch } from "@/components/ui/switch";