重构首页
This commit is contained in:
141
src/views/home/components/ChatList.vue
Normal file
141
src/views/home/components/ChatList.vue
Normal file
@@ -0,0 +1,141 @@
|
||||
<template>
|
||||
<div class="chat-list">
|
||||
<div class="chat-divider">今天 15:14</div>
|
||||
|
||||
<div v-for="msg in messages" :key="msg.id" class="message-row" :class="{ 'is-user': msg.isUser }">
|
||||
<div v-if="!msg.isUser" class="avatar-wrap">
|
||||
<div class="ai-avatar">AI</div>
|
||||
</div>
|
||||
|
||||
<div class="bubble-wrap">
|
||||
<div class="bubble">{{ msg.content }}</div>
|
||||
<div class="time">{{ msg.time }}</div>
|
||||
</div>
|
||||
|
||||
<div v-if="msg.isUser" class="avatar-wrap">
|
||||
<el-avatar :size="28" src="https://cube.elemecdn.com/0/88/03b0d39583f48206768a7534e55bcpng.png" />
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<script setup lang="ts">
|
||||
import { ref } from 'vue';
|
||||
|
||||
interface Message {
|
||||
id: number;
|
||||
content: string;
|
||||
time: string;
|
||||
isUser: boolean;
|
||||
}
|
||||
|
||||
const messages = ref<Message[]>([
|
||||
{
|
||||
id: 1,
|
||||
content: '你好!我叫知子,很高兴为您服务。您今天想聊些什么呢?',
|
||||
time: '09:30',
|
||||
isUser: false,
|
||||
},
|
||||
{
|
||||
id: 2,
|
||||
content: '你好!我想了解下这个系统都能做什么。',
|
||||
time: '09:31',
|
||||
isUser: true,
|
||||
},
|
||||
{
|
||||
id: 3,
|
||||
content: '当然可以,这个系统提供了多种功能:日记、文件、快捷指令、快捷回复,以及技能管理和模型管理入口。你想先看哪一块?',
|
||||
time: '09:31',
|
||||
isUser: false,
|
||||
},
|
||||
]);
|
||||
</script>
|
||||
|
||||
<style scoped lang="scss">
|
||||
.chat-list {
|
||||
height: 100%;
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
justify-content: flex-start;
|
||||
gap: 16px;
|
||||
padding: 28px 0 10px;
|
||||
}
|
||||
|
||||
.chat-divider {
|
||||
align-self: center;
|
||||
font-size: 12px;
|
||||
color: #8b95a7;
|
||||
line-height: 1;
|
||||
padding: 0 12px;
|
||||
letter-spacing: 0.2px;
|
||||
}
|
||||
|
||||
.message-row {
|
||||
display: flex;
|
||||
align-items: flex-end;
|
||||
gap: 10px;
|
||||
max-width: 100%;
|
||||
|
||||
&.is-user {
|
||||
justify-content: flex-end;
|
||||
}
|
||||
}
|
||||
|
||||
.avatar-wrap {
|
||||
width: 30px;
|
||||
height: 30px;
|
||||
flex-shrink: 0;
|
||||
}
|
||||
|
||||
.ai-avatar {
|
||||
width: 30px;
|
||||
height: 30px;
|
||||
border-radius: 50%;
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
font-size: 11px;
|
||||
font-weight: 700;
|
||||
color: #53607a;
|
||||
background: linear-gradient(145deg, #f7f9fc 0%, #e9eef6 100%);
|
||||
border: 1px solid #dfe6f0;
|
||||
box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.75);
|
||||
}
|
||||
|
||||
.bubble-wrap {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
gap: 5px;
|
||||
max-width: min(84%, 1120px);
|
||||
}
|
||||
|
||||
.bubble {
|
||||
font-size: 14px;
|
||||
line-height: 1.75;
|
||||
padding: 12px 14px;
|
||||
border-radius: 12px;
|
||||
word-break: break-word;
|
||||
color: #1f2937;
|
||||
background: rgba(255, 255, 255, 0.84);
|
||||
border: 1px solid rgba(226, 233, 244, 0.95);
|
||||
backdrop-filter: blur(8px);
|
||||
box-shadow: 0 6px 18px rgba(15, 23, 42, 0.06);
|
||||
|
||||
.message-row.is-user & {
|
||||
background: linear-gradient(135deg, #58a6ff 0%, #3b82f6 52%, #2563eb 100%);
|
||||
border-color: rgba(59, 130, 246, 0.32);
|
||||
color: #fff;
|
||||
box-shadow: 0 8px 20px rgba(37, 99, 235, 0.33);
|
||||
}
|
||||
}
|
||||
|
||||
.time {
|
||||
font-size: 11px;
|
||||
color: #8f9aae;
|
||||
padding: 0 4px;
|
||||
|
||||
.message-row.is-user & {
|
||||
text-align: right;
|
||||
}
|
||||
}
|
||||
</style>
|
||||
Reference in New Issue
Block a user