diff --git a/packages/core/client/src/acl/ACLProvider.tsx b/packages/core/client/src/acl/ACLProvider.tsx index c8f7b69df..52074922c 100644 --- a/packages/core/client/src/acl/ACLProvider.tsx +++ b/packages/core/client/src/acl/ACLProvider.tsx @@ -233,7 +233,7 @@ export const ACLActionProvider = (props) => { } const params = parseAction(actionPath, { schema, recordPkValue }); if (!params) { - return null; + return {props.children}; } //视图表无编辑权限时不显示 if (editablePath.includes(actionPath) || editablePath.includes(actionPath?.split(':')[1])) { diff --git a/packages/core/client/src/schema-component/antd/action/Action.tsx b/packages/core/client/src/schema-component/antd/action/Action.tsx index b88b73a6f..ace42978e 100644 --- a/packages/core/client/src/schema-component/antd/action/Action.tsx +++ b/packages/core/client/src/schema-component/antd/action/Action.tsx @@ -25,6 +25,7 @@ import { useA } from './hooks'; import { useGetAriaLabelOfAction } from './hooks/useGetAriaLabelOfAction'; import { ComposedAction } from './types'; import { linkageAction } from './utils'; +import { useACLActionParamsContext } from '../../../acl'; export const Action: ComposedAction = observer( (props: any) => { @@ -44,6 +45,7 @@ export const Action: ComposedAction = observer( disabled: propsDisabled, ...others } = useProps(props); + const aclCtx = useACLActionParamsContext(); const { wrapSSR, componentCls, hashId } = useStyles(); const { t } = useTranslation(); const [visible, setVisible] = useState(false); @@ -99,7 +101,7 @@ export const Action: ComposedAction = observer( e.preventDefault(); e.stopPropagation(); - if (!disabled) { + if (!disabled && aclCtx) { const onOk = () => { onClick?.(e); setVisible(true); @@ -122,12 +124,12 @@ export const Action: ComposedAction = observer( const buttonStyle = useMemo(() => { return { ...style, - opacity: designable && field?.data?.hidden && 0.1, + opacity: designable && (field?.data?.hidden || !aclCtx) && 0.1, }; }, [designable, field?.data?.hidden, style]); const renderButton = () => { - if (!designable && field?.data?.hidden) { + if (!designable && (field?.data?.hidden || !aclCtx)) { return null; }