feat: 聊天页面

This commit is contained in:
zhangyh
2025-10-14 16:42:09 +08:00
parent fe2e8b1965
commit f64c3752b4
20 changed files with 718 additions and 10 deletions

View File

@@ -0,0 +1,63 @@
<template>
<div class="chat-loading">
<div class="loading-container flex flex-column flex-align-center">
<img src="@/assets/images/chat_loading.png" alt="Loading" class="loading-image" />
<!-- 阴影效果 -->
<div class="loading-shadow"></div>
<div class="loading-text">Analyzing the Outfit...</div>
</div>
</div>
</template>
<script setup lang="ts">
// 这个组件只负责显示loading动画
interface LoadingProps {
// 可以在这里定义props类型
}
// 定义组件props类型
const props = defineProps<LoadingProps>()
</script>
<style lang="less" scoped>
.chat-loading {
display: flex;
justify-content: flex-start;
}
.loading-container {
position: relative;
}
.loading-image {
width: 36.4rem;
height: 36.4rem;
animation: rotate 1s linear infinite;
}
.loading-shadow {
width: 19.6rem;
height: 5.2rem;
background-color: #d9d9d9;
border-radius: 50%;
filter: blur(35.5px);
margin-top: 5.1rem;
margin-bottom: 6.4rem;
}
.loading-text{
font-family: 'satoshiRegular';
font-size: 4.8rem;
letter-spacing: 0.02em;
line-height: 124%;
}
@keyframes rotate {
from {
transform: rotate(0deg);
}
to {
transform: rotate(360deg);
}
}
</style>

View File

@@ -0,0 +1,121 @@
<template>
<div class="input-area">
<div class="input-container">
<!-- 加号图标 -->
<div class="icon-wrapper">
<SvgIcon name="plus" size="40" />
</div>
<!-- 分隔线 -->
<div class="divider"></div>
<!-- 输入框 -->
<div class="input-wrapper">
<input
v-model="inputValue"
type="text"
placeholder="Ask anything about your desired outfit"
class="text-input"
@keyup.enter="handleSend"
/>
</div>
<!-- 语音图标 -->
<div class="icon-wrapper">
<SvgIcon name="audio" size="52" />
</div>
<!-- 发送图标 -->
<div class="icon-wrapper send-icon" @click="handleSend">
<SvgIcon name="send" size="46" />
</div>
</div>
</div>
</template>
<script setup lang="ts">
import { ref } from 'vue'
import SvgIcon from '@/components/SvgIcon/index.vue'
interface InputAreaEmits {
'send-message': [message: string]
}
const inputValue = ref<string>('')
const emit = defineEmits<InputAreaEmits>()
const handleSend = (): void => {
if (inputValue.value.trim()) {
console.log('input发送消息:', inputValue.value)
emit('send-message', inputValue.value)
inputValue.value = ''
}
}
</script>
<style lang="less" scoped>
.input-area {
background-color: #fff;
}
.input-container {
display: flex;
align-items: center;
background-color: #efefef;
padding: 0 4.85rem 0 5.2rem;
height: 19.3rem;
}
.icon-wrapper {
display: flex;
align-items: center;
justify-content: center;
cursor: pointer;
&.send-icon {
margin-left: 4.38rem;
}
}
.divider {
width: 2px;
height: 14.9rem;
margin-left: 5.59rem;
margin-right: 3.5rem;
background-color: #888;
}
.input-wrapper {
flex: 1;
display: flex;
align-items: center;
}
.text-input {
width: 100%;
border: none;
outline: none;
background: transparent;
font-size: 4rem;
font-family: 'robotoBold';
font-weight: 400;
line-height: 121%;
// padding-right: 2rem;
margin-right: 4.21rem;
color: #888;
&::placeholder {
color: #888;
}
}
// 确保图标颜色为 #6d6868
:deep(.svg-icon) {
color: #6d6868;
svg {
fill: #6d6868;
}
}
</style>

View File

@@ -0,0 +1,149 @@
<template>
<div
class="chat-message"
:class="{ 'user-message': value.userId === '1', 'ai-message': value.userId !== '1' }"
>
<!-- AI消息显示头像 -->
<div v-if="value.userId !== '1'" class="chat-avatar">
<img :src="value.thumb" alt="AI Avatar" />
</div>
<!-- 消息内容 -->
<div class="message-content">
<div class="message-text">
{{ value.content }}
</div>
<!-- AI消息显示操作栏 -->
<div v-if="value.userId !== '1'" class="message-actions flex">
<SvgIcon
v-for="item in actionList"
:key="item.value"
:name="item.icon"
size="39"
@click.stop="handleClickAction(item.value)"
/>
</div>
</div>
</div>
</template>
<script setup lang="ts">
// 定义消息类型
interface ChatMessage {
id: string
content: string
userId: string
time: string
thumb: string
}
// 定义操作项类型
interface ActionItem {
value: string
icon: string
}
// 定义组件props类型
interface NoticeItemProps {
value: ChatMessage
}
const props = defineProps<NoticeItemProps>()
const handleClickAction = (value: string): void => {
console.log('click Action', value)
}
const actionList: ActionItem[] = [
{
value: 'thumbup',
icon: 'thumbup'
},
{
value: 'thumbdown',
icon: 'thumbdown'
},
{
value: 'refresh',
icon: 'refresh'
},
{
value: 'upload',
icon: 'upload'
},
{
value: 'more',
icon: 'more'
}
]
</script>
<style lang="less" scoped>
.chat-message {
display: flex;
margin-bottom: 16px;
align-items: flex-start;
.message-text {
font-size: 4.2rem;
font-family: 'robotoBold';
line-height: 121%;
font-weight: 400;
background-color: #efefef;
padding: 4.95rem 3.95rem;
}
&.user-message {
justify-content: flex-end;
.message-content {
align-items: flex-end;
.message-text {
border-radius: 2rem 2rem 0 2rem;
}
}
}
&.ai-message {
justify-content: flex-start;
.message-content {
align-items: flex-start;
.message-text {
color: #000;
border-radius: 0 2rem 2rem 2rem;
}
}
}
}
.chat-avatar {
width: 7.8rem;
height: 7.4rem;
border-radius: 50%;
margin-right: 1.88rem;
img {
width: 100%;
height: 100%;
border-radius: 50%;
object-fit: cover;
}
}
.message-content {
display: flex;
flex-direction: column;
max-width: 70%;
}
.message-actions {
margin-top: 2.6rem;
color: #6b6b6b;
column-gap: 1.61rem;
.svg-icon {
cursor: pointer;
}
}
</style>

View File

@@ -0,0 +1,103 @@
<template>
<div class="chat-list">
<div class="chat-message-item" v-for="message in chatMessages" :key="message.id">
<NoticeItem :value="message" @send-message="handleSendMessage" />
</div>
<!-- Loading效果 -->
<div v-if="isLoading" class="chat-message-item">
<ChatLoading />
</div>
</div>
</template>
<script setup lang="ts">
import NoticeItem from './NoticeItem.vue'
import ChatLoading from './ChatLoading.vue'
import { ref, onMounted, onUnmounted } from 'vue'
// 定义消息类型
interface ChatMessage {
id: string
content: string
userId: string
time: string
thumb: string
}
// 定义组件暴露的方法类型
interface NoticeListExpose {
simulateSendMessage: () => void
}
const isLoading = ref<boolean>(false)
let loadingTimer: any = null
const chatMessages = 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'
}
])
const handleSendMessage = (message: string): void => {
console.log('list发送消息:', message)
}
const simulateSendMessage = (): void => {
isLoading.value = true
loadingTimer = setTimeout(() => {
const newMessage: ChatMessage = {
id: Date.now().toString(),
content:
"Thanks for your message! I'm processing your request and will provide you with the best fashion advice.",
userId: '2',
time: new Date().toLocaleTimeString('en-US', { hour: '2-digit', minute: '2-digit' }),
thumb: 'https://files-dev.deercal.com/uploads/platforms/logo_code/669933e1b873e798.jpg'
}
chatMessages.value.push(newMessage)
isLoading.value = false
}, 3000)
}
</script>
<style lang="less" scoped>
.chat-list {
padding: 16px;
background-color: #fff;
height: 100%;
overflow-y: auto;
flex: 1;
}
.chat-message-item {
margin-bottom: 4.84rem;
}
</style>

View File

@@ -0,0 +1,98 @@
<template>
<div class="asistant-container flex flex-column">
<div class="header">
<HeaderTitle light hasSetting />
</div>
<div class="content flex-1" v-if="!isLoading">
<NoticeList ref="noticeListRef" @send-message="handleSendMessage" />
</div>
<div class="footer" v-if="!isLoading">
<InputArea @send-message="handleSendMessage" />
<div class="continue">
<button class="btn">Continue</button>
</div>
</div>
<!-- Loading状态时显示loading组件 -->
<div v-if="isLoading" class="loading-wrapper">
<ChatLoading />
</div>
</div>
</template>
<script setup lang="ts">
import HeaderTitle from '@/components/HeaderTitle.vue'
import NoticeList from './components/NoticeList.vue'
import InputArea from './components/InputArea.vue'
import ChatLoading from './components/ChatLoading.vue'
import { ref, onMounted } from 'vue'
// 定义NoticeList组件引用类型
interface NoticeListRef {
simulateSendMessage: () => void
}
const isLoading = ref<boolean>(false)
const noticeListRef = ref<NoticeListRef | null>(null)
onMounted(() => {
// handleSendMessage('123')
})
const handleSendMessage = (message: string): void => {
console.log('收到消息:', message)
// 显示loading状态
isLoading.value = true
// 模拟请求延迟
setTimeout(() => {
// 调用NoticeList的方法添加新消息
if (noticeListRef.value) {
noticeListRef.value.simulateSendMessage()
}
// 隐藏loading状态
isLoading.value = false
}, 10000) // 3秒后完成
}
</script>
<style lang="less" scoped>
.asistant-container {
height: 100vh;
overflow: hidden;
}
.header {
flex-shrink: 0;
}
.content {
overflow: hidden;
display: flex;
flex-direction: column;
}
.footer {
flex-shrink: 0;
.continue {
font-family: 'satoshiRegular';
font-size: 3.6rem;
color: #fff;
text-align: right;
padding: 2.6rem 4.5rem;
.btn {
border-radius: 7px;
background-color: #000;
width: 24.6rem;
height: 5.9rem;
}
}
}
.loading-wrapper {
flex: 1;
display: flex;
align-items: center;
justify-content: center;
background-color: #fff;
}
</style>

View File

@@ -46,7 +46,7 @@
</div>
<!-- 登录按钮 -->
<button type="submit" class="login-button">Log in</button>
<button type="submit" class="login-button">Sign Up</button>
<!-- Google登录按钮 -->
<div type="button" class="google-button" @click="handleGoogleLogin">

View File

@@ -0,0 +1,13 @@
<template>
<div class="container">
<router-view />
</div>
</template>
<style lang="less" scoped>
.container {
width: 100%;
height: 100%;
position: relative;
font-family: 'satoshiRegular';
}
</style>

View File

@@ -1,15 +1,41 @@
<template>
<div class="customer-container safe-area-top" :class="{'form-mode': pageMode === 'form'}">
<div class="customer-container safe-area-top" :class="{ 'form-mode': pageMode === 'form' }">
<template v-if="pageMode === 'entry'">
<div class="setting flex flex-between">
<van-icon name="arrow-left" color="#fff" size="70" />
<SvgIcon name="setting" color="#fff" size="70" style="width: 7rem" />
</div>
<div class="content flex flex-center flex-column">
<div class="text">Who is Your Customer?</div>
</div>
<div class="entry-btn flex flex-center" @click="handleChangeMode('form')">Entry</div>
</template>
<template v-else>
<div class="form-container">
<div class="back-container flex flex-center" @click="handleChangeMode('entry')">
<van-icon name="arrow-left" color="#fff" size="50" />
</div>
<div class="text">
<div class="form-title">Entry ID</div>
<div class="description">
Redefine the styling experience with AI.<br />
Use Styling Angel to speed up your fashion journey.
</div>
</div>
<div class="glass-form">
<div class="form-field">
<label class="field-label">Customer Name</label>
<input type="text" placeholder="Name" class="form-input" />
</div>
<div class="form-field email">
<label class="field-label">Customer Email</label>
<input type="email" placeholder="Email" class="form-input" />
</div>
<button class="confirm-btn" @click="handleConfirm">Confirm</button>
</div>
<div class="copyright">Powered by AiDLab for Lane Crawford</div>
</div>
</template>
</div>
</template>
<script setup lang="ts">
@@ -20,6 +46,10 @@ const pageMode = ref<PageMode>('entry')
const handleChangeMode = (mode: PageMode) => {
pageMode.value = mode
}
const handleConfirm = () => {
console.log('handleConfirm')
}
</script>
<style lang="less" scoped>
.customer-container {
@@ -31,9 +61,9 @@ const handleChangeMode = (mode: PageMode) => {
background-size: cover;
background-position: center;
background-repeat: no-repeat;
padding-top: 12.17rem;
&.form-mode {
background: url('@/assets/images/has_shouder_bg.png') no-repeat center center;
padding-top: 21.47rem;
}
.setting {
@@ -70,5 +100,110 @@ const handleChangeMode = (mode: PageMode) => {
line-height: 9rem;
font-size: 5.6rem;
}
.form-container {
.back-container {
width: 7.3rem;
height: 7.3rem;
border: 2px solid #fff;
border-radius: 1.8rem;
background: rgba(0, 0, 0, 0.2);
backdrop-filter: blur(20px);
-webkit-backdrop-filter: blur(20px);
margin-left: 7rem;
position: relative;
box-shadow: 0 4px 15px rgba(0, 0, 0, 0.1), inset 0 1px 0 #000000;
.back-icon {
width: 2.08rem;
height: 3.47rem;
}
}
.text {
padding-left: 15.2rem;
margin-top: 7.9rem;
letter-spacing: 0.02rem;
}
.form-title {
font-family: 'satoshiBold';
font-size: 11rem;
line-height: 1.24em;
}
.description {
font-size: 3rem;
line-height: 141%;
letter-spacing: 0.08rem;
margin-top: 2.7rem;
font-family: 'satoshiRegular';
}
.glass-form {
height: 84.8rem;
border: 2px solid #FFFFFF;
border-radius: 4.7rem;
background: rgba(115, 115, 115, 0.23);
backdrop-filter: blur(70px);
-webkit-backdrop-filter: blur(70px);
margin: 0 14.2rem;
padding: 8.2rem 7.9rem;
margin-top: 7.5rem;
box-shadow: 0 4px 15px rgba(0, 0, 0, 0.1), inset 0 1px 0 rgba(255, 255, 255, 0.1);
.form-field {
margin-bottom: 3.6rem;
&.email {
margin-bottom: 6.8rem;
}
.field-label {
display: block;
color: #fff;
font-size: 3.6rem;
font-family: 'satoshiRegular';
margin-bottom: 3rem;
}
.form-input {
width: 100%;
height: 10rem;
line-height: 10rem;
border: 2px solid #fff;
border-radius: 7rem;
padding: 0 5.5rem;
color: #fff;
font-size: 3.8rem;
font-family: 'satoshiRegular';
background: transparent;
&::placeholder {
color: rgba(255, 255, 255, 0.6);
}
}
}
.confirm-btn {
width: 100%;
height: 10rem;
line-height: 10rem;
background: #000;
border: none;
border-radius: 7rem;
color: #fff;
font-size: 4rem;
font-family: 'satoshiRegular';
cursor: pointer;
box-shadow: 0 2px 8px rgba(0, 0, 0, 0.2);
}
}
.copyright{
font-family: 'satoshiRegular';
font-size: 3rem;
line-height: 124%;
letter-spacing: 0.08rem;
margin-top: 2.7rem;
text-align: center;
font-weight: 400;
margin-top: 18.7rem;
}
}
}
</style>