Skip to content

Commit

Permalink
feat: 增加 schema 配置
Browse files Browse the repository at this point in the history
  • Loading branch information
zhanbo.lh committed Nov 20, 2024
1 parent 5ba95a6 commit 69a25d7
Show file tree
Hide file tree
Showing 6 changed files with 46 additions and 547 deletions.
2 changes: 2 additions & 0 deletions docs/xflow/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,7 @@ const settings = [
title: 'Input',
type: 'Start',
hidden: true,
targetHandleHidden: true,
icon: {
type: 'icon-start',
bgColor: '#17B26A',
Expand All @@ -60,6 +61,7 @@ const settings = [
title: 'Output',
type: 'End',
hidden: true,
sourceHandleHidden: true,
icon: {
type: 'icon-end',
bgColor: '#F79009',
Expand Down
14 changes: 8 additions & 6 deletions packages/x-flow/src/components/CustomNode/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,16 +5,16 @@ import classNames from 'classnames';
import produce from 'immer';
import { useShallow } from 'zustand/react/shallow';
import { Handle, Position, useReactFlow } from '@xyflow/react';
import useStore from '../../models/store';
import { capitalize, uuid } from '../../utils';
import useStore from '../../models/store';
import { ConfigContext } from '../../models/context';
import NodeSelectPopover from '../NodesPopover';
import './index.less';

export default memo((props: any) => {
const { id, type, data, layout, isConnectable, selected, onClick } = props;
const configCtx: any = useContext(ConfigContext);
const NodeWidget = configCtx?.widgets[`${capitalize(type)}Node`];
const { widgets, settingMap } = useContext(ConfigContext);
const NodeWidget = widgets[`${capitalize(type)}Node`];

const [isHovered, setIsHovered] = useState(false);
const reactflow = useReactFlow();
Expand Down Expand Up @@ -60,14 +60,16 @@ export default memo((props: any) => {
setEdges(newEdges);
};


let targetPosition = Position.Left;
let sourcePosition = Position.Right;
if (layout === 'TB') {
targetPosition = Position.Top;
sourcePosition = Position.Bottom;
}

console.log(settingMap, 'settingMap=====')


return (
<div
className={classNames('xflow-node-container', {
Expand All @@ -77,7 +79,7 @@ export default memo((props: any) => {
onMouseEnter={() => setIsHovered(true)}
onMouseLeave={() => setIsHovered(false)}
>
{ (
{!settingMap?.[type]?.targetHandleHidden && (
<Handle
type='target'
position={targetPosition}
Expand All @@ -90,7 +92,7 @@ export default memo((props: any) => {
data={data}
onClick={() => onClick(data)}
/>
{(
{!settingMap?.[type]?.sourceHandleHidden && (
<Handle
type='source'
position={sourcePosition}
Expand Down
264 changes: 0 additions & 264 deletions packages/x-flow/src/components/CustomNode/utils.ts

This file was deleted.

Loading

0 comments on commit 69a25d7

Please sign in to comment.