You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
139 lines
3.5 KiB
139 lines
3.5 KiB
1 year ago
|
<script setup lang="ts">
|
||
|
import { onMounted, ref } from 'vue'
|
||
|
import type { MessageItem } from './index.d'
|
||
|
import { MessageStatusEnum, MessageTypeEnum } from '@/enums/messageEnum'
|
||
|
|
||
|
defineProps<{
|
||
|
list: MessageItem[]
|
||
|
}>()
|
||
|
|
||
|
const messageRef = ref<Element | null>(null)
|
||
|
|
||
|
onMounted(async () => {
|
||
|
|
||
|
})
|
||
|
</script>
|
||
|
|
||
|
<template>
|
||
|
<div ref="messageRef" class="app-message">
|
||
|
<div class="content-wrap">
|
||
|
<div v-for="(item, index) in list" :key="item.time + index" class="item">
|
||
|
<div v-if="item.messageType === MessageTypeEnum.USER" class="user">
|
||
|
<div class="content">
|
||
|
{{ item.content }}
|
||
|
</div>
|
||
|
<img class="icon-user" src="@/assets/images/conversation/user.png" alt="">
|
||
|
</div>
|
||
|
<div v-if="item.messageType === MessageTypeEnum.AI" class="ai">
|
||
|
<img class="icon-ai" src="@/assets/images/conversation/logo.png" alt="">
|
||
|
<div class="content">
|
||
|
{{ item.content }}
|
||
|
</div>
|
||
|
<div v-if="item.messageStatus === MessageStatusEnum.ERROR" class="error">
|
||
|
哎呀,出问题了...
|
||
|
</div>
|
||
|
<div
|
||
|
v-if="item.messageStatus === MessageStatusEnum.ACTICON"
|
||
|
class="loading"
|
||
|
>
|
||
|
正在回答中...
|
||
|
</div>
|
||
|
<div v-if="item.messageStatus === MessageStatusEnum.END" class="btns">
|
||
|
<div class="copy" @click="copyText(item.content)">
|
||
|
复制
|
||
|
</div>
|
||
|
<div v-if="index === 0" class="reload" @click="reloadMessage">
|
||
|
重新回答
|
||
|
</div>
|
||
|
</div>
|
||
|
</div>
|
||
|
</div>
|
||
|
</div>
|
||
|
</div>
|
||
|
</template>
|
||
|
|
||
|
<style lang="scss" scoped>
|
||
|
@include app('message') {
|
||
|
height: calc(100% - 120px);
|
||
|
overflow: auto;
|
||
|
|
||
|
.content-wrap {
|
||
|
box-sizing: border-box;
|
||
|
transform: rotate(180deg);
|
||
|
.item {
|
||
|
padding: 0 15px;
|
||
|
margin-top: 15px;
|
||
|
transform: rotate(180deg);
|
||
|
.user,
|
||
|
.ai {
|
||
|
display: flex;
|
||
|
}
|
||
|
.user {
|
||
|
justify-content: flex-end;
|
||
|
.content {
|
||
|
color: #ffffff;
|
||
|
padding: 10px 15px;
|
||
|
background: linear-gradient(131deg, #009bfc 0%, #00eadb 100%);
|
||
|
border-radius: 15px 15px 0px 15px;
|
||
|
}
|
||
|
.icon-user {
|
||
|
width: 40px;
|
||
|
height: 40px;
|
||
|
margin-left: 15px;
|
||
|
}
|
||
|
}
|
||
|
.ai {
|
||
|
position: relative;
|
||
|
margin-bottom: 15px;
|
||
|
display: flex;
|
||
|
flex-wrap: wrap;
|
||
|
.icon-ai {
|
||
|
width: 40px;
|
||
|
height: 40px;
|
||
|
margin-right: 15px;
|
||
|
}
|
||
|
.content {
|
||
|
width: calc(100% - 55px);
|
||
|
padding: 10px 15px;
|
||
|
background: #ffffff;
|
||
|
border-radius: 0rpx 15px 15px 15px;
|
||
|
border: 1px solid #e7edef;
|
||
|
}
|
||
|
.error {
|
||
|
color: red;
|
||
|
height: 30px;
|
||
|
padding-left: 60px;
|
||
|
margin: 10px auto 0 auto;
|
||
|
}
|
||
|
.loading {
|
||
|
height: 30px;
|
||
|
color: #009dfb;
|
||
|
padding-left: 60px;
|
||
|
margin: 20rpx auto 0 auto;
|
||
|
}
|
||
|
.btns {
|
||
|
width: 100%;
|
||
|
height: 30px;
|
||
|
padding-left: 60px;
|
||
|
margin: 10px auto 0 auto;
|
||
|
display: flex;
|
||
|
justify-content: space-between;
|
||
|
align-items: center;
|
||
|
.copy {
|
||
|
color: #009dfb;
|
||
|
padding: 5px 15px;
|
||
|
background: #c1effb;
|
||
|
border-radius: 15px;
|
||
|
text-align: center;
|
||
|
margin-right: 20px;
|
||
|
}
|
||
|
.reload {
|
||
|
color: #009dfb;
|
||
|
}
|
||
|
}
|
||
|
}
|
||
|
}
|
||
|
}
|
||
|
}
|
||
|
</style>
|