|
@@ -32,46 +32,46 @@
|
|
|
<div class="mt-2 flex w-full items-center">
|
|
|
<div class="mx-auto" />
|
|
|
<audioCom class="mr-2" @onAudio="onAudio" />
|
|
|
- <template v-if="state.text">
|
|
|
- <template v-if="state.isWaiting">
|
|
|
- <el-tooltip content="等待回复中" placement="top">
|
|
|
- <div
|
|
|
- class="flex h-8 w-8 cursor-no-drop items-center justify-center rounded-sm bg-[var(--czr-main-color)] opacity-50"
|
|
|
- >
|
|
|
- <SvgIcon name="wait" color="#ffffff" size="20" />
|
|
|
- </div>
|
|
|
- </el-tooltip>
|
|
|
- </template>
|
|
|
- <template v-else-if="state.isStop">
|
|
|
- <el-tooltip content="停止生成" placement="top">
|
|
|
+ <template v-if="state.isWaiting">
|
|
|
+ <el-tooltip content="等待回复中" placement="top">
|
|
|
+ <div
|
|
|
+ class="flex h-8 w-8 cursor-no-drop items-center justify-center rounded-sm bg-[var(--czr-main-color)] opacity-50"
|
|
|
+ >
|
|
|
+ <SvgIcon name="wait" color="#ffffff" size="20" />
|
|
|
+ </div>
|
|
|
+ </el-tooltip>
|
|
|
+ </template>
|
|
|
+ <template v-else-if="state.isStop">
|
|
|
+ <el-tooltip content="停止生成" placement="top">
|
|
|
+ <div
|
|
|
+ class="__hover flex h-8 w-8 items-center justify-center rounded-sm bg-[var(--czr-main-color)]"
|
|
|
+ @click="onStop()"
|
|
|
+ >
|
|
|
+ <div class="h-3 w-3 bg-[#ffffff]" />
|
|
|
+ </div>
|
|
|
+ </el-tooltip>
|
|
|
+ </template>
|
|
|
+ <template v-else>
|
|
|
+ <template v-if="state.text">
|
|
|
+ <el-tooltip content="发送" placement="top">
|
|
|
<div
|
|
|
class="__hover flex h-8 w-8 items-center justify-center rounded-sm bg-[var(--czr-main-color)]"
|
|
|
- @click="onStop()"
|
|
|
+ @click="onSend()"
|
|
|
>
|
|
|
- <div class="h-3 w-3 bg-[#ffffff]" />
|
|
|
+ <img src="@/assets/images/chat/send.png" />
|
|
|
</div>
|
|
|
</el-tooltip>
|
|
|
</template>
|
|
|
<template v-else>
|
|
|
- <el-tooltip content="发送" placement="top">
|
|
|
+ <el-tooltip content="请输入问题" placement="top">
|
|
|
<div
|
|
|
- class="__hover flex h-8 w-8 items-center justify-center rounded-sm bg-[var(--czr-main-color)]"
|
|
|
- @click="onSend()"
|
|
|
+ class="flex h-8 w-8 cursor-no-drop items-center justify-center rounded-sm bg-[var(--czr-main-color)] opacity-50"
|
|
|
>
|
|
|
<img src="@/assets/images/chat/send.png" />
|
|
|
</div>
|
|
|
</el-tooltip>
|
|
|
</template>
|
|
|
</template>
|
|
|
- <template v-else>
|
|
|
- <el-tooltip content="请输入问题" placement="top">
|
|
|
- <div
|
|
|
- class="flex h-8 w-8 cursor-no-drop items-center justify-center rounded-sm bg-[var(--czr-main-color)] opacity-50"
|
|
|
- >
|
|
|
- <img src="@/assets/images/chat/send.png" />
|
|
|
- </div>
|
|
|
- </el-tooltip>
|
|
|
- </template>
|
|
|
</div>
|
|
|
</div>
|
|
|
</div>
|
|
@@ -85,6 +85,7 @@ import audioCom from './audio/index.vue'
|
|
|
import { AnswerStruct } from '@/types/chat'
|
|
|
import { isValue } from '@/utils/czr-util'
|
|
|
import { ElMessage } from 'element-plus'
|
|
|
+import { chatMessage } from '@/views/chat/chat'
|
|
|
|
|
|
const state: any = reactive({
|
|
|
text: '',
|
|
@@ -94,7 +95,7 @@ const state: any = reactive({
|
|
|
query: '',
|
|
|
},
|
|
|
isWaiting: false,
|
|
|
- isStop: true,
|
|
|
+ isStop: false,
|
|
|
})
|
|
|
const ref_text = ref()
|
|
|
const ref_chatMsg = ref()
|
|
@@ -199,7 +200,7 @@ const scrollToEnd = () => {
|
|
|
}
|
|
|
const onSend = (text = '') => {
|
|
|
if ((isValue(state.text.trim()) || text) && !state.loading) {
|
|
|
- if (state.isWaiting) {
|
|
|
+ if (state.isWaiting || state.isStop) {
|
|
|
ElMessage({
|
|
|
message: '问题回复中,请稍后提问!',
|
|
|
grouping: true,
|
|
@@ -227,6 +228,20 @@ const onSend = (text = '') => {
|
|
|
scrollToEnd()
|
|
|
state.isWaiting = true
|
|
|
state.isStop = true
|
|
|
+ chatMessage(state.params, {
|
|
|
+ onData: (text, data) => {
|
|
|
+ console.log(text, data)
|
|
|
+ state.isWaiting = false
|
|
|
+ // answer.messageId = messageId
|
|
|
+ // answer.taskId = taskId
|
|
|
+ answer.loading = false
|
|
|
+ answer.text += text
|
|
|
+ scrollToEnd()
|
|
|
+ },
|
|
|
+ onMessageEnd: (data) => {
|
|
|
+ state.isStop = false
|
|
|
+ },
|
|
|
+ })
|
|
|
}
|
|
|
}
|
|
|
const onStop = () => {}
|