【增加】AI Chat 应道页面

This commit is contained in:
cherishsince 2024-05-17 17:07:57 +08:00
parent 48b3b08f0a
commit fc31528367
2 changed files with 93 additions and 4 deletions

View File

@ -0,0 +1,84 @@
<template>
<div class="chat-empty">
<!-- title -->
<div class="center-container">
<div class="title">芋艿 AI</div>
<div class="role-list">
<div class="role-item" v-for="prompt in promptList" :key="prompt.prompt" @click="handlerPromptClick(prompt)">
{{prompt.prompt}}
</div>
</div>
</div>
</div>
</template>
<script setup lang="ts">
const router = useRouter()
const promptList = ref<any[]>() //
promptList.value = [
{
"prompt": "今天天气怎么样?",
},
{
"prompt": "写一首好听的诗歌?",
}
]
const emits = defineEmits(['onPrompt'])
const handlerPromptClick = async ({ prompt }) => {
emits('onPrompt', prompt)
}
onMounted(async () => {
})
</script>
<style scoped lang="scss">
.chat-empty {
position: relative;
display: flex;
flex-direction: row;
justify-content: center;
width: 100%;
height: 100%;
.center-container {
display: flex;
flex-direction: column;
justify-content: center;
.title {
font-size: 28px;
font-weight: bold;
text-align: center;
}
.role-list {
display: flex;
flex-direction: row;
flex-wrap: wrap;
align-items: center;
justify-content: center;
width: 460px;
margin-top: 20px;
.role-item {
display: flex;
justify-content: center;
width: 180px;
line-height: 50px;
border: 1px solid #e4e4e4;
border-radius: 10px;
margin: 10px;
cursor: pointer;
}
.role-item:hover {
background-color: rgba(243, 243, 243, 0.73);
}
}
}
}
</style>

View File

@ -34,9 +34,12 @@
<!-- main --> <!-- main -->
<el-main class="main-container"> <el-main class="main-container">
<div class="message-container" > <div class="message-container" >
<Message ref="messageRef" :list="list" @onDeleteSuccess="handlerMessageDelete" /> <Message v-if="list.length > 0" ref="messageRef" :list="list" @on-delete-success="handlerMessageDelete" />
<ChatEmpty v-if="list.length === 0" @on-prompt="onSend"/>
</div> </div>
</el-main> </el-main>
<!-- 底部 -->
<el-footer class="footer-container"> <el-footer class="footer-container">
<form @submit.prevent="onSend" class="prompt-from"> <form @submit.prevent="onSend" class="prompt-from">
<textarea <textarea
@ -84,10 +87,12 @@
<script setup lang="ts"> <script setup lang="ts">
import Conversation from './Conversation.vue' import Conversation from './Conversation.vue'
import Message from './Message.vue' import Message from './Message.vue'
import ChatEmpty from './ChatEmpty.vue'
import {ChatMessageApi, ChatMessageVO} from '@/api/ai/chat/message' import {ChatMessageApi, ChatMessageVO} from '@/api/ai/chat/message'
import {ChatConversationApi, ChatConversationVO} from '@/api/ai/chat/conversation' import {ChatConversationApi, ChatConversationVO} from '@/api/ai/chat/conversation'
import {useClipboard} from '@vueuse/core' import {useClipboard} from '@vueuse/core'
import ChatConversationUpdateForm from "@/views/ai/chat/components/ChatConversationUpdateForm.vue"; import ChatConversationUpdateForm from "@/views/ai/chat/components/ChatConversationUpdateForm.vue";
import {send} from "vite";
const route = useRoute() // const route = useRoute() //
const message = useMessage() // const message = useMessage() //
@ -153,7 +158,7 @@ const onPromptInput = (event) => {
/** /**
* 发送消息 * 发送消息
*/ */
const onSend = async () => { const onSend = async (val?: string) => {
// //
if (isComposing.value) { if (isComposing.value) {
return return
@ -162,7 +167,7 @@ const onSend = async () => {
if (conversationInProgress.value) { if (conversationInProgress.value) {
return return
} }
const content = prompt.value?.trim() + '' const content = (val ? val : prompt.value?.trim()) as string
if (content.length < 2) { if (content.length < 2) {
ElMessage({ ElMessage({
message: '请输入内容!', message: '请输入内容!',