mirror of
https://github.com/1Panel-dev/MaxKB.git
synced 2025-12-26 01:33:05 +00:00
refactor: Dialogue logic optimization (#2776)
This commit is contained in:
parent
44c1d35b1f
commit
bd900118f4
|
|
@ -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: () => {
|
||||
|
|
|
|||
|
|
@ -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()
|
||||
|
|
|
|||
|
|
@ -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()) {
|
||||
|
|
|
|||
Loading…
Reference in New Issue