diff --git a/web/src/app/(user)/canvas/components/canvas-assistant-panel.tsx b/web/src/app/(user)/canvas/components/canvas-assistant-panel.tsx index fcf62e8..7f7a6ae 100644 --- a/web/src/app/(user)/canvas/components/canvas-assistant-panel.tsx +++ b/web/src/app/(user)/canvas/components/canvas-assistant-panel.tsx @@ -1,12 +1,11 @@ "use client"; -import { useEffect, useMemo, useState, type ReactNode } from "react"; -import { ArrowUp, History, ImageIcon, LoaderCircle, MessageSquare, PanelRightClose, Plus, RotateCcw, Settings2, Sparkles, Trash2, X } from "lucide-react"; -import { Button, ConfigProvider, Modal, Segmented, Tooltip } from "antd"; +import { useEffect, useMemo, useState } from "react"; +import { ArrowUp, ChevronDown, Cpu, History, ImageIcon, LoaderCircle, MessageSquare, PanelRightClose, Plus, RotateCcw, Settings2, Sparkles, Trash2, X } from "lucide-react"; +import { Button, Dropdown, Modal, Tooltip } from "antd"; import { motion } from "motion/react"; import { ImageGenerationPending } from "@/components/image-generation-pending"; -import { ModelPicker } from "@/components/model-picker"; import { useConfigStore, useEffectiveConfig, type AiConfig } from "@/stores/use-config-store"; import { canvasThemes } from "@/lib/canvas-theme"; import { nanoid } from "nanoid"; @@ -417,41 +416,16 @@ function AssistantComposer({ placeholder={mode === "image" ? "描述你想生成或修改的图片" : "输入你想问的问题"} />
-
+
- - onModeChange(value as AssistantMode)} - options={[ - { - value: "ask", - label: ( - - - - ), - }, - { - value: "image", - label: ( - - - - ), - }, - ]} - /> - + {mode === "image" ? ( <> - onConfigChange("imageModel", model)} onMissingConfig={onMissingConfig} /> - document.body} onConfigChange={onConfigChange} onMissingConfig={onMissingConfig} /> + onConfigChange("imageModel", model)} onMissingConfig={onMissingConfig} /> + document.body} buttonClassName="canvas-composer-settings canvas-composer-icon !h-8 !min-w-8 !rounded-full !px-2" onConfigChange={onConfigChange} onMissingConfig={onMissingConfig} /> ) : ( - onConfigChange("textModel", model)} onMissingConfig={onMissingConfig} /> + onConfigChange("textModel", model)} onMissingConfig={onMissingConfig} /> )}
+ + ); +} + +function ModelMenuLabel({ model }: { model: string }) { + return ( + + + {model} + + ); +} + +function ModelIcon({ model }: { model: string }) { + const name = model.toLowerCase(); + const icon = name.includes("claude") || name.includes("anthropic") ? "/icons/claude.svg" : name.includes("gemini") || name.includes("google") ? "/icons/gemini.svg" : name.includes("gpt") || name.includes("openai") ? "/icons/openai.svg" : ""; + return icon ? : ; +} + +function AssistantModeSwitch({ mode, theme, onChange }: { mode: AssistantMode; theme: (typeof canvasThemes)[keyof typeof canvasThemes]; onChange: (mode: AssistantMode) => void }) { + return ( +
+ {[ + { value: "ask" as const, title: "对话", icon: }, + { value: "image" as const, title: "生图", icon: }, + ].map((item) => ( + + + + ))} +
); } diff --git a/web/src/app/(user)/canvas/components/canvas-prompt-library.tsx b/web/src/app/(user)/canvas/components/canvas-prompt-library.tsx index e2305e4..a29730d 100644 --- a/web/src/app/(user)/canvas/components/canvas-prompt-library.tsx +++ b/web/src/app/(user)/canvas/components/canvas-prompt-library.tsx @@ -16,9 +16,9 @@ export function CanvasPromptLibrary({ onSelect }: { onSelect: (prompt: string) = <>