mirror of
https://github.com/langgenius/dify.git
synced 2026-05-02 16:38:04 +08:00
add memory icon in editor block
This commit is contained in:
@ -7,13 +7,15 @@ export type VariableIconProps = {
|
||||
className?: string
|
||||
variables?: string[]
|
||||
variableCategory?: VarInInspectType | string
|
||||
isMemoryVariable?: boolean
|
||||
}
|
||||
const VariableIcon = ({
|
||||
className,
|
||||
variables = [],
|
||||
variableCategory,
|
||||
isMemoryVariable,
|
||||
}: VariableIconProps) => {
|
||||
const VarIcon = useVarIcon(variables, variableCategory)
|
||||
const VarIcon = useVarIcon(variables, variableCategory, isMemoryVariable)
|
||||
|
||||
return VarIcon && (
|
||||
<VarIcon
|
||||
|
||||
@ -21,6 +21,7 @@ const VariableLabel = ({
|
||||
errorMsg,
|
||||
onClick,
|
||||
isExceptionVariable,
|
||||
isMemoryVariable,
|
||||
ref,
|
||||
notShowFullPath,
|
||||
rightSlot,
|
||||
@ -50,6 +51,7 @@ const VariableLabel = ({
|
||||
<VariableIcon
|
||||
variables={variables}
|
||||
className={varColorClassName}
|
||||
isMemoryVariable={isMemoryVariable}
|
||||
/>
|
||||
<VariableName
|
||||
variables={variables}
|
||||
|
||||
@ -1,7 +1,8 @@
|
||||
import { useMemo } from 'react'
|
||||
import { Variable02 } from '@/app/components/base/icons/src/vender/solid/development'
|
||||
import { BubbleX, Env } from '@/app/components/base/icons/src/vender/line/others'
|
||||
import { BubbleX, Env, Memory } from '@/app/components/base/icons/src/vender/line/others'
|
||||
import { Loop } from '@/app/components/base/icons/src/vender/workflow'
|
||||
|
||||
import {
|
||||
isConversationVar,
|
||||
isENV,
|
||||
@ -9,13 +10,16 @@ import {
|
||||
} from '../utils'
|
||||
import { VarInInspectType } from '@/types/workflow'
|
||||
|
||||
export const useVarIcon = (variables: string[], variableCategory?: VarInInspectType | string) => {
|
||||
export const useVarIcon = (variables: string[], variableCategory?: VarInInspectType | string, isMemoryVariable?: boolean) => {
|
||||
if (variableCategory === 'loop')
|
||||
return Loop
|
||||
|
||||
if (isENV(variables) || variableCategory === VarInInspectType.environment || variableCategory === 'environment')
|
||||
return Env
|
||||
|
||||
if (isMemoryVariable)
|
||||
return Memory
|
||||
|
||||
if (isConversationVar(variables) || variableCategory === VarInInspectType.conversation || variableCategory === 'conversation')
|
||||
return BubbleX
|
||||
|
||||
|
||||
@ -13,6 +13,7 @@ export type VariablePayload = {
|
||||
onClick?: (e: React.MouseEvent<HTMLDivElement>) => void
|
||||
errorMsg?: string
|
||||
isExceptionVariable?: boolean
|
||||
isMemoryVariable?: boolean
|
||||
ref?: React.Ref<HTMLDivElement>
|
||||
notShowFullPath?: boolean
|
||||
rightSlot?: ReactNode
|
||||
|
||||
Reference in New Issue
Block a user