diff --git a/packages/client/src/schema-component/antd/action/Action.Link.tsx b/packages/client/src/schema-component/antd/action/Action.Link.tsx new file mode 100644 index 000000000..d28a15470 --- /dev/null +++ b/packages/client/src/schema-component/antd/action/Action.Link.tsx @@ -0,0 +1,31 @@ +import { observer, RecursionField, useField, useFieldSchema } from '@formily/react'; +import React, { useState } from 'react'; +import { Link } from 'react-router-dom'; +import { ActionContext } from './context'; +import { useA } from './hooks'; +import { ComposedAction } from './types'; + +export const ActionLink: ComposedAction = observer((props: any) => { + const { openMode, containerRefKey, useAction = useA, onClick, ...others } = props; + const [visible, setVisible] = useState(false); + const schema = useFieldSchema(); + const field = useField(); + const { run } = useAction(); + return ( + + { + onClick && onClick(e); + setVisible(true); + run(); + }} + > + {field.title} + + + + ); +}); + +export default ActionLink; diff --git a/packages/client/src/schema-component/antd/action/Action.tsx b/packages/client/src/schema-component/antd/action/Action.tsx index a461a6f8a..d94027398 100644 --- a/packages/client/src/schema-component/antd/action/Action.tsx +++ b/packages/client/src/schema-component/antd/action/Action.tsx @@ -3,6 +3,7 @@ import { Button } from 'antd'; import React, { useState } from 'react'; import ActionContainer from './Action.Container'; import { ActionDrawer } from './Action.Drawer'; +import { ActionLink } from './Action.Link'; import { ActionModal } from './Action.Modal'; import { ActionPage } from './Action.Page'; import { ActionContext } from './context'; @@ -32,6 +33,7 @@ export const Action: ComposedAction = observer((props: any) => { ); }); +Action.Link = ActionLink; Action.Drawer = ActionDrawer; Action.Modal = ActionModal; Action.Container = ActionContainer;