浏览代码

refactor & perf of file `var-reference-vars.tsx` (#17444)

tags/1.2.0
yusheng chen 6 个月前
父节点
当前提交
dd4b03e812
没有帐户链接到提交者的电子邮件
共有 1 个文件被更改,包括 7 次插入4 次删除
  1. 7
    4
      web/app/components/workflow/nodes/_base/components/variable/var-reference-vars.tsx

+ 7
- 4
web/app/components/workflow/nodes/_base/components/variable/var-reference-vars.tsx 查看文件

import { checkKeys } from '@/utils/var' import { checkKeys } from '@/utils/var'
import { FILE_STRUCT } from '@/app/components/workflow/constants' import { FILE_STRUCT } from '@/app/components/workflow/constants'
import { Loop } from '@/app/components/base/icons/src/vender/workflow' import { Loop } from '@/app/components/base/icons/src/vender/workflow'
import { noop } from 'lodash-es'


type ObjectChildrenProps = { type ObjectChildrenProps = {
nodeId: string nodeId: string
isLoopVar?: boolean isLoopVar?: boolean
} }


const objVarTypes = [VarType.object, VarType.file]

const Item: FC<ItemProps> = ({ const Item: FC<ItemProps> = ({
nodeId, nodeId,
title, title,
isLoopVar, isLoopVar,
}) => { }) => {
const isFile = itemData.type === VarType.file const isFile = itemData.type === VarType.file
const isObj = ([VarType.object, VarType.file].includes(itemData.type) && itemData.children && itemData.children.length > 0)
const isObj = (objVarTypes.includes(itemData.type) && itemData.children && itemData.children.length > 0)
const isSys = itemData.variable.startsWith('sys.') const isSys = itemData.variable.startsWith('sys.')
const isEnv = itemData.variable.startsWith('env.') const isEnv = itemData.variable.startsWith('env.')
const isChatVar = itemData.variable.startsWith('conversation.') const isChatVar = itemData.variable.startsWith('conversation.')
const itemRef = useRef(null)
const itemRef = useRef<HTMLDivElement>(null)
const [isItemHovering, setIsItemHovering] = useState(false) const [isItemHovering, setIsItemHovering] = useState(false)
const _ = useHover(itemRef, { const _ = useHover(itemRef, {
onChange: (hovering) => { onChange: (hovering) => {
return ( return (
<PortalToFollowElem <PortalToFollowElem
open={open} open={open}
onOpenChange={() => { }}
onOpenChange={noop}
placement='left-start' placement='left-start'
> >
<PortalToFollowElemTrigger className='w-full'> <PortalToFollowElemTrigger className='w-full'>
isSupportFileVar, isSupportFileVar,
}) => { }) => {
const currObjPath = objPath const currObjPath = objPath
const itemRef = useRef(null)
const itemRef = useRef<HTMLDivElement>(null)
const [isItemHovering, setIsItemHovering] = useState(false) const [isItemHovering, setIsItemHovering] = useState(false)
const _ = useHover(itemRef, { const _ = useHover(itemRef, {
onChange: (hovering) => { onChange: (hovering) => {

正在加载...
取消
保存