2025-10-14 16:42:09 +08:00
< template >
< div class = "asistant-container flex flex-column" >
< div class = "header" >
2025-10-17 17:09:33 +08:00
< HeaderTitle hasSetting styleType = "2" / >
2025-10-14 16:42:09 +08:00
< / div >
2025-10-15 15:46:01 +08:00
< div class = "loading-container" v-if = "isLoading" >
2025-10-20 15:32:40 +08:00
< GenerateLoading / >
2025-10-14 16:42:09 +08:00
< / div >
2025-10-15 15:46:01 +08:00
< template v-else >
< div class = "content flex-1" v-if = "!isLoading" >
2025-10-16 16:03:01 +08:00
< NoticeList ref = "noticeListRef" :list = "messageList" @ send -message = " handleSendMessage " / >
2025-10-15 15:46:01 +08:00
< / div >
< div class = "footer" v-if = "!isLoading" >
< InputArea @ send -message = " handleSendMessage " / >
< div class = "continue" >
2025-10-16 16:03:01 +08:00
< button class = "btn" @click ="handleContinue" > Continue < / button >
2025-10-15 15:46:01 +08:00
< / div >
< / div >
< / template >
2025-10-14 16:42:09 +08:00
< / div >
< / template >
< script setup lang = "ts" >
import HeaderTitle from '@/components/HeaderTitle.vue'
import NoticeList from './components/NoticeList.vue'
import InputArea from './components/InputArea.vue'
2025-10-20 15:32:40 +08:00
import GenerateLoading from './components/GenerateLoading.vue'
2025-10-21 11:21:15 +08:00
import { ref , onMounted , onActivated } from 'vue'
2025-10-16 16:03:01 +08:00
import { useRouter } from 'vue-router'
const router = useRouter ( )
2025-10-14 16:42:09 +08:00
2025-10-21 11:21:15 +08:00
defineOptions ( {
name : 'asistant'
} )
2025-10-14 16:42:09 +08:00
// 定义NoticeList组件引用类型
interface NoticeListRef {
simulateSendMessage : ( ) => void
}
2025-10-16 16:03:01 +08:00
// 定义消息类型
interface ChatMessage {
id : string
content : string
userId : string
time : string
thumb : string
}
2025-10-14 16:42:09 +08:00
const isLoading = ref < boolean > ( false )
const noticeListRef = ref < NoticeListRef | null > ( null )
2025-10-16 16:03:01 +08:00
const messageList = ref < ChatMessage [ ] > ( [
{
id : '1' ,
content : 'I want a chic outfit for dinner.' ,
userId : '1' ,
time : '14:30' ,
thumb : ''
} ,
{
id : '2' ,
content :
"Hey there! A chic dinner outfit, I love that! To give you the perfect recommendations, tell me: is this a romantic date, business dinner, or celebration with friends? And what's your go-to style vibe: classic elegance or something with more edge?" ,
userId : '2' ,
time : '14:31' ,
thumb : 'https://files-dev.deercal.com/uploads/platforms/logo_code/669933e1b873e798.jpg'
} ,
{
id : '3' ,
content : "It's a romantic date, and I prefer classic elegance." ,
userId : '1' ,
time : '14:32' ,
thumb : ''
} ,
{
id : '4' ,
content :
"Perfect! For a romantic dinner with classic elegance, I'd suggest a little black dress with delicate jewelry and elegant heels. Would you like me to show you some specific options?" ,
userId : '2' ,
time : '14:33' ,
thumb : 'https://files-dev.deercal.com/uploads/platforms/logo_code/669933e1b873e798.jpg'
}
] )
2025-10-14 16:42:09 +08:00
onMounted ( ( ) => {
2025-10-21 11:21:15 +08:00
console . log ( '🚀 组件挂载 - onMounted 触发' )
2025-10-14 16:42:09 +08:00
// handleSendMessage('123')
} )
2025-10-21 11:21:15 +08:00
onActivated ( ( ) => {
console . log ( '🔄 缓存页面激活 - onActivated 触发' )
console . log ( '当前消息数量:' , messageList . value . length )
} )
2025-10-14 16:42:09 +08:00
const handleSendMessage = ( message : string ) : void => {
console . log ( '收到消息:' , message )
2025-10-16 16:03:01 +08:00
messageList . value . push ( {
id : '1' ,
content : message ,
userId : '1' ,
time : new Date ( ) . toLocaleTimeString ( 'en-US' , { hour : '2-digit' , minute : '2-digit' } ) ,
thumb : ''
} )
//
}
const handleContinue = ( ) => {
// router.push('/workshop/selectStyle')
// 模拟接口之后再跳转
isLoading . value = true
2025-10-14 16:42:09 +08:00
setTimeout ( ( ) => {
2025-10-16 16:03:01 +08:00
router . push ( '/workshop/selectStyle' )
2025-10-21 11:21:15 +08:00
isLoading . value = false
2025-10-16 16:03:01 +08:00
} , 1000 )
2025-10-14 16:42:09 +08:00
}
< / script >
< style lang = "less" scoped >
. asistant - container {
height : 100 vh ;
overflow : hidden ;
}
. header {
flex - shrink : 0 ;
}
. content {
overflow : hidden ;
display : flex ;
flex - direction : column ;
}
. footer {
flex - shrink : 0 ;
2025-10-15 15:46:01 +08:00
2025-10-14 16:42:09 +08:00
. continue {
font - family : 'satoshiRegular' ;
font - size : 3.6 rem ;
color : # fff ;
text - align : right ;
padding : 2.6 rem 4.5 rem ;
. btn {
border - radius : 7 px ;
background - color : # 000 ;
width : 24.6 rem ;
height : 5.9 rem ;
}
}
}
2025-10-15 15:46:01 +08:00
. loading - container {
2025-10-14 16:42:09 +08:00
flex : 1 ;
display : flex ;
align - items : center ;
justify - content : center ;
background - color : # fff ;
}
< / style >