UNPKG

@alitajs/antd-plus

Version:

基于 ant-design 封装的偏业务组件

62 lines (57 loc) 1.78 kB
import "antd/es/button/style"; import _Button from "antd/es/button"; function _extends() { _extends = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; return _extends.apply(this, arguments); } import React from 'react'; import { Authorized } from '@alitajs/antd-plus'; import Policy from '@pansy/policy'; var Auth = function Auth(props) { var actions = [{ module: 'module1', action: 'action1' }, { module: 'module1', action: 'action2' }, { module: 'module1', action: 'action3' }, { module: 'module2', action: 'action1' }, { module: 'module2', action: 'action2' }]; var policy = new Policy(actions); policy.addPolicy({ version: 1, statement: [{ effect: 'allow', action: ['module1/*'] }] }); return /*#__PURE__*/React.createElement(Authorized, _extends({}, props, { policy: policy })); }; var Example = function Example() { return /*#__PURE__*/React.createElement("div", { className: "authorized-demo" }, /*#__PURE__*/React.createElement(Auth, { authority: "*" }, /*#__PURE__*/React.createElement(_Button, { type: "primary" }, "\u64CD\u4F5C1")), /*#__PURE__*/React.createElement(Auth, { authority: "module1/action1" }, /*#__PURE__*/React.createElement(_Button, { style: { margin: '0 16px' }, type: "primary" }, "\u64CD\u4F5C2")), /*#__PURE__*/React.createElement(Auth, { authority: "module2/action1", noMatch: "no auth" }, /*#__PURE__*/React.createElement(_Button, { type: "primary" }, "\u64CD\u4F5C2"))); }; export default Example;