"use client";
|
|
import { useState, useEffect } from 'react';
|
import { motion, AnimatePresence } from 'framer-motion';
|
|
// 导入场景数据
|
const services = [
|
{
|
title: '补料',
|
description: '智能动态分析产线,工位的缺料情况,降低停线风险',
|
imageUrl: '/images/kanban.jpg',
|
chatbotId: 'JELkWpPLHQfRNhEH',
|
},
|
{
|
title: '插单',
|
description: '智能评估需求插单对产能,原材料和交付服务的影响,提升客户满意度',
|
imageUrl: '/images/xuqiu.jpg',
|
chatbotId: 'DfH4cIzujVGvn5iR',
|
},
|
{
|
title: '科沃斯销售推荐小助手',
|
description: '智能化产品推荐提升导购效率',
|
imageUrl: '/images/robot.jpg',
|
chatbotId: 'sUAviPXvcEIw3oQC',
|
},
|
{
|
title: '库存管理知识库问答',
|
description: '库存知识,提供专业的供应链库存知识问答',
|
imageUrl: '/images/know.jpg',
|
chatbotId: 'pDDfkU9HyBl2gzXx',
|
},
|
];
|
|
export default function AISceneChatPage() {
|
const [selectedScene, setSelectedScene] = useState(services[0]);
|
const [iframeKey, setIframeKey] = useState(0); // 用于强制刷新iframe
|
|
// 切换场景时重新加载iframe
|
const handleSceneChange = (scene: typeof services[0]) => {
|
setSelectedScene(scene);
|
setIframeKey(prev => prev + 1);
|
};
|
|
return (
|
<div className="h-screen flex bg-[#0A1033]">
|
{/* 左侧场景选项卡 */}
|
<div className="w-64 bg-[#131C41] border-r border-[#6ADBFF]/20 flex flex-col">
|
<div className="p-4 flex-1 overflow-y-auto">
|
<h2 className="text-xl font-bold text-white mb-6 flex items-center">
|
<span className="text-transparent bg-clip-text bg-gradient-to-r from-[#6ADBFF] to-[#5E72EB]">
|
AI场景
|
</span>
|
<motion.span
|
className="ml-2 inline-block w-2 h-2 rounded-full bg-[#6ADBFF]"
|
animate={{
|
scale: [1, 1.5, 1],
|
opacity: [0.7, 1, 0.7]
|
}}
|
transition={{
|
duration: 2,
|
repeat: Infinity,
|
ease: "easeInOut"
|
}}
|
/>
|
</h2>
|
<div className="space-y-3">
|
{services.map((scene) => (
|
<motion.button
|
key={scene.chatbotId}
|
onClick={() => handleSceneChange(scene)}
|
className={`w-full p-4 rounded-lg text-left transition-all duration-500 relative overflow-hidden
|
${selectedScene.chatbotId === scene.chatbotId
|
? 'text-[#6ADBFF]'
|
: 'text-gray-300 hover:text-[#6ADBFF]'
|
}`}
|
whileHover={{ scale: 1.02 }}
|
whileTap={{ scale: 0.98 }}
|
>
|
{selectedScene.chatbotId === scene.chatbotId && (
|
<motion.div
|
className="absolute inset-0 bg-gradient-to-r from-[#1A2547] to-[#1E2B63] -z-10"
|
layoutId="activeBackground"
|
initial={false}
|
transition={{
|
type: "spring",
|
stiffness: 200,
|
damping: 20
|
}}
|
/>
|
)}
|
<div className="flex items-center relative z-10">
|
<div className="w-10 h-10 rounded-lg overflow-hidden mr-3 relative">
|
<img
|
src={scene.imageUrl}
|
alt={scene.title}
|
className="w-full h-full object-cover transform transition-transform duration-700 group-hover:scale-110"
|
/>
|
<div className="absolute inset-0 bg-gradient-to-br from-black/20 to-transparent"></div>
|
</div>
|
<div>
|
<span className="font-medium block">{scene.title}</span>
|
<span className="text-xs text-gray-400 line-clamp-1">{scene.description}</span>
|
</div>
|
</div>
|
{selectedScene.chatbotId === scene.chatbotId && (
|
<motion.div
|
className="absolute right-3 top-1/2 -translate-y-1/2 w-1.5 h-6 bg-[#6ADBFF] rounded-full"
|
layoutId="activeIndicator"
|
initial={{ opacity: 0 }}
|
animate={{ opacity: 1 }}
|
exit={{ opacity: 0 }}
|
/>
|
)}
|
</motion.button>
|
))}
|
</div>
|
</div>
|
</div>
|
|
{/* 中间聊天区域 */}
|
<div className="flex-1 flex flex-col bg-gradient-to-br from-[#0A1033] to-[#131C41]">
|
{/* 顶部标题栏 */}
|
<div className="h-16 border-b border-[#6ADBFF]/20 flex items-center px-6 bg-[#131C41]/50 backdrop-blur-sm">
|
<AnimatePresence mode="wait">
|
<motion.div
|
key={selectedScene.chatbotId}
|
initial={{ opacity: 0, y: -20 }}
|
animate={{ opacity: 1, y: 0 }}
|
exit={{ opacity: 0, y: 20 }}
|
transition={{ duration: 0.3 }}
|
className="flex items-center"
|
>
|
<div className="w-8 h-8 rounded-lg overflow-hidden mr-3 relative">
|
<img
|
src={selectedScene.imageUrl}
|
alt={selectedScene.title}
|
className="w-full h-full object-cover"
|
/>
|
<div className="absolute inset-0 bg-gradient-to-br from-black/20 to-transparent"></div>
|
</div>
|
<div>
|
<h1 className="text-xl font-bold text-white">
|
{selectedScene.title}
|
</h1>
|
<p className="text-sm text-gray-400">
|
{selectedScene.description}
|
</p>
|
</div>
|
</motion.div>
|
</AnimatePresence>
|
</div>
|
|
{/* 聊天窗口 */}
|
<div className="flex-1 relative">
|
<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>
|
</div>
|
</div>
|
);
|
}
|