Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 20 additions & 0 deletions ui/src/components/ai-chat/component/inline-params/constants.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
/**
* 用户输入参数平铺白名单
*
* 只有这些 input_type 的字段可以被设置为外置参数(在聊天框上平铺显示)。
* 改动这里会影响 3 个消费方,注意同步语义:
* - UserInputTitleDialog.vue —— 齿轮弹窗中 select option 的 disabled 判断
* - inline-params/index.vue —— 渲染时兜底过滤,防止白名单被绕过
* - base-node/UserInputFieldTable.vue —— 字段类型变更/删除时清理脏数据
*/
export const ALLOWED_EXPOSED_TYPES = [
'Model',
'Knowledge',
'SwitchInput',
'DatePicker',
'TreeSelect',
'SingleSelect',
'MultiSelect',
'RadioCard',
'RadioRow',
] as const
15 changes: 15 additions & 0 deletions ui/src/workflow/nodes/base-node/component/UserInputFieldTable.vue
Original file line number Diff line number Diff line change
Expand Up @@ -96,6 +96,7 @@ import Sortable from 'sortablejs'
import UserFieldFormDialog from './UserFieldFormDialog.vue'
import { MsgError } from '@/utils/message'
import { t } from '@/locales'
import { ALLOWED_EXPOSED_TYPES } from '@/components/ai-chat/component/inline-params/constants'
import UserInputTitleDialog from '@/workflow/nodes/base-node/component/UserInputTitleDialog.vue'
import { input_type_list } from '@/components/dynamics-form/constructor/data'
const props = defineProps<{ nodeModel: any }>()
Expand All @@ -110,6 +111,13 @@ function openAddDialog(data?: any, index?: any) {
UserFieldFormDialogRef.value.open(data, index)
}

function removeFromExposed(fieldName: string) {
const setting = props.nodeModel.properties.user_input_field_list_setting
if (setting?.exposed_fields?.includes(fieldName)) {
setting.exposed_fields = setting.exposed_fields.filter((f: string) => f !== fieldName)
}
}

function openChangeTitleDialog() {
UserInputTitleDialogRef.value.open(
inputFieldConfig.value,
Expand All @@ -120,7 +128,11 @@ function openChangeTitleDialog() {
}

function deleteField(index: any) {
const removed = inputFieldList.value[index]
inputFieldList.value.splice(index, 1)
if (removed?.field) {
removeFromExposed(removed.field)
}
props.nodeModel.graphModel.eventCenter.emit('refreshFieldList')
onDragHandle()
}
Expand All @@ -145,6 +157,9 @@ function refreshFieldList(data: any, index: any) {
} else {
inputFieldList.value.push(data)
}
if (!ALLOWED_EXPOSED_TYPES.includes(data.input_type)) {
removeFromExposed(data.field)
}
UserFieldFormDialogRef.value.close()
props.nodeModel.graphModel.eventCenter.emit('refreshFieldList')
onDragHandle()
Expand Down
14 changes: 2 additions & 12 deletions ui/src/workflow/nodes/base-node/component/UserInputTitleDialog.vue
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@
:label="getFieldLabel(item)"
:value="item.field"
:disabled="
!allowedTypes.includes(item.input_type) ||
!ALLOWED_EXPOSED_TYPES.includes(item.input_type) ||
(form.exposed_fields.length >= 3 && !form.exposed_fields.includes(item.field))
"
/>
Expand Down Expand Up @@ -53,6 +53,7 @@
import { reactive, ref } from 'vue'
import type { FormInstance } from 'element-plus'
import { t } from '@/locales'
import { ALLOWED_EXPOSED_TYPES } from '@/components/ai-chat/component/inline-params/constants'
const emit = defineEmits(['refresh'])

const fieldFormRef = ref()
Expand All @@ -68,17 +69,6 @@ const rules = reactive({
menu_title: [{ required: true, message: t('common.inputPlaceholder'), trigger: 'blur' }],
})

const allowedTypes = [
'Model',
'Knowledge',
'SwitchInput',
'DatePicker',
'TreeSelect',
'SingleSelect',
'MultiSelect',
'RadioCard',
'RadioRow',
]
const dialogVisible = ref<boolean>(false)

const getFieldLabel = (item: any) => {
Expand Down
Loading