Skip to content

Commit bd90011

Browse files
authored
refactor: Dialogue logic optimization (#2776)
1 parent 44c1d35 commit bd90011

File tree

3 files changed

+27
-3
lines changed

3 files changed

+27
-3
lines changed

ui/src/components/ai-chat/component/chat-input-operate/index.vue

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -268,15 +268,17 @@ const props = withDefaults(
268268
isMobile: boolean
269269
appId?: string
270270
chatId: string
271+
showUserInput?: boolean
271272
sendMessage: (question: string, other_params_data?: any, chat?: chatType) => void
272273
openChatId: () => Promise<string>
274+
checkInputParam: () => boolean
273275
}>(),
274276
{
275277
applicationDetails: () => ({}),
276278
available: true
277279
}
278280
)
279-
const emit = defineEmits(['update:chatId', 'update:loading'])
281+
const emit = defineEmits(['update:chatId', 'update:loading', 'update:showUserInput'])
280282
const chartOpenId = ref<string>()
281283
const chatId_context = computed({
282284
get: () => {

ui/src/components/ai-chat/component/user-form/index.vue

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -83,6 +83,9 @@ const inputFieldConfig = ref({ title: t('chat.userInput') })
8383
const showUserInput = ref(true)
8484
const firstMounted = ref(false)
8585
86+
const dynamicsFormRef = ref<InstanceType<typeof DynamicsForm>>()
87+
const dynamicsFormRef2 = ref<InstanceType<typeof DynamicsForm>>()
88+
8689
const emit = defineEmits(['update:api_form_data', 'update:form_data', 'confirm', 'cancel'])
8790
8891
const api_form_data_context = computed({
@@ -365,7 +368,18 @@ const confirmHandle = () => {
365368
const cancelHandle = () => {
366369
emit('cancel')
367370
}
368-
defineExpose({ checkInputParam })
371+
const render = (data: any) => {
372+
if (dynamicsFormRef.value) {
373+
dynamicsFormRef.value?.render(inputFieldList.value, data)
374+
}
375+
}
376+
377+
const renderDebugAiChat = (data: any) => {
378+
if (dynamicsFormRef2.value) {
379+
dynamicsFormRef2.value?.render(apiInputFieldList.value, data)
380+
}
381+
}
382+
defineExpose({ checkInputParam, render, renderDebugAiChat })
369383
onMounted(() => {
370384
firstMounted.value = true
371385
handleInputFieldList()

ui/src/components/ai-chat/index.vue

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,10 @@
55
:class="type"
66
:style="{ height: firsUserInput ? '100%' : undefined }"
77
>
8-
<div v-show="showUserInputContent" :class="firsUserInput ? 'firstUserInput' : 'popperUserInput'">
8+
<div
9+
v-show="showUserInputContent"
10+
:class="firsUserInput ? 'firstUserInput' : 'popperUserInput'"
11+
>
912
<UserForm
1013
v-model:api_form_data="api_form_data"
1114
v-model:form_data="form_data"
@@ -60,9 +63,11 @@
6063
:type="type"
6164
:send-message="sendMessage"
6265
:open-chat-id="openChatId"
66+
:check-input-param="checkInputParam"
6367
:chat-management="ChatManagement"
6468
v-model:chat-id="chartOpenId"
6569
v-model:loading="loading"
70+
v-model:show-user-input="showUserInput"
6671
v-if="type !== 'log'"
6772
>
6873
<template #operateBefore>
@@ -210,6 +215,9 @@ function UserFormCancel() {
210215
// api_form_data.value = JSON.parse(JSON.stringify(initialApiFormData.value))
211216
showUserInput.value = false
212217
}
218+
const checkInputParam = () => {
219+
userFormRef.value?.checkInputParam()
220+
}
213221
214222
function sendMessage(val: string, other_params_data?: any, chat?: chatType) {
215223
if (!userFormRef.value?.checkInputParam()) {

0 commit comments

Comments
 (0)