Chore: frontend infrastructure upgrade (#16420)

Co-authored-by: NFish <douxc512@gmail.com>
Co-authored-by: zxhlyh <jasonapring2015@outlook.com>
Co-authored-by: twwu <twwu@dify.ai>
Co-authored-by: jZonG <jzongcode@gmail.com>
This commit is contained in:
Joel
2025-03-21 17:41:03 +08:00
committed by GitHub
parent e61415223b
commit 7709d9df20
1435 changed files with 13372 additions and 11612 deletions

View File

@@ -61,14 +61,14 @@ const AddVariable = ({
<div
className={cn(
'group/addvariable flex items-center justify-center',
'w-4 h-4 cursor-pointer',
'h-4 w-4 cursor-pointer',
'hover:rounded-full hover:bg-primary-600',
open && '!rounded-full !bg-primary-600',
)}
>
<Plus02
className={cn(
'w-2.5 h-2.5 text-gray-500',
'h-2.5 w-2.5 text-gray-500',
'group-hover/addvariable:text-white',
open && '!text-white',
)}

View File

@@ -81,17 +81,17 @@ const NodeGroupItem = ({
return (
<div
className={cn(
'relative pt-1 px-1.5 pb-1.5 rounded-lg border-[1.5px] border-transparent',
showSelectionBorder && '!border-gray-300 !border-dashed bg-black/[0.02]',
'relative rounded-lg border-[1.5px] border-transparent px-1.5 pb-1.5 pt-1',
showSelectionBorder && '!border-dashed !border-gray-300 bg-black/[0.02]',
showSelectedBorder && '!border-primary-600 !bg-primary-50',
)}
onMouseEnter={() => groupEnabled && handleGroupItemMouseEnter(item.targetHandleId)}
onMouseLeave={handleGroupItemMouseLeave}
>
<div className='flex items-center justify-between h-4 text-[10px] font-medium text-gray-500'>
<div className='flex h-4 items-center justify-between text-[10px] font-medium text-gray-500'>
<span
className={cn(
'grow uppercase truncate',
'grow truncate uppercase',
showSelectedBorder && 'text-primary-600',
)}
title={item.title}
@@ -99,8 +99,8 @@ const NodeGroupItem = ({
{item.title}
</span>
<div className='flex items-center'>
<span className='shrink-0 ml-2'>{item.type}</span>
<div className='ml-2 mr-1 w-[1px] h-2.5 bg-gray-200'></div>
<span className='ml-2 shrink-0'>{item.type}</span>
<div className='ml-2 mr-1 h-2.5 w-[1px] bg-gray-200'></div>
<AddVariable
availableVars={availableVars}
variableAssignerNodeId={item.variableAssignerNodeId}
@@ -113,7 +113,7 @@ const NodeGroupItem = ({
!item.variables.length && (
<div
className={cn(
'relative flex items-center px-1 h-[22px] justify-between bg-gray-100 rounded-md space-x-1 text-[10px] font-normal text-gray-400 uppercase',
'relative flex h-[22px] items-center justify-between space-x-1 rounded-md bg-gray-100 px-1 text-[10px] font-normal uppercase text-gray-400',
(showSelectedBorder || showSelectionBorder) && '!bg-black/[0.02]',
)}
>

View File

@@ -35,7 +35,7 @@ const NodeVariableItem = ({
const { t } = useTranslation()
return (
<div className={cn(
'relative flex items-center p-[3px] pl-[5px] gap-1 self-stretch rounded-md bg-workflow-block-parma-bg',
'relative flex items-center gap-1 self-stretch rounded-md bg-workflow-block-parma-bg p-[3px] pl-[5px]',
showBorder && '!bg-black/[0.02]',
className,
)}>
@@ -47,19 +47,19 @@ const NodeVariableItem = ({
type={node?.data.type || BlockEnum.Start}
/>
</div>
<div className='max-w-[85px] truncate mx-0.5 text-xs font-medium text-gray-700' title={node?.data.title}>{node?.data.title}</div>
<div className='mx-0.5 max-w-[85px] truncate text-xs font-medium text-gray-700' title={node?.data.title}>{node?.data.title}</div>
<Line3 className='mr-0.5'></Line3>
</div>
)}
<div className='flex items-center text-primary-600 w-full'>
{!isEnv && !isChatVar && <Variable02 className={cn('shrink-0 w-3.5 h-3.5 text-primary-500', isException && 'text-text-warning')} />}
{isEnv && <Env className='shrink-0 w-3.5 h-3.5 text-util-colors-violet-violet-600' />}
{!isChatVar && <div className={cn('max-w-[75px] truncate ml-0.5 system-xs-medium overflow-hidden text-ellipsis', isEnv && 'text-gray-900', isException && 'text-text-warning')} title={varName}>{varName}</div>}
<div className='flex w-full items-center text-primary-600'>
{!isEnv && !isChatVar && <Variable02 className={cn('h-3.5 w-3.5 shrink-0 text-primary-500', isException && 'text-text-warning')} />}
{isEnv && <Env className='h-3.5 w-3.5 shrink-0 text-util-colors-violet-violet-600' />}
{!isChatVar && <div className={cn('system-xs-medium ml-0.5 max-w-[75px] overflow-hidden truncate text-ellipsis', isEnv && 'text-gray-900', isException && 'text-text-warning')} title={varName}>{varName}</div>}
{isChatVar
&& <div className='flex items-center w-full gap-1'>
<div className='flex h-[18px] min-w-[18px] items-center gap-0.5 flex-1'>
<BubbleX className='w-3.5 h-3.5 text-util-colors-teal-teal-700' />
<div className={cn('max-w-[75px] truncate ml-0.5 system-xs-medium overflow-hidden text-ellipsis text-util-colors-teal-teal-700')}>{varName}</div>
&& <div className='flex w-full items-center gap-1'>
<div className='flex h-[18px] min-w-[18px] flex-1 items-center gap-0.5'>
<BubbleX className='h-3.5 w-3.5 text-util-colors-teal-teal-700' />
<div className={cn('system-xs-medium ml-0.5 max-w-[75px] overflow-hidden truncate text-ellipsis text-util-colors-teal-teal-700')}>{varName}</div>
</div>
{writeMode && <Badge className='shrink-0' text={t(`${i18nPrefix}.operations.${writeMode}`)} />}
</div>

View File

@@ -24,7 +24,7 @@ type Payload = VarGroupItemType & {
group_name?: string
}
interface Props {
type Props = {
readOnly: boolean
nodeId: string
payload: Payload
@@ -107,17 +107,17 @@ const VarGroupItem: FC<Props> = ({
title={groupEnabled
? <div className='flex items-center'>
<div className='flex items-center !normal-case'>
<Folder className='mr-0.5 w-3.5 h-3.5' />
<Folder className='mr-0.5 h-3.5 w-3.5' />
{(!isEditGroupName)
? (
<div className='flex items-center h-6 px-1 rounded-lg cursor-text text-text-secondary system-sm-semibold hover:bg-gray-100' onClick={setEditGroupName}>
<div className='system-sm-semibold flex h-6 cursor-text items-center rounded-lg px-1 text-text-secondary hover:bg-gray-100' onClick={setEditGroupName}>
{payload.group_name}
</div>
)
: (
<input
type='text'
className='h-6 px-1 rounded-lg bg-white border border-gray-300 focus:outline-none'
className='h-6 rounded-lg border border-gray-300 bg-white px-1 focus:outline-none'
// style={{
// width: `${((payload.group_name?.length || 0) + 1) / 2}em`,
// }}
@@ -132,20 +132,20 @@ const VarGroupItem: FC<Props> = ({
</div>
{canRemove && (
<div
className='group-hover:block hidden ml-0.5 p-1 rounded-md text-gray-500 cursor-pointer hover:bg-[#FEE4E2] hover:text-[#D92D20]'
className='ml-0.5 hidden cursor-pointer rounded-md p-1 text-gray-500 hover:bg-[#FEE4E2] hover:text-[#D92D20] group-hover:block'
onClick={onRemove}
>
<RiDeleteBinLine
className='w-4 h-4'
className='h-4 w-4'
/>
</div>
)}
</div>
: t(`${i18nPrefix}.title`)!}
operations={
<div className='flex items-center h-6 space-x-2'>
<div className='flex h-6 items-center space-x-2'>
{payload.variables.length > 0 && (
<div className='flex items-center h-[18px] px-1 border border-divider-deep rounded-[5px] text-text-tertiary system-2xs-medium-uppercase'>{payload.output_type}</div>
<div className='system-2xs-medium-uppercase flex h-[18px] items-center rounded-[5px] border border-divider-deep px-1 text-text-tertiary'>{payload.output_type}</div>
)}
{
!readOnly

View File

@@ -74,7 +74,7 @@ const VarList: FC<Props> = ({
/>
{!readonly && (
<RemoveButton
className='!p-2 !bg-gray-100 hover:!bg-gray-200'
className='!bg-gray-100 !p-2 hover:!bg-gray-200'
onClick={handleVarRemove(index)}
/>
)}

View File

@@ -43,7 +43,7 @@ const Node: FC<NodeProps<VariableAssignerNodeType>> = (props) => {
}, [t, advanced_settings, data, id])
return (
<div className='relative mb-1 px-1 space-y-0.5' ref={ref}>
<div className='relative mb-1 space-y-0.5 px-1' ref={ref}>
{
groups.map((item) => {
return (

View File

@@ -39,7 +39,7 @@ const Panel: FC<NodePanelProps<VariableAssignerNodeType>> = ({
return (
<div className='mt-2'>
<div className='px-4 pb-4 space-y-4'>
<div className='space-y-4 px-4 pb-4'>
{!isEnableGroup
? (
<VarGroupItem
@@ -99,7 +99,7 @@ const Panel: FC<NodePanelProps<VariableAssignerNodeType>> = ({
{isEnableGroup && (
<>
<Split />
<div className='px-4 pt-4 pb-2'>
<div className='px-4 pb-2 pt-4'>
<OutputVars>
<>
{inputs.advanced_settings?.groups.map((item, index) => (

View File

@@ -120,7 +120,7 @@ const useConfig = (id: string, payload: VariableAssignerNodeType) => {
inputs.advanced_settings.groups.forEach((item) => {
const match = item.group_name.match(/(\d+)$/)
if (match) {
const num = parseInt(match[1], 10)
const num = Number.parseInt(match[1], 10)
if (num > maxInGroupName)
maxInGroupName = num
}