feat(ui): 添加配置错误 toast 提示

当 Provider API Key 未配置时,显示 toast 提示并提供
"去配置"按钮,点击可直接打开 Providers 配置面板
This commit is contained in:
2025-12-14 22:35:02 +08:00
parent 32064a3531
commit 07a039001d
2 changed files with 24 additions and 0 deletions
+12
View File
@@ -5,6 +5,7 @@
import { useEffect, useRef } from 'react';
import { WifiOff, MessageSquare, Settings, FolderOpen, Terminal, Plug, Zap, Bot, History, Server } from 'lucide-react';
import { motion, AnimatePresence } from 'framer-motion';
import { toast } from 'sonner';
import {
useChat,
ChatMessage,
@@ -54,6 +55,17 @@ export function ChatPage({
console.error('Chat error:', error);
},
onSessionUpdated,
onConfigError: (error) => {
toast.error(error.message, {
duration: 10000,
action: onOpenProviders
? {
label: '去配置',
onClick: onOpenProviders,
}
: undefined,
});
},
});
const messagesEndRef = useRef<HTMLDivElement>(null);
+12
View File
@@ -5,6 +5,7 @@
import { useEffect, useRef } from 'react';
import { WifiOff, MessageSquare, Settings, FolderOpen, Terminal, Plug, Zap, Bot, History, Server } from 'lucide-react';
import { motion, AnimatePresence } from 'framer-motion';
import { toast } from 'sonner';
import {
useChat,
ChatMessage,
@@ -64,6 +65,17 @@ export function ChatPage({
},
onSessionNotFound,
onSessionUpdated,
onConfigError: (error) => {
toast.error(error.message, {
duration: 10000,
action: onOpenProviders
? {
label: '去配置',
onClick: onOpenProviders,
}
: undefined,
});
},
});
const messagesEndRef = useRef<HTMLDivElement>(null);