Browse Source

📌 versions: up @umijs/fabric

pull/6894/head
chenshuai2144 6 years ago
parent
commit
d301e01a9f
  1. 2
      package.json
  2. 20
      src/components/Authorized/CheckPermissions.tsx

2
package.json

@ -86,7 +86,7 @@
"@types/react": "^16.9.17",
"@types/react-dom": "^16.8.4",
"@types/react-helmet": "^5.0.13",
"@umijs/fabric": "^2.0.5",
"@umijs/fabric": "^2.2.0",
"@umijs/plugin-blocks": "^2.0.5",
"@umijs/preset-ant-design-pro": "^1.2.0",
"@umijs/preset-react": "^1.4.8",

20
src/components/Authorized/CheckPermissions.tsx

@ -57,19 +57,15 @@ const checkPermissions = <T, K>(
}
// Function 处理
if (typeof authority === 'function') {
try {
const bool = authority(currentAuthority);
// 函数执行后返回值是 Promise
if (bool instanceof Promise) {
return <PromiseRender<T, K> ok={target} error={Exception} promise={bool} />;
}
if (bool) {
return target;
}
return Exception;
} catch (error) {
throw error;
const bool = authority(currentAuthority);
// 函数执行后返回值是 Promise
if (bool instanceof Promise) {
return <PromiseRender<T, K> ok={target} error={Exception} promise={bool} />;
}
if (bool) {
return target;
}
return Exception;
}
throw new Error('unsupported parameters');
};

Loading…
Cancel
Save