fix: not show sys var type

This commit is contained in:
Joel 2024-03-19 11:54:47 +08:00
parent f3bf4c7730
commit 978ee93df7
1 changed files with 20 additions and 15 deletions

View File

@ -97,27 +97,32 @@ const VarReferencePicker: FC<Props> = ({
const getVarType = () => {
if (isConstant)
return 'undefined'
const targetVarNodeId = isSystemVar(value as ValueSelector) ? startNode?.id : outputVarNodeId
const isSystem = isSystemVar(value as ValueSelector)
const targetVarNodeId = isSystem ? startNode?.id : outputVarNodeId
const targetVar = allOutputVars.find(v => v.nodeId === targetVarNodeId)
if (!targetVar)
return 'undefined'
let type: VarType = VarType.string
let curr: any = targetVar.vars;
(value as ValueSelector).slice(1).forEach((key, i) => {
const isLast = i === value.length - 2
curr = curr.find((v: any) => v.variable === key)
if (isLast) {
type = curr?.type
}
else {
if (curr.type === VarType.object)
curr = curr.children
}
})
return type
let curr: any = targetVar.vars
if (isSystem) {
return curr.find((v: any) => v.variable === (value as ValueSelector).join('.'))?.type
}
else {
(value as ValueSelector).slice(1).forEach((key, i) => {
const isLast = i === value.length - 2
curr = curr.find((v: any) => v.variable === key)
if (isLast) {
type = curr?.type
}
else {
if (curr.type === VarType.object)
curr = curr.children
}
})
return type
}
}
const varKindTypes = [