tntd
Version:
tntd是基于 TNT Design 设计体系的 React UI 组件库,主要用于研发企业级中后台产品。
39 lines (38 loc) • 1.35 kB
JavaScript
;
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.getCheckAuth = exports["default"] = void 0;
var _get2 = _interopRequireDefault(require("lodash/get"));
function _interopRequireDefault(e) {
return e && e.__esModule ? e : {
"default": e
};
}
var getCheckAuth = exports.getCheckAuth = function getCheckAuth(menus) {
var _getAuthMap = function getAuthMap() {
var menus = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : [];
var authMap = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
return menus.reduce(function (acc, _ref) {
var code = _ref.code,
groupName = _ref.groupName,
functionList = _ref.functionList,
children = _ref.children;
if (groupName) {
return _getAuthMap(children, acc);
} else {
acc[code] = acc[code] || {};
acc[code] = (functionList || []).reduce(function (acc, curFunc) {
acc[curFunc.code] = curFunc.hasPermission;
return acc;
}, acc[code]);
return acc;
}
}, authMap);
};
var authMap = _getAuthMap(menus);
return function (menuCode, funCode) {
return !!(0, _get2["default"])(authMap, "".concat(menuCode).concat(funCode ? ".".concat(funCode) : ''));
};
};
var _default = exports["default"] = getCheckAuth;