fix type error of placeholder

This commit is contained in:
JzoNg 2025-12-03 19:48:24 +08:00
parent 882d2f5b4c
commit 202f924d99
8 changed files with 17 additions and 47 deletions

View File

@ -33,7 +33,7 @@ const ComponentUI: FC<Props> = ({
type: InputVarType.textInput,
output_variable_name: varName,
placeholder: {
type: 'const',
type: 'constant',
selector: [],
value: '',
},

View File

@ -22,7 +22,7 @@ type Props = {
const defaultPayload: FormInputItem = {
type: InputVarType.paragraph,
output_variable_name: '',
placeholder: { type: 'const', selector: [], value: '' },
placeholder: { type: 'constant', selector: [], value: '' },
}
const InputField: React.FC<Props> = ({
nodeId,
@ -41,12 +41,12 @@ const InputField: React.FC<Props> = ({
return (value: any) => {
const nextValue = produce(tempPayload, (draft) => {
if (!draft.placeholder)
draft.placeholder = { type: 'const', selector: [], value: '' }
draft.placeholder = { type: 'constant', selector: [], value: '' }
draft.placeholder[key] = value
if(key === 'selector')
draft.placeholder.type = 'variable'
else if(key === 'value')
draft.placeholder.type = 'const'
draft.placeholder.type = 'constant'
})
setTempPayload(nextValue)
}
@ -75,7 +75,7 @@ const InputField: React.FC<Props> = ({
<PrePopulate
isVariable={placeholderConfig?.type === 'variable'}
onIsVariableChange={(isVariable) => {
handlePlaceholderChange('type')(isVariable ? 'variable' : 'const')
handlePlaceholderChange('type')(isVariable ? 'variable' : 'constant')
}}
nodeId={nodeId}
valueSelector={placeholderConfig?.selector}

View File

@ -773,11 +773,11 @@ export const useWorkflowRun = () => {
onTTSChunk: (messageId: string, audio: string) => {
if (!audio || audio === '')
return
player.playAudioWithAudio(audio, true)
player?.playAudioWithAudio(audio, true)
AudioPlayerManager.getInstance().resetMsgId(messageId)
},
onTTSEnd: (messageId: string, audio: string) => {
player.playAudioWithAudio(audio, false)
player?.playAudioWithAudio(audio, false)
},
onWorkflowSuspended: (params) => {
handleWorkflowSuspended()

View File

@ -99,6 +99,7 @@ const MethodSelector: FC<Props> = ({
id: uuid4(),
type: DeliveryMethodType.Email,
enabled: false,
config: null,
})
}}
>

View File

@ -1,6 +1,6 @@
import type { NodeDefault } from '../../types'
import type { HumanInputNodeType } from './types'
import { DeliveryMethodType, UserActionButtonType } from './types'
// import { DeliveryMethodType, UserActionButtonType } from './types'
import { genNodeMetaData } from '@/app/components/workflow/utils'
import { BlockEnum } from '@/app/components/workflow/types'
import { BlockClassificationEnum } from '@/app/components/workflow/block-selector/types'
@ -16,40 +16,8 @@ const metaData = genNodeMetaData({
const nodeDefault: NodeDefault<HumanInputNodeType> = {
metaData,
defaultValue: {
delivery_methods: [
{
id: 'webapp-method',
type: DeliveryMethodType.WebApp,
enabled: true,
},
{
id: 'email-method',
type: DeliveryMethodType.Email,
enabled: false,
},
],
user_actions: [
{
id: 'approve-action',
title: 'Post to X',
button_style: UserActionButtonType.Primary,
},
{
id: 'regenerate-action',
title: 'regenerate',
button_style: UserActionButtonType.Default,
},
{
id: 'thinking-action',
title: 'thinking',
button_style: UserActionButtonType.Accent,
},
{
id: 'cancel-action',
title: 'cancel',
button_style: UserActionButtonType.Ghost,
},
],
delivery_methods: [],
user_actions: [],
timeout: 3,
timeout_unit: 'day',
},

View File

@ -40,11 +40,11 @@ export type DeliveryMethod = {
id: string
type: DeliveryMethodType
enabled: boolean
config?: EmailConfig | {}
config?: EmailConfig | {} | null
}
export type FormInputItemPlaceholder = {
type: 'variable' | 'const',
type: 'variable' | 'constant',
selector: ValueSelector
value: string
}

View File

@ -51,10 +51,10 @@ const useSingleRunFormParams = ({
return {
type: item.type,
output_variable_name: item.output_variable_name,
placeholder: item.placeholder?.type === 'const' ? item.placeholder.value : '',
placeholder: item.placeholder?.type === 'constant' ? item.placeholder.value : '',
}
})
return res
return res
}, [inputs.form_content, inputs.inputs])
const getDependentVars = () => {

View File

@ -137,7 +137,8 @@ export const fetchFilePreview: Fetcher<{ content: string }, { fileID: string }>
}
export const fetchCurrentWorkspace: Fetcher<ICurrentWorkspace, { url: string; params: Record<string, any> }> = ({ url, params }) => {
return post<ICurrentWorkspace>(url, { body: params })
// return post<ICurrentWorkspace>(url, { body: params })
return get<ICurrentWorkspace>(url, { params })
}
export const updateCurrentWorkspace: Fetcher<ICurrentWorkspace, { url: string; body: Record<string, any> }> = ({ url, body }) => {