refactor: Dialogue logic optimization (#2776)

This commit is contained in:
shaohuzhang1 2025-04-02 15:51:15 +08:00 committed by GitHub
parent 44c1d35b1f
commit bd900118f4
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
3 changed files with 27 additions and 3 deletions

View File

@ -268,15 +268,17 @@ const props = withDefaults(
isMobile: boolean
appId?: string
chatId: string
showUserInput?: boolean
sendMessage: (question: string, other_params_data?: any, chat?: chatType) => void
openChatId: () => Promise<string>
checkInputParam: () => boolean
}>(),
{
applicationDetails: () => ({}),
available: true
}
)
const emit = defineEmits(['update:chatId', 'update:loading'])
const emit = defineEmits(['update:chatId', 'update:loading', 'update:showUserInput'])
const chartOpenId = ref<string>()
const chatId_context = computed({
get: () => {

View File

@ -83,6 +83,9 @@ const inputFieldConfig = ref({ title: t('chat.userInput') })
const showUserInput = ref(true)
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 api_form_data_context = computed({
@ -365,7 +368,18 @@ const confirmHandle = () => {
const cancelHandle = () => {
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(() => {
firstMounted.value = true
handleInputFieldList()

View File

@ -5,7 +5,10 @@
:class="type"
:style="{ height: firsUserInput ? '100%' : undefined }"
>
<div v-show="showUserInputContent" :class="firsUserInput ? 'firstUserInput' : 'popperUserInput'">
<div
v-show="showUserInputContent"
:class="firsUserInput ? 'firstUserInput' : 'popperUserInput'"
>
<UserForm
v-model:api_form_data="api_form_data"
v-model:form_data="form_data"
@ -60,9 +63,11 @@
:type="type"
:send-message="sendMessage"
:open-chat-id="openChatId"
:check-input-param="checkInputParam"
:chat-management="ChatManagement"
v-model:chat-id="chartOpenId"
v-model:loading="loading"
v-model:show-user-input="showUserInput"
v-if="type !== 'log'"
>
<template #operateBefore>
@ -210,6 +215,9 @@ function UserFormCancel() {
// api_form_data.value = JSON.parse(JSON.stringify(initialApiFormData.value))
showUserInput.value = false
}
const checkInputParam = () => {
userFormRef.value?.checkInputParam()
}
function sendMessage(val: string, other_params_data?: any, chat?: chatType) {
if (!userFormRef.value?.checkInputParam()) {