mirror of
https://github.com/1Panel-dev/MaxKB.git
synced 2025-12-26 01:33:05 +00:00
This commit is contained in:
parent
f646102262
commit
6fe001fcf8
|
|
@ -80,7 +80,7 @@ const props = defineProps<{
|
|||
chatRecord: chatType
|
||||
application: any
|
||||
loading: boolean
|
||||
sendMessage: (question: string, other_params_data?: any, chat?: chatType) => void
|
||||
sendMessage: (question: string, other_params_data?: any, chat?: chatType) => Promise<boolean>
|
||||
chatManagement: any
|
||||
type: 'log' | 'ai-chat' | 'debug-ai-chat'
|
||||
}>()
|
||||
|
|
@ -98,9 +98,10 @@ const showUserAvatar = computed(() => {
|
|||
const chatMessage = (question: string, type: 'old' | 'new', other_params_data?: any) => {
|
||||
if (type === 'old') {
|
||||
add_answer_text_list(props.chatRecord.answer_text_list)
|
||||
props.sendMessage(question, other_params_data, props.chatRecord)
|
||||
props.chatManagement.open(props.chatRecord.id)
|
||||
props.chatManagement.write(props.chatRecord.id)
|
||||
props.sendMessage(question, other_params_data, props.chatRecord).then(() => {
|
||||
props.chatManagement.open(props.chatRecord.id)
|
||||
props.chatManagement.write(props.chatRecord.id)
|
||||
})
|
||||
} else {
|
||||
props.sendMessage(question, other_params_data)
|
||||
}
|
||||
|
|
|
|||
|
|
@ -224,33 +224,41 @@ const validate = () => {
|
|||
return userFormRef.value?.validate() || Promise.reject(false)
|
||||
}
|
||||
|
||||
function sendMessage(val: string, other_params_data?: any, chat?: chatType) {
|
||||
function sendMessage(val: string, other_params_data?: any, chat?: chatType): Promise<boolean> {
|
||||
if (isUserInput.value) {
|
||||
userFormRef.value
|
||||
?.validate()
|
||||
.then((ok) => {
|
||||
let userFormData = JSON.parse(localStorage.getItem(`${accessToken}userForm`) || '{}')
|
||||
const newData = Object.keys(form_data.value).reduce((result: any, key: string) => {
|
||||
result[key] = Object.prototype.hasOwnProperty.call(userFormData, key)
|
||||
? userFormData[key]
|
||||
: form_data.value[key]
|
||||
return result
|
||||
}, {})
|
||||
localStorage.setItem(`${accessToken}userForm`, JSON.stringify(newData))
|
||||
showUserInput.value = false
|
||||
if (!loading.value && props.applicationDetails?.name) {
|
||||
handleDebounceClick(val, other_params_data, chat)
|
||||
}
|
||||
})
|
||||
.catch((e) => {
|
||||
showUserInput.value = true
|
||||
return
|
||||
})
|
||||
if (userFormRef.value) {
|
||||
return userFormRef.value
|
||||
?.validate()
|
||||
.then((ok) => {
|
||||
let userFormData = JSON.parse(localStorage.getItem(`${accessToken}userForm`) || '{}')
|
||||
const newData = Object.keys(form_data.value).reduce((result: any, key: string) => {
|
||||
result[key] = Object.prototype.hasOwnProperty.call(userFormData, key)
|
||||
? userFormData[key]
|
||||
: form_data.value[key]
|
||||
return result
|
||||
}, {})
|
||||
localStorage.setItem(`${accessToken}userForm`, JSON.stringify(newData))
|
||||
showUserInput.value = false
|
||||
if (!loading.value && props.applicationDetails?.name) {
|
||||
handleDebounceClick(val, other_params_data, chat)
|
||||
return true
|
||||
}
|
||||
throw 'err: no send'
|
||||
})
|
||||
.catch((e) => {
|
||||
showUserInput.value = true
|
||||
return false
|
||||
})
|
||||
} else {
|
||||
return Promise.reject(false)
|
||||
}
|
||||
} else {
|
||||
showUserInput.value = false
|
||||
if (!loading.value && props.applicationDetails?.name) {
|
||||
handleDebounceClick(val, other_params_data, chat)
|
||||
return Promise.resolve(true)
|
||||
}
|
||||
return Promise.reject(false)
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Reference in New Issue