2026-02-10 13:05:24 +08:00
< template >
< div class = "agent-container flex flex-col" >
< div class = "agent-header flex align-center space-between" >
< div class = "header-title-wrapper" >
< div class = "agent-title" > { { props . title } } < / div >
< div class = "agent-name" > AI Assistant 1.0 < / div >
< / div >
< SvgIcon name = "equal" color = "#0d0d0d" size = "24" / >
< / div >
< div class = "agent-body flex-1 flex flex-col" >
2026-02-10 17:22:40 +08:00
< List :message-list = "messageList" / >
< Input is -agent -mode @send ="handleSendMessage" / >
2026-02-10 13:05:24 +08:00
< / div >
< / div >
< / template >
< script setup lang = "ts" >
2026-02-10 17:22:40 +08:00
import { ref , reactive } from 'vue'
2026-02-10 13:05:24 +08:00
import List from './List.vue'
import Input from '../../components/Input.vue'
const props = withDefaults (
defineProps < {
title : string
} > ( ) ,
{
title : 'Retro Sofa Sketch'
}
)
2026-02-10 17:22:40 +08:00
const messageList = ref ( [
{ id : 1 , text : 'Hello' , isUser : true } ,
{
id : 2 ,
text : 'Hey, I am your design assistant FiDA. I noticed that you want to design a yellow sofa. I can help you! Tell me what else you need?'
} ,
{
id : 3 ,
text : 'Please design a vintage-inspired sofa with smooth, flowing lines and a sculptural silhouette. The sofa features a retro aesthetic combined with elegant curves, creating a timeless and refined look.' ,
isUser : true
}
] )
2026-02-10 13:05:24 +08:00
const handleSendMessage = ( message : string ) => {
console . log ( 'Message sent:' , message )
2026-02-10 17:22:40 +08:00
messageList . value . push ( {
id : messageList . value . length + 1 ,
text : message ,
isUser : true
} )
// Add AI loading message
const aiMessage = reactive ( {
id : messageList . value . length + 1 ,
text : '' ,
isUser : false ,
loading : true ,
thinking : false ,
thinkingText : '' ,
thinkingCollapsed : false ,
streaming : false
} )
messageList . value . push ( aiMessage )
// Simulate AI response
setTimeout ( ( ) => {
aiMessage . loading = false
aiMessage . thinking = true
aiMessage . thinkingText = '思考中...'
// Simulate thinking process
setTimeout ( ( ) => {
aiMessage . thinkingText = '分析用户需求:设计复古风格沙发,强调流畅线条和雕塑轮廓。'
} , 1000 )
setTimeout ( ( ) => {
aiMessage . thinkingText += '\n考虑颜色方案: 黄色基调, 结合复古元素考虑颜色方案: 黄色基调, 结合复古元素考虑颜色方案: 黄色基调, 结合复古元素考虑颜色方案: 黄色基调, 结合复古元素考虑颜色方案: 黄色基调, 结合复古元素考虑颜色方案: 黄色基调, 结合复古元素考虑颜色方案: 黄色基调, 结合复古元素考虑颜色方案: 黄色基调, 结合复古元素考虑颜色方案: 黄色基调, 结合复古元素考虑颜色方案: 黄色基调, 结合复古元素考虑颜色方案: 黄色基调, 结合复古元素考虑颜色方案: 黄色基调, 结合复古元素考虑颜色方案: 黄色基调, 结合复古元素考虑颜色方案: 黄色基调, 结合复古元素考虑颜色方案: 黄色基调, 结合复古元素考虑颜色方案: 黄色基调, 结合复古元素考虑颜色方案: 黄色基调, 结合复古元素考虑颜色方案: 黄色基调, 结合复古元素考虑颜色方案: 黄色基调, 结合复古元素考虑颜色方案: 黄色基调, 结合复古元素。'
} , 2000 )
setTimeout ( ( ) => {
aiMessage . thinkingText += '\n生成设计草图...'
aiMessage . thinking = false
aiMessage . streaming = true
// Simulate streaming response
const response = '根据您的描述,我为您设计了一个复古风格的沙发。这个沙发采用黄色皮革材质,线条流畅,轮廓雕塑感强。整体造型优雅,结合了现代舒适与复古美学。'
let index = 0
const interval = setInterval ( ( ) => {
if ( index < response . length ) {
aiMessage . text += response [ index ]
index ++
} else {
clearInterval ( interval )
aiMessage . streaming = false
}
} , 50 )
} , 3000 )
} , 1000 )
2026-02-10 13:05:24 +08:00
}
< / script >
< style lang = "less" scoped >
. c - svg {
width : initial ;
}
. agent - container {
// width: 39%;
width : 63.4 rem ;
background - color : # fff ;
border - radius : 2 rem ;
box - shadow : 0 px 15 px 21 px 0 px # 0000000 d ;
. agent - header {
height : 7.4 rem ;
border - bottom : 0.1 rem solid # c9c9c9 ;
font - family : 'GeneralMedium' ;
padding : 1.4 rem 3.4 rem 1.4 rem 3.1 rem ;
. agent - title {
font - size : 1.8 rem ;
margin - bottom : 0.6 rem ;
}
. agent - name {
font - size : 1.4 rem ;
}
}
. agent - body {
padding : 3.2 rem ;
. assist - input - wrapper {
width : 100 % ;
height : 14.4 rem ;
min - height : 14.4 rem ! important ;
max - height : 14.4 rem ! important ;
}
}
. input - wrapper {
height : 14.4 rem ;
padding : 0 2 rem 3 rem ;
}
}
< / style >