From 4b36debd0b7a41ac43d9e6b2cd631538c8126f99 Mon Sep 17 00:00:00 2001 From: heimoshuiyu Date: Fri, 27 Dec 2024 14:25:12 +0800 Subject: [PATCH] format code --- src/chatgpt.ts | 8 +- src/components/Templates.tsx | 14 +- src/components/ui/accordion.tsx | 24 +- src/components/ui/alert-dialog.tsx | 48 +-- src/components/ui/alert.tsx | 22 +- src/components/ui/aspect-ratio.tsx | 6 +- src/components/ui/avatar.tsx | 22 +- src/components/ui/badge.tsx | 12 +- src/components/ui/breadcrumb.tsx | 46 +-- src/components/ui/button.tsx | 22 +- src/components/ui/calendar.tsx | 18 +- src/components/ui/card.tsx | 37 +- src/components/ui/carousel.tsx | 142 +++---- src/components/ui/chart.tsx | 142 +++---- src/components/ui/chat/chat-bubble.tsx | 405 +++++++++---------- src/components/ui/chat/chat-input.tsx | 47 +-- src/components/ui/chat/chat-message-list.tsx | 46 +-- src/components/ui/chat/expandable-chat.tsx | 306 +++++++------- src/components/ui/chat/message-loading.tsx | 90 ++--- src/components/ui/checkbox.tsx | 14 +- src/components/ui/collapsible.tsx | 12 +- src/components/ui/command.tsx | 52 +-- src/components/ui/context-menu.tsx | 66 +-- src/components/ui/dialog.tsx | 44 +- src/components/ui/drawer.tsx | 44 +- src/components/ui/dropdown-menu.tsx | 66 +-- src/components/ui/form.tsx | 99 ++--- src/components/ui/hover-card.tsx | 18 +- src/components/ui/input-otp.tsx | 32 +- src/components/ui/input.tsx | 12 +- src/components/ui/label.tsx | 16 +- src/components/ui/menubar.tsx | 74 ++-- src/components/ui/navigation-menu.tsx | 42 +- src/components/ui/popover.tsx | 18 +- src/components/ui/progress.tsx | 14 +- src/components/ui/radio-group.tsx | 22 +- src/components/ui/resizable.tsx | 18 +- src/components/ui/scroll-area.tsx | 16 +- src/components/ui/select.tsx | 46 +-- src/components/ui/separator.tsx | 12 +- src/components/ui/sheet.tsx | 48 +-- src/components/ui/sidebar.tsx | 294 +++++++------- src/components/ui/skeleton.tsx | 6 +- src/components/ui/slider.tsx | 12 +- src/components/ui/sonner.tsx | 16 +- src/components/ui/switch.tsx | 12 +- src/components/ui/table.tsx | 38 +- src/components/ui/tabs.tsx | 22 +- src/components/ui/textarea.tsx | 12 +- src/components/ui/toast.tsx | 46 +-- src/components/ui/toaster.tsx | 10 +- src/components/ui/toggle-group.tsx | 26 +- src/components/ui/toggle.tsx | 18 +- src/components/ui/tooltip.tsx | 20 +- src/global.css | 4 +- src/hooks/use-mobile.tsx | 24 +- src/hooks/use-toast.ts | 127 +++--- src/indexedDB/upgrade.ts | 2 +- src/indexedDB/v1.ts | 6 +- src/indexedDB/v11.ts | 2 +- src/lib/utils.ts | 6 +- src/messageDetail.tsx | 2 +- src/search.tsx | 4 +- src/textarea.tsx | 2 +- src/types/newChatstore.ts | 10 +- src/utils/totalCost.ts | 2 +- 66 files changed, 1485 insertions(+), 1480 deletions(-) diff --git a/src/chatgpt.ts b/src/chatgpt.ts index 217906b..e7409cf 100644 --- a/src/chatgpt.ts +++ b/src/chatgpt.ts @@ -117,7 +117,7 @@ function calculate_token_length_from_text(text: string): number { } // https://help.openai.com/en/articles/4936856-what-are-tokens-and-how-to-count-them export function calculate_token_length( - content: string | MessageDetail[], + content: string | MessageDetail[] ): number { if (typeof content === "string") { return calculate_token_length_from_text(content); @@ -172,7 +172,7 @@ class Chat { presence_penalty = 0, frequency_penalty = 0, json_mode = false, - } = {}, + } = {} ) { this.OPENAI_API_KEY = OPENAI_API_KEY ?? ""; this.messages = []; @@ -207,14 +207,14 @@ class Chat { } if (msg.role === "system") { console.log( - "Warning: detected system message in the middle of history", + "Warning: detected system message in the middle of history" ); } } for (const msg of this.messages) { if (msg.name && msg.role !== "system") { console.log( - "Warning: detected message where name field set but role is system", + "Warning: detected message where name field set but role is system" ); } } diff --git a/src/components/Templates.tsx b/src/components/Templates.tsx index 0cad74a..a215fe8 100644 --- a/src/components/Templates.tsx +++ b/src/components/Templates.tsx @@ -21,7 +21,7 @@ const Templates = (props: { if (!newChatStore.apiEndpoint) { newChatStore.apiEndpoint = getDefaultParams( "api", - chatStore.apiEndpoint, + chatStore.apiEndpoint ); } if (!newChatStore.apiKey) { @@ -30,37 +30,37 @@ const Templates = (props: { if (!newChatStore.whisper_api) { newChatStore.whisper_api = getDefaultParams( "whisper-api", - chatStore.whisper_api, + chatStore.whisper_api ); } if (!newChatStore.whisper_key) { newChatStore.whisper_key = getDefaultParams( "whisper-key", - chatStore.whisper_key, + chatStore.whisper_key ); } if (!newChatStore.tts_api) { newChatStore.tts_api = getDefaultParams( "tts-api", - chatStore.tts_api, + chatStore.tts_api ); } if (!newChatStore.tts_key) { newChatStore.tts_key = getDefaultParams( "tts-key", - chatStore.tts_key, + chatStore.tts_key ); } if (!newChatStore.image_gen_api) { newChatStore.image_gen_api = getDefaultParams( "image-gen-api", - chatStore.image_gen_api, + chatStore.image_gen_api ); } if (!newChatStore.image_gen_key) { newChatStore.image_gen_key = getDefaultParams( "image-gen-key", - chatStore.image_gen_key, + chatStore.image_gen_key ); } newChatStore.cost = 0; diff --git a/src/components/ui/accordion.tsx b/src/components/ui/accordion.tsx index e1797c9..26c5ac9 100644 --- a/src/components/ui/accordion.tsx +++ b/src/components/ui/accordion.tsx @@ -1,10 +1,10 @@ -import * as React from "react" -import * as AccordionPrimitive from "@radix-ui/react-accordion" -import { ChevronDown } from "lucide-react" +import * as React from "react"; +import * as AccordionPrimitive from "@radix-ui/react-accordion"; +import { ChevronDown } from "lucide-react"; -import { cn } from "@/lib/utils" +import { cn } from "@/lib/utils"; -const Accordion = AccordionPrimitive.Root +const Accordion = AccordionPrimitive.Root; const AccordionItem = React.forwardRef< React.ElementRef, @@ -15,8 +15,8 @@ const AccordionItem = React.forwardRef< className={cn("border-b", className)} {...props} /> -)) -AccordionItem.displayName = "AccordionItem" +)); +AccordionItem.displayName = "AccordionItem"; const AccordionTrigger = React.forwardRef< React.ElementRef, @@ -35,8 +35,8 @@ const AccordionTrigger = React.forwardRef< -)) -AccordionTrigger.displayName = AccordionPrimitive.Trigger.displayName +)); +AccordionTrigger.displayName = AccordionPrimitive.Trigger.displayName; const AccordionContent = React.forwardRef< React.ElementRef, @@ -49,7 +49,7 @@ const AccordionContent = React.forwardRef< >
{children}
-)) -AccordionContent.displayName = AccordionPrimitive.Content.displayName +)); +AccordionContent.displayName = AccordionPrimitive.Content.displayName; -export { Accordion, AccordionItem, AccordionTrigger, AccordionContent } +export { Accordion, AccordionItem, AccordionTrigger, AccordionContent }; diff --git a/src/components/ui/alert-dialog.tsx b/src/components/ui/alert-dialog.tsx index fa2b442..02e0005 100644 --- a/src/components/ui/alert-dialog.tsx +++ b/src/components/ui/alert-dialog.tsx @@ -1,14 +1,14 @@ -import * as React from "react" -import * as AlertDialogPrimitive from "@radix-ui/react-alert-dialog" +import * as React from "react"; +import * as AlertDialogPrimitive from "@radix-ui/react-alert-dialog"; -import { cn } from "@/lib/utils" -import { buttonVariants } from "@/components/ui/button" +import { cn } from "@/lib/utils"; +import { buttonVariants } from "@/components/ui/button"; -const AlertDialog = AlertDialogPrimitive.Root +const AlertDialog = AlertDialogPrimitive.Root; -const AlertDialogTrigger = AlertDialogPrimitive.Trigger +const AlertDialogTrigger = AlertDialogPrimitive.Trigger; -const AlertDialogPortal = AlertDialogPrimitive.Portal +const AlertDialogPortal = AlertDialogPrimitive.Portal; const AlertDialogOverlay = React.forwardRef< React.ElementRef, @@ -22,8 +22,8 @@ const AlertDialogOverlay = React.forwardRef< {...props} ref={ref} /> -)) -AlertDialogOverlay.displayName = AlertDialogPrimitive.Overlay.displayName +)); +AlertDialogOverlay.displayName = AlertDialogPrimitive.Overlay.displayName; const AlertDialogContent = React.forwardRef< React.ElementRef, @@ -40,8 +40,8 @@ const AlertDialogContent = React.forwardRef< {...props} /> -)) -AlertDialogContent.displayName = AlertDialogPrimitive.Content.displayName +)); +AlertDialogContent.displayName = AlertDialogPrimitive.Content.displayName; const AlertDialogHeader = ({ className, @@ -54,8 +54,8 @@ const AlertDialogHeader = ({ )} {...props} /> -) -AlertDialogHeader.displayName = "AlertDialogHeader" +); +AlertDialogHeader.displayName = "AlertDialogHeader"; const AlertDialogFooter = ({ className, @@ -68,8 +68,8 @@ const AlertDialogFooter = ({ )} {...props} /> -) -AlertDialogFooter.displayName = "AlertDialogFooter" +); +AlertDialogFooter.displayName = "AlertDialogFooter"; const AlertDialogTitle = React.forwardRef< React.ElementRef, @@ -80,8 +80,8 @@ const AlertDialogTitle = React.forwardRef< className={cn("text-lg font-semibold", className)} {...props} /> -)) -AlertDialogTitle.displayName = AlertDialogPrimitive.Title.displayName +)); +AlertDialogTitle.displayName = AlertDialogPrimitive.Title.displayName; const AlertDialogDescription = React.forwardRef< React.ElementRef, @@ -92,9 +92,9 @@ const AlertDialogDescription = React.forwardRef< className={cn("text-sm text-muted-foreground", className)} {...props} /> -)) +)); AlertDialogDescription.displayName = - AlertDialogPrimitive.Description.displayName + AlertDialogPrimitive.Description.displayName; const AlertDialogAction = React.forwardRef< React.ElementRef, @@ -105,8 +105,8 @@ const AlertDialogAction = React.forwardRef< className={cn(buttonVariants(), className)} {...props} /> -)) -AlertDialogAction.displayName = AlertDialogPrimitive.Action.displayName +)); +AlertDialogAction.displayName = AlertDialogPrimitive.Action.displayName; const AlertDialogCancel = React.forwardRef< React.ElementRef, @@ -121,8 +121,8 @@ const AlertDialogCancel = React.forwardRef< )} {...props} /> -)) -AlertDialogCancel.displayName = AlertDialogPrimitive.Cancel.displayName +)); +AlertDialogCancel.displayName = AlertDialogPrimitive.Cancel.displayName; export { AlertDialog, @@ -136,4 +136,4 @@ export { AlertDialogDescription, AlertDialogAction, AlertDialogCancel, -} +}; diff --git a/src/components/ui/alert.tsx b/src/components/ui/alert.tsx index 5afd41d..b068396 100644 --- a/src/components/ui/alert.tsx +++ b/src/components/ui/alert.tsx @@ -1,7 +1,7 @@ -import * as React from "react" -import { cva, type VariantProps } from "class-variance-authority" +import * as React from "react"; +import { cva, type VariantProps } from "class-variance-authority"; -import { cn } from "@/lib/utils" +import { cn } from "@/lib/utils"; const alertVariants = cva( "relative w-full rounded-lg border px-4 py-3 text-sm [&>svg+div]:translate-y-[-3px] [&>svg]:absolute [&>svg]:left-4 [&>svg]:top-4 [&>svg]:text-foreground [&>svg~*]:pl-7", @@ -17,7 +17,7 @@ const alertVariants = cva( variant: "default", }, } -) +); const Alert = React.forwardRef< HTMLDivElement, @@ -29,8 +29,8 @@ const Alert = React.forwardRef< className={cn(alertVariants({ variant }), className)} {...props} /> -)) -Alert.displayName = "Alert" +)); +Alert.displayName = "Alert"; const AlertTitle = React.forwardRef< HTMLParagraphElement, @@ -41,8 +41,8 @@ const AlertTitle = React.forwardRef< className={cn("mb-1 font-medium leading-none tracking-tight", className)} {...props} /> -)) -AlertTitle.displayName = "AlertTitle" +)); +AlertTitle.displayName = "AlertTitle"; const AlertDescription = React.forwardRef< HTMLParagraphElement, @@ -53,7 +53,7 @@ const AlertDescription = React.forwardRef< className={cn("text-sm [&_p]:leading-relaxed", className)} {...props} /> -)) -AlertDescription.displayName = "AlertDescription" +)); +AlertDescription.displayName = "AlertDescription"; -export { Alert, AlertTitle, AlertDescription } +export { Alert, AlertTitle, AlertDescription }; diff --git a/src/components/ui/aspect-ratio.tsx b/src/components/ui/aspect-ratio.tsx index c4abbf3..c9e6f4b 100644 --- a/src/components/ui/aspect-ratio.tsx +++ b/src/components/ui/aspect-ratio.tsx @@ -1,5 +1,5 @@ -import * as AspectRatioPrimitive from "@radix-ui/react-aspect-ratio" +import * as AspectRatioPrimitive from "@radix-ui/react-aspect-ratio"; -const AspectRatio = AspectRatioPrimitive.Root +const AspectRatio = AspectRatioPrimitive.Root; -export { AspectRatio } +export { AspectRatio }; diff --git a/src/components/ui/avatar.tsx b/src/components/ui/avatar.tsx index 51e507b..d260623 100644 --- a/src/components/ui/avatar.tsx +++ b/src/components/ui/avatar.tsx @@ -1,9 +1,9 @@ -"use client" +"use client"; -import * as React from "react" -import * as AvatarPrimitive from "@radix-ui/react-avatar" +import * as React from "react"; +import * as AvatarPrimitive from "@radix-ui/react-avatar"; -import { cn } from "@/lib/utils" +import { cn } from "@/lib/utils"; const Avatar = React.forwardRef< React.ElementRef, @@ -17,8 +17,8 @@ const Avatar = React.forwardRef< )} {...props} /> -)) -Avatar.displayName = AvatarPrimitive.Root.displayName +)); +Avatar.displayName = AvatarPrimitive.Root.displayName; const AvatarImage = React.forwardRef< React.ElementRef, @@ -29,8 +29,8 @@ const AvatarImage = React.forwardRef< className={cn("aspect-square h-full w-full", className)} {...props} /> -)) -AvatarImage.displayName = AvatarPrimitive.Image.displayName +)); +AvatarImage.displayName = AvatarPrimitive.Image.displayName; const AvatarFallback = React.forwardRef< React.ElementRef, @@ -44,7 +44,7 @@ const AvatarFallback = React.forwardRef< )} {...props} /> -)) -AvatarFallback.displayName = AvatarPrimitive.Fallback.displayName +)); +AvatarFallback.displayName = AvatarPrimitive.Fallback.displayName; -export { Avatar, AvatarImage, AvatarFallback } +export { Avatar, AvatarImage, AvatarFallback }; diff --git a/src/components/ui/badge.tsx b/src/components/ui/badge.tsx index e87d62b..fd92f29 100644 --- a/src/components/ui/badge.tsx +++ b/src/components/ui/badge.tsx @@ -1,7 +1,7 @@ -import * as React from "react" -import { cva, type VariantProps } from "class-variance-authority" +import * as React from "react"; +import { cva, type VariantProps } from "class-variance-authority"; -import { cn } from "@/lib/utils" +import { cn } from "@/lib/utils"; const badgeVariants = cva( "inline-flex items-center rounded-md border px-2.5 py-0.5 text-xs font-semibold transition-colors focus:outline-none focus:ring-2 focus:ring-ring focus:ring-offset-2", @@ -21,7 +21,7 @@ const badgeVariants = cva( variant: "default", }, } -) +); export interface BadgeProps extends React.HTMLAttributes, @@ -30,7 +30,7 @@ export interface BadgeProps function Badge({ className, variant, ...props }: BadgeProps) { return (
- ) + ); } -export { Badge, badgeVariants } +export { Badge, badgeVariants }; diff --git a/src/components/ui/breadcrumb.tsx b/src/components/ui/breadcrumb.tsx index 60e6c96..492882d 100644 --- a/src/components/ui/breadcrumb.tsx +++ b/src/components/ui/breadcrumb.tsx @@ -1,16 +1,16 @@ -import * as React from "react" -import { Slot } from "@radix-ui/react-slot" -import { ChevronRight, MoreHorizontal } from "lucide-react" +import * as React from "react"; +import { Slot } from "@radix-ui/react-slot"; +import { ChevronRight, MoreHorizontal } from "lucide-react"; -import { cn } from "@/lib/utils" +import { cn } from "@/lib/utils"; const Breadcrumb = React.forwardRef< HTMLElement, React.ComponentPropsWithoutRef<"nav"> & { - separator?: React.ReactNode + separator?: React.ReactNode; } ->(({ ...props }, ref) =>