|
@@ -1,9 +1,60 @@
|
|
|
-<script setup lang="ts"></script>
|
|
|
+<script setup lang="ts">
|
|
|
+import AChat from '@/views/OaSystem/aiQA/components/AChat.vue'
|
|
|
+import ExampleChat from '@/views/OaSystem/aiQA/components/ExampleChat.vue'
|
|
|
+import sendImg from '@/assets/imgs/ai/send.png'
|
|
|
+import QChat from '@/views/OaSystem/aiQA/components/QChat.vue'
|
|
|
+
|
|
|
+interface ChatContentProps {
|
|
|
+ currentQuestion: string
|
|
|
+ changeQuestion: (q: string) => void
|
|
|
+}
|
|
|
+
|
|
|
+const props = defineProps<ChatContentProps>()
|
|
|
+const { currentQuestion } = toRefs(props)
|
|
|
+const { changeQuestion } = props
|
|
|
+
|
|
|
+const textarea = ref('')
|
|
|
+
|
|
|
+const handleClear = () => {
|
|
|
+ changeQuestion('')
|
|
|
+}
|
|
|
+
|
|
|
+const handleSend = () => {
|
|
|
+ changeQuestion(textarea.value)
|
|
|
+ textarea.value = ''
|
|
|
+}
|
|
|
+</script>
|
|
|
|
|
|
<template>
|
|
|
<div class="chat-content">
|
|
|
- <div class="message-body"></div>
|
|
|
- <div class="input-body"></div>
|
|
|
+ <div class="message-body">
|
|
|
+ <template v-if="currentQuestion">
|
|
|
+ <QChat>{{ currentQuestion }}</QChat>
|
|
|
+ <AChat> 生成中 </AChat>
|
|
|
+ </template>
|
|
|
+ <template v-else>
|
|
|
+ <!-- 引导对话 -->
|
|
|
+ <AChat>
|
|
|
+ <ExampleChat />
|
|
|
+ </AChat>
|
|
|
+ </template>
|
|
|
+ </div>
|
|
|
+ <div class="input-body">
|
|
|
+ <div class="input-header">
|
|
|
+ <div class="clear-btn" @click="handleClear"> 清空对话</div>
|
|
|
+ </div>
|
|
|
+ <el-input
|
|
|
+ class="input"
|
|
|
+ v-model="textarea"
|
|
|
+ :autosize="{ minRows: 4, maxRows: 20 }"
|
|
|
+ type="textarea"
|
|
|
+ resize="none"
|
|
|
+ placeholder="请输入问题,可以通过回车换行"
|
|
|
+ />
|
|
|
+ <div class="q-btn" @click="handleSend">
|
|
|
+ <img :src="sendImg" alt="发送" />
|
|
|
+ </div>
|
|
|
+ </div>
|
|
|
</div>
|
|
|
</template>
|
|
|
|
|
@@ -12,15 +63,68 @@
|
|
|
width: 100%;
|
|
|
height: 100%;
|
|
|
padding: 25px 50px;
|
|
|
+ display: flex;
|
|
|
+ flex-flow: column;
|
|
|
|
|
|
.message-body {
|
|
|
+ flex-grow: 1;
|
|
|
+ overflow-y: auto;
|
|
|
}
|
|
|
|
|
|
.input-body {
|
|
|
+ position: relative;
|
|
|
+ padding: 15px 20px;
|
|
|
+ min-height: 120px;
|
|
|
+ flex-shrink: 0;
|
|
|
+ margin-top: 20px;
|
|
|
width: calc(100% - 50px);
|
|
|
margin-left: 50px;
|
|
|
background: #f4f7fd;
|
|
|
border-radius: 8px 8px 8px 8px;
|
|
|
+ display: flex;
|
|
|
+
|
|
|
+ .input-header {
|
|
|
+ position: absolute;
|
|
|
+ top: -30px;
|
|
|
+ width: calc(100% - 50px);
|
|
|
+ display: flex;
|
|
|
+ justify-content: flex-end;
|
|
|
+
|
|
|
+ .clear-btn {
|
|
|
+ cursor: pointer;
|
|
|
+ font-size: 16px;
|
|
|
+ color: #8a94a4;
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ .input {
|
|
|
+ width: calc(100% - 80px);
|
|
|
+
|
|
|
+ :deep(.el-textarea__inner) {
|
|
|
+ border: none !important;
|
|
|
+ box-shadow: none !important;
|
|
|
+ background: transparent;
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ .q-btn {
|
|
|
+ width: 76px;
|
|
|
+ height: 48px;
|
|
|
+ background: #2e77e6;
|
|
|
+ border-radius: 30px 30px 30px 30px;
|
|
|
+ overflow: hidden;
|
|
|
+ cursor: pointer;
|
|
|
+ align-self: flex-end;
|
|
|
+
|
|
|
+ img {
|
|
|
+ width: 100%;
|
|
|
+ height: 100%;
|
|
|
+ }
|
|
|
+
|
|
|
+ &:hover {
|
|
|
+ opacity: 0.9;
|
|
|
+ }
|
|
|
+ }
|
|
|
}
|
|
|
}
|
|
|
</style>
|