mirror of
https://git.mirrors.martin98.com/https://github.com/langgenius/dify.git
synced 2025-08-14 04:05:53 +08:00
refactor & perf of file var-reference-vars.tsx
(#17444)
This commit is contained in:
parent
bf69b97639
commit
dd4b03e812
@ -17,6 +17,7 @@ import { BubbleX, Env } from '@/app/components/base/icons/src/vender/line/others
|
|||||||
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
|
||||||
@ -42,6 +43,8 @@ type ItemProps = {
|
|||||||
isLoopVar?: boolean
|
isLoopVar?: boolean
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const objVarTypes = [VarType.object, VarType.file]
|
||||||
|
|
||||||
const Item: FC<ItemProps> = ({
|
const Item: FC<ItemProps> = ({
|
||||||
nodeId,
|
nodeId,
|
||||||
title,
|
title,
|
||||||
@ -55,11 +58,11 @@ const Item: FC<ItemProps> = ({
|
|||||||
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) => {
|
||||||
@ -100,7 +103,7 @@ const Item: FC<ItemProps> = ({
|
|||||||
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'>
|
||||||
@ -180,7 +183,7 @@ const ObjectChildren: FC<ObjectChildrenProps> = ({
|
|||||||
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) => {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user