Przeglądaj źródła

📌 versions: up @umijs/fabric

chenshuai2144 5 lat temu
rodzic
commit
d301e01a9f
2 zmienionych plików z 9 dodań i 13 usunięć
  1. 1 1
      package.json
  2. 8 12
      src/components/Authorized/CheckPermissions.tsx

+ 1 - 1
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",

+ 8 - 12
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');
 };