import { useEffect } from 'react' import Image from 'next/image' import IconWarning from '@/assets/images/warning.svg' import { ChatError, ErrorCode, ChatMessageModel } from '@/lib/bots/bing/types' import { ExternalLink } from './external-link' import { useBing } from '@/lib/hooks/use-bing' export interface ChatNotificationProps extends Pick, 'bot'> { message?: ChatMessageModel } function getAction(error: ChatError, reset: () => void) { if (error.code === ErrorCode.THROTTLE_LIMIT) { reset() return (
你已达到每日最大发送消息次数,请更换账号或隔一天后重试
) } if (error.code === ErrorCode.BING_FORBIDDEN) { return ( 你的账号已在黑名单,请尝试更换账号及申请解封 ) } if (error.code === ErrorCode.CONVERSATION_LIMIT) { return (
当前话题已中止,请点 重新开始 开启新的对话
) } if (error.code === ErrorCode.BING_CAPTCHA) { return ( 点击通过人机验证 ) } if (error.code === ErrorCode.BING_UNAUTHORIZED) { reset() return ( 没有获取到身份信息或身份信息失效,点此重新设置 ) } return error.message } export function ChatNotification({ message, bot }: ChatNotificationProps) { useEffect(() => { window.scrollBy(0, 2000) }, [message]) if (!message?.error) return return (
error {getAction(message.error, () => bot.resetConversation())}
) }