From 8b3dc4298d5b2378f6cb02ccf035f7973417c063 Mon Sep 17 00:00:00 2001 From: thzxx Date: Sat, 27 Jun 2026 21:50:31 +0800 Subject: [PATCH] =?UTF-8?q?feat:=20DeepSeek=20=E9=80=89=E6=8B=A9=E6=97=B6?= =?UTF-8?q?=E7=A6=81=E6=AD=A2=E4=B8=8A=E4=BC=A0=E5=9B=BE=E7=89=87=E9=99=84?= =?UTF-8?q?=E4=BB=B6?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit DeepSeek 不支持多模态,前端层面阻止用户选择图片文件: - ChatInput 根据 provider 动态控制 accept 属性(DeepSeek不包含image/*) - addFiles 中过滤图片文件(DeepSeek自动跳过) - Paperclip 按钮 Tooltip 区分提示 - provider 切换后即时生效(通过 useAgentStore 响应式读取) --- src/components/chat/ChatInput.tsx | 24 ++++++++++++++++++++---- 1 file changed, 20 insertions(+), 4 deletions(-) diff --git a/src/components/chat/ChatInput.tsx b/src/components/chat/ChatInput.tsx index 9a028ab..94eea31 100644 --- a/src/components/chat/ChatInput.tsx +++ b/src/components/chat/ChatInput.tsx @@ -46,6 +46,10 @@ export function ChatInput(): React.JSX.Element { const isStreaming = useAgentStore((s) => s.isStreaming); const tokenUsage = useAgentStore((s) => s.tokenUsage); const currentSessionId = useSessionStore((s) => s.currentSessionId); + const provider = useAgentStore((s) => s.provider); + + /** DeepSeek 不支持多模态图片 */ + const supportsImages = provider !== 'deepseek'; // 草稿自动保存 useEffect(() => { if (currentSessionId) { const d = sessionStorage.getItem(`draft-${currentSessionId}`); setInput(d ?? ''); } }, [currentSessionId]); @@ -85,9 +89,21 @@ export function ChatInput(): React.JSX.Element { const addFiles = useCallback(async (files: FileList | File[]) => { const fileArray = Array.from(files).slice(0, 5); // 最多 5 个附件 - const newAttachments = await Promise.all(fileArray.map(processFile)); + + // DeepSeek 不支持多模态,过滤图片 + const filtered = supportsImages + ? fileArray + : fileArray.filter((f) => !IMAGE_TYPES.includes(f.type)); + + if (filtered.length < fileArray.length && !supportsImages) { + // TODO: 用 Toast 提示用户 "DeepSeek 不支持图片,已自动跳过 N 个图片文件" + } + + if (filtered.length === 0) return; + + const newAttachments = await Promise.all(filtered.map(processFile)); setAttachments((prev) => [...prev, ...newAttachments]); - }, [processFile]); + }, [processFile, supportsImages]); const removeAttachment = useCallback((id: string) => { setAttachments((prev) => prev.filter((a) => a.id !== id)); @@ -224,7 +240,7 @@ export function ChatInput(): React.JSX.Element { )} - +