Browse Source

Fix firefox error, close #677

afc163 8 years ago
parent
commit
3c03f22231
1 changed files with 6 additions and 1 deletions
  1. 6 1
      src/components/Authorized/CheckPermissions.js

+ 6 - 1
src/components/Authorized/CheckPermissions.js

@@ -1,6 +1,11 @@
 import React from 'react';
 import React from 'react';
 import PromiseRender from './PromiseRender';
 import PromiseRender from './PromiseRender';
 import { CURRENT } from './index';
 import { CURRENT } from './index';
+
+function isPromise(obj) {
+  return !!obj && (typeof obj === 'object' || typeof obj === 'function') && typeof obj.then === 'function';
+}
+
 /**
 /**
  * 通用权限检查方法
  * 通用权限检查方法
  * Common check permissions method
  * Common check permissions method
@@ -32,7 +37,7 @@ const checkPermissions = (authority, currentAuthority, target, Exception) => {
   }
   }
 
 
   // Promise 处理
   // Promise 处理
-  if (authority.constructor.name === 'Promise') {
+  if (isPromise(authority)) {
     return () => (
     return () => (
       <PromiseRender ok={target} error={Exception} promise={authority} />
       <PromiseRender ok={target} error={Exception} promise={authority} />
     );
     );