feat(ui): 添加配置错误 toast 提示
当 Provider API Key 未配置时,显示 toast 提示并提供 "去配置"按钮,点击可直接打开 Providers 配置面板
This commit is contained in:
@@ -5,6 +5,7 @@
|
|||||||
import { useEffect, useRef } from 'react';
|
import { useEffect, useRef } from 'react';
|
||||||
import { WifiOff, MessageSquare, Settings, FolderOpen, Terminal, Plug, Zap, Bot, History, Server } from 'lucide-react';
|
import { WifiOff, MessageSquare, Settings, FolderOpen, Terminal, Plug, Zap, Bot, History, Server } from 'lucide-react';
|
||||||
import { motion, AnimatePresence } from 'framer-motion';
|
import { motion, AnimatePresence } from 'framer-motion';
|
||||||
|
import { toast } from 'sonner';
|
||||||
import {
|
import {
|
||||||
useChat,
|
useChat,
|
||||||
ChatMessage,
|
ChatMessage,
|
||||||
@@ -54,6 +55,17 @@ export function ChatPage({
|
|||||||
console.error('Chat error:', error);
|
console.error('Chat error:', error);
|
||||||
},
|
},
|
||||||
onSessionUpdated,
|
onSessionUpdated,
|
||||||
|
onConfigError: (error) => {
|
||||||
|
toast.error(error.message, {
|
||||||
|
duration: 10000,
|
||||||
|
action: onOpenProviders
|
||||||
|
? {
|
||||||
|
label: '去配置',
|
||||||
|
onClick: onOpenProviders,
|
||||||
|
}
|
||||||
|
: undefined,
|
||||||
|
});
|
||||||
|
},
|
||||||
});
|
});
|
||||||
|
|
||||||
const messagesEndRef = useRef<HTMLDivElement>(null);
|
const messagesEndRef = useRef<HTMLDivElement>(null);
|
||||||
|
|||||||
@@ -5,6 +5,7 @@
|
|||||||
import { useEffect, useRef } from 'react';
|
import { useEffect, useRef } from 'react';
|
||||||
import { WifiOff, MessageSquare, Settings, FolderOpen, Terminal, Plug, Zap, Bot, History, Server } from 'lucide-react';
|
import { WifiOff, MessageSquare, Settings, FolderOpen, Terminal, Plug, Zap, Bot, History, Server } from 'lucide-react';
|
||||||
import { motion, AnimatePresence } from 'framer-motion';
|
import { motion, AnimatePresence } from 'framer-motion';
|
||||||
|
import { toast } from 'sonner';
|
||||||
import {
|
import {
|
||||||
useChat,
|
useChat,
|
||||||
ChatMessage,
|
ChatMessage,
|
||||||
@@ -64,6 +65,17 @@ export function ChatPage({
|
|||||||
},
|
},
|
||||||
onSessionNotFound,
|
onSessionNotFound,
|
||||||
onSessionUpdated,
|
onSessionUpdated,
|
||||||
|
onConfigError: (error) => {
|
||||||
|
toast.error(error.message, {
|
||||||
|
duration: 10000,
|
||||||
|
action: onOpenProviders
|
||||||
|
? {
|
||||||
|
label: '去配置',
|
||||||
|
onClick: onOpenProviders,
|
||||||
|
}
|
||||||
|
: undefined,
|
||||||
|
});
|
||||||
|
},
|
||||||
});
|
});
|
||||||
|
|
||||||
const messagesEndRef = useRef<HTMLDivElement>(null);
|
const messagesEndRef = useRef<HTMLDivElement>(null);
|
||||||
|
|||||||
Reference in New Issue
Block a user