| | |
| | | import { motion, AnimatePresence } from 'framer-motion'; |
| | | import { useSearchParams } from 'next/navigation'; |
| | | import { useRouter } from 'next/navigation'; |
| | | import Image from 'next/image'; |
| | | import DataPreviewDialog from '@/components/DataPreviewDialog'; |
| | | |
| | | // 导入场景数据 |
| | |
| | | const [services] = useState([defaultServices.find(s => s.chatbotId === sceneId) || defaultServices[0]]); |
| | | const [selectedScene, setSelectedScene] = useState(initialScene); |
| | | const [iframeKey, setIframeKey] = useState(0); |
| | | const [token, setToken] = useState<string | null>(null); |
| | | |
| | | useEffect(() => { |
| | | // Get token from localStorage |
| | | const storedToken = localStorage.getItem('token'); |
| | | setToken(storedToken); |
| | | }, []); |
| | | |
| | | // 切换场景时重新加载iframe |
| | | const handleSceneChange = (scene: typeof services[0]) => { |
| | |
| | | </div> |
| | | |
| | | {/* 聊天窗口 */} |
| | | <div className="flex-1 relative [&::-webkit-scrollbar]:w-1 [&::-webkit-scrollbar-track]:bg-transparent [&::-webkit-scrollbar-thumb]:bg-[#E5E6EB] [&::-webkit-scrollbar-thumb]:rounded-full hover:[&::-webkit-scrollbar-thumb]:bg-[#C9CDD4]"> |
| | | <AnimatePresence mode="wait"> |
| | | <motion.div |
| | | key={iframeKey} |
| | | className="absolute inset-0" |
| | | initial={{ opacity: 0, scale: 0.98 }} |
| | | animate={{ opacity: 1, scale: 1 }} |
| | | exit={{ opacity: 0, scale: 1.02 }} |
| | | transition={{ duration: 0.3 }} |
| | | > |
| | | <iframe |
| | | src={`http://121.43.139.99/chatbot/${selectedScene.chatbotId}`} |
| | | className="w-full h-full" |
| | | style={{ border: 'none' }} |
| | | allow="microphone" |
| | | /> |
| | | </motion.div> |
| | | </AnimatePresence> |
| | | <div className="flex-1 relative"> |
| | | <iframe |
| | | key={iframeKey} |
| | | className="w-full h-full rounded-lg" |
| | | src={`http://121.43.139.99:7000/chatbot/${selectedScene.chatbotId}${token ? `?token=${token}` : ''}`} |
| | | frameBorder="0" |
| | | allow="microphone" |
| | | ></iframe> |
| | | </div> |
| | | </div> |
| | | </div> |