mirror of
https://git.mirrors.martin98.com/https://github.com/langgenius/dify.git
synced 2025-08-20 06:49:13 +08:00
fix: file show type error
This commit is contained in:
parent
007a6fd14a
commit
264f7c2139
@ -52,18 +52,18 @@ const inputVarTypeToVarType = (type: InputVarType): VarType => {
|
|||||||
} as any)[type] || VarType.string
|
} as any)[type] || VarType.string
|
||||||
}
|
}
|
||||||
|
|
||||||
const findExceptVarInObject = (obj: any, filterVar: (payload: Var, selector: ValueSelector) => boolean, value_selector: ValueSelector): Var => {
|
const findExceptVarInObject = (obj: any, filterVar: (payload: Var, selector: ValueSelector) => boolean, value_selector: ValueSelector, isFile?: boolean): Var => {
|
||||||
const { children } = obj
|
const { children } = obj
|
||||||
const res: Var = {
|
const res: Var = {
|
||||||
variable: obj.variable,
|
variable: obj.variable,
|
||||||
type: VarType.object,
|
type: isFile ? VarType.file : VarType.object,
|
||||||
children: children.filter((item: Var) => {
|
children: children.filter((item: Var) => {
|
||||||
const { children } = item
|
const { children } = item
|
||||||
const currSelector = [...value_selector, item.variable]
|
const currSelector = [...value_selector, item.variable]
|
||||||
if (!children)
|
if (!children)
|
||||||
return filterVar(item, currSelector)
|
return filterVar(item, currSelector)
|
||||||
|
|
||||||
const obj = findExceptVarInObject(item, filterVar, currSelector)
|
const obj = findExceptVarInObject(item, filterVar, currSelector, false) // File doesn't contains file children
|
||||||
return obj.children && obj.children?.length > 0
|
return obj.children && obj.children?.length > 0
|
||||||
}),
|
}),
|
||||||
}
|
}
|
||||||
@ -302,7 +302,6 @@ const formatItem = (
|
|||||||
}
|
}
|
||||||
|
|
||||||
const selector = [id]
|
const selector = [id]
|
||||||
|
|
||||||
res.vars = res.vars.filter((v) => {
|
res.vars = res.vars.filter((v) => {
|
||||||
const isCurrentMatched = filterVar(v, (() => {
|
const isCurrentMatched = filterVar(v, (() => {
|
||||||
const variableArr = v.variable.split('.')
|
const variableArr = v.variable.split('.')
|
||||||
@ -330,7 +329,7 @@ const formatItem = (
|
|||||||
if (!children)
|
if (!children)
|
||||||
return false
|
return false
|
||||||
|
|
||||||
const obj = findExceptVarInObject(isFile ? { ...v, children } : v, filterVar, selector)
|
const obj = findExceptVarInObject(isFile ? { ...v, children } : v, filterVar, selector, isFile)
|
||||||
return obj?.children && obj?.children.length > 0
|
return obj?.children && obj?.children.length > 0
|
||||||
}).map((v) => {
|
}).map((v) => {
|
||||||
const isFile = v.type === VarType.file
|
const isFile = v.type === VarType.file
|
||||||
@ -352,7 +351,7 @@ const formatItem = (
|
|||||||
if (!children)
|
if (!children)
|
||||||
return v
|
return v
|
||||||
|
|
||||||
return findExceptVarInObject(isFile ? { ...v, children } : v, filterVar, selector)
|
return findExceptVarInObject(isFile ? { ...v, children } : v, filterVar, selector, isFile)
|
||||||
})
|
})
|
||||||
|
|
||||||
return res
|
return res
|
||||||
|
Loading…
x
Reference in New Issue
Block a user