山西督察-superintend-distribute-web react
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

31 lines
714 B

  1. /* eslint-disable eslint-comments/disable-enable-pair */
  2. /* eslint-disable import/no-mutable-exports */
  3. let CURRENT = 'NULL';
  4. /**
  5. * Use authority or getAuthority
  6. *
  7. * @param {string|()=>String} currentAuthority
  8. */
  9. const renderAuthorize = Authorized => currentAuthority => {
  10. if (currentAuthority) {
  11. if (typeof currentAuthority === 'function') {
  12. CURRENT = currentAuthority();
  13. }
  14. if (
  15. Object.prototype.toString.call(currentAuthority) === '[object String]' ||
  16. Array.isArray(currentAuthority)
  17. ) {
  18. CURRENT = currentAuthority;
  19. }
  20. } else {
  21. CURRENT = 'NULL';
  22. }
  23. return Authorized;
  24. };
  25. export { CURRENT };
  26. export default Authorized => renderAuthorize(Authorized);