refactor: Dialogue logic optimization (#2776)
This commit is contained in:
parent
44c1d35b1f
commit
bd900118f4
@ -268,15 +268,17 @@ const props = withDefaults(
|
|||||||
isMobile: boolean
|
isMobile: boolean
|
||||||
appId?: string
|
appId?: string
|
||||||
chatId: string
|
chatId: string
|
||||||
|
showUserInput?: boolean
|
||||||
sendMessage: (question: string, other_params_data?: any, chat?: chatType) => void
|
sendMessage: (question: string, other_params_data?: any, chat?: chatType) => void
|
||||||
openChatId: () => Promise<string>
|
openChatId: () => Promise<string>
|
||||||
|
checkInputParam: () => boolean
|
||||||
}>(),
|
}>(),
|
||||||
{
|
{
|
||||||
applicationDetails: () => ({}),
|
applicationDetails: () => ({}),
|
||||||
available: true
|
available: true
|
||||||
}
|
}
|
||||||
)
|
)
|
||||||
const emit = defineEmits(['update:chatId', 'update:loading'])
|
const emit = defineEmits(['update:chatId', 'update:loading', 'update:showUserInput'])
|
||||||
const chartOpenId = ref<string>()
|
const chartOpenId = ref<string>()
|
||||||
const chatId_context = computed({
|
const chatId_context = computed({
|
||||||
get: () => {
|
get: () => {
|
||||||
|
|||||||
@ -83,6 +83,9 @@ const inputFieldConfig = ref({ title: t('chat.userInput') })
|
|||||||
const showUserInput = ref(true)
|
const showUserInput = ref(true)
|
||||||
const firstMounted = ref(false)
|
const firstMounted = ref(false)
|
||||||
|
|
||||||
|
const dynamicsFormRef = ref<InstanceType<typeof DynamicsForm>>()
|
||||||
|
const dynamicsFormRef2 = ref<InstanceType<typeof DynamicsForm>>()
|
||||||
|
|
||||||
const emit = defineEmits(['update:api_form_data', 'update:form_data', 'confirm', 'cancel'])
|
const emit = defineEmits(['update:api_form_data', 'update:form_data', 'confirm', 'cancel'])
|
||||||
|
|
||||||
const api_form_data_context = computed({
|
const api_form_data_context = computed({
|
||||||
@ -365,7 +368,18 @@ const confirmHandle = () => {
|
|||||||
const cancelHandle = () => {
|
const cancelHandle = () => {
|
||||||
emit('cancel')
|
emit('cancel')
|
||||||
}
|
}
|
||||||
defineExpose({ checkInputParam })
|
const render = (data: any) => {
|
||||||
|
if (dynamicsFormRef.value) {
|
||||||
|
dynamicsFormRef.value?.render(inputFieldList.value, data)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
const renderDebugAiChat = (data: any) => {
|
||||||
|
if (dynamicsFormRef2.value) {
|
||||||
|
dynamicsFormRef2.value?.render(apiInputFieldList.value, data)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
defineExpose({ checkInputParam, render, renderDebugAiChat })
|
||||||
onMounted(() => {
|
onMounted(() => {
|
||||||
firstMounted.value = true
|
firstMounted.value = true
|
||||||
handleInputFieldList()
|
handleInputFieldList()
|
||||||
|
|||||||
@ -5,7 +5,10 @@
|
|||||||
:class="type"
|
:class="type"
|
||||||
:style="{ height: firsUserInput ? '100%' : undefined }"
|
:style="{ height: firsUserInput ? '100%' : undefined }"
|
||||||
>
|
>
|
||||||
<div v-show="showUserInputContent" :class="firsUserInput ? 'firstUserInput' : 'popperUserInput'">
|
<div
|
||||||
|
v-show="showUserInputContent"
|
||||||
|
:class="firsUserInput ? 'firstUserInput' : 'popperUserInput'"
|
||||||
|
>
|
||||||
<UserForm
|
<UserForm
|
||||||
v-model:api_form_data="api_form_data"
|
v-model:api_form_data="api_form_data"
|
||||||
v-model:form_data="form_data"
|
v-model:form_data="form_data"
|
||||||
@ -60,9 +63,11 @@
|
|||||||
:type="type"
|
:type="type"
|
||||||
:send-message="sendMessage"
|
:send-message="sendMessage"
|
||||||
:open-chat-id="openChatId"
|
:open-chat-id="openChatId"
|
||||||
|
:check-input-param="checkInputParam"
|
||||||
:chat-management="ChatManagement"
|
:chat-management="ChatManagement"
|
||||||
v-model:chat-id="chartOpenId"
|
v-model:chat-id="chartOpenId"
|
||||||
v-model:loading="loading"
|
v-model:loading="loading"
|
||||||
|
v-model:show-user-input="showUserInput"
|
||||||
v-if="type !== 'log'"
|
v-if="type !== 'log'"
|
||||||
>
|
>
|
||||||
<template #operateBefore>
|
<template #operateBefore>
|
||||||
@ -210,6 +215,9 @@ function UserFormCancel() {
|
|||||||
// api_form_data.value = JSON.parse(JSON.stringify(initialApiFormData.value))
|
// api_form_data.value = JSON.parse(JSON.stringify(initialApiFormData.value))
|
||||||
showUserInput.value = false
|
showUserInput.value = false
|
||||||
}
|
}
|
||||||
|
const checkInputParam = () => {
|
||||||
|
userFormRef.value?.checkInputParam()
|
||||||
|
}
|
||||||
|
|
||||||
function sendMessage(val: string, other_params_data?: any, chat?: chatType) {
|
function sendMessage(val: string, other_params_data?: any, chat?: chatType) {
|
||||||
if (!userFormRef.value?.checkInputParam()) {
|
if (!userFormRef.value?.checkInputParam()) {
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user