|
@@ -69,9 +69,9 @@ const messages = ref<MessageItem[]>([
|
|
|
}
|
|
}
|
|
|
])
|
|
])
|
|
|
messages.value = JSON.parse(sessionStorage.getItem('AIChat')) || messages.value
|
|
messages.value = JSON.parse(sessionStorage.getItem('AIChat')) || messages.value
|
|
|
-onMounted(() => {
|
|
|
|
|
|
|
+const handleOpen = () => {
|
|
|
scrollToBottom()
|
|
scrollToBottom()
|
|
|
-})
|
|
|
|
|
|
|
+}
|
|
|
|
|
|
|
|
watch(
|
|
watch(
|
|
|
() => messages.value,
|
|
() => messages.value,
|
|
@@ -121,15 +121,17 @@ const parseHtmlString = (data) => {
|
|
|
|
|
|
|
|
const progressInterval = ref()
|
|
const progressInterval = ref()
|
|
|
const serial_no = ref()
|
|
const serial_no = ref()
|
|
|
|
|
+const is_FixedAnswer = ref(true) // 是否为预设问题 true是自由问题 false是预设问题
|
|
|
const aiChat = (question, isPresetQuestion) => {
|
|
const aiChat = (question, isPresetQuestion) => {
|
|
|
serial_no.value = userStore.userInfo?.uname + Date.now().toString()
|
|
serial_no.value = userStore.userInfo?.uname + Date.now().toString()
|
|
|
$api
|
|
$api
|
|
|
.aiChat({
|
|
.aiChat({
|
|
|
serial_no: serial_no.value,
|
|
serial_no: serial_no.value,
|
|
|
prompt: sessionStorage.getItem('prompt'),
|
|
prompt: sessionStorage.getItem('prompt'),
|
|
|
- // question_type: isPresetQuestion ? 'Predefined Question' : 'Free Question',
|
|
|
|
|
|
|
+ // question_type: isPresetQuestion || !is_FixedAnswer ? 'Predefined Question' : 'Free Question',
|
|
|
question_type: 'Free Question',
|
|
question_type: 'Free Question',
|
|
|
- question_content: question
|
|
|
|
|
|
|
+ question_content: question,
|
|
|
|
|
+ fixed_faq: !is_FixedAnswer ? messages.value[messages.value.length - 2].content : ''
|
|
|
})
|
|
})
|
|
|
.then((res) => {
|
|
.then((res) => {
|
|
|
if (isPause.value) {
|
|
if (isPause.value) {
|
|
@@ -250,6 +252,7 @@ const handlePause = () => {
|
|
|
.then((res) => {
|
|
.then((res) => {
|
|
|
if (res.code === 200) {
|
|
if (res.code === 200) {
|
|
|
clearInterval(progressInterval.value)
|
|
clearInterval(progressInterval.value)
|
|
|
|
|
+ is_FixedAnswer.value = true
|
|
|
queryTime.value = -1
|
|
queryTime.value = -1
|
|
|
messages.value[messages.value.length - 1].isCancel = true
|
|
messages.value[messages.value.length - 1].isCancel = true
|
|
|
messages.value[messages.value.length - 1].content = progressStatus.cancel
|
|
messages.value[messages.value.length - 1].content = progressStatus.cancel
|
|
@@ -279,12 +282,13 @@ const handleFeedback = (index, feedback) => {
|
|
|
const emit = defineEmits(['close'])
|
|
const emit = defineEmits(['close'])
|
|
|
// 关闭聊天窗口
|
|
// 关闭聊天窗口
|
|
|
const handleClose = () => {
|
|
const handleClose = () => {
|
|
|
- progressInterval.value && clearInterval(progressInterval.value)
|
|
|
|
|
|
|
+ // progressInterval.value && clearInterval(progressInterval.value)
|
|
|
emit('close')
|
|
emit('close')
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
defineExpose({
|
|
defineExpose({
|
|
|
- handleSend
|
|
|
|
|
|
|
+ handleSend,
|
|
|
|
|
+ handleOpen
|
|
|
})
|
|
})
|
|
|
</script>
|
|
</script>
|
|
|
|
|
|