From 3c03f222316c633bccf0b543296890e44f27ffe5 Mon Sep 17 00:00:00 2001 From: afc163 Date: Sat, 13 Jan 2018 19:46:35 +0800 Subject: [PATCH] Fix firefox error, close #677 --- src/components/Authorized/CheckPermissions.js | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/src/components/Authorized/CheckPermissions.js b/src/components/Authorized/CheckPermissions.js index c1d6647d..a62deed4 100644 --- a/src/components/Authorized/CheckPermissions.js +++ b/src/components/Authorized/CheckPermissions.js @@ -1,6 +1,11 @@ import React from 'react'; import PromiseRender from './PromiseRender'; import { CURRENT } from './index'; + +function isPromise(obj) { + return !!obj && (typeof obj === 'object' || typeof obj === 'function') && typeof obj.then === 'function'; +} + /** * 通用权限检查方法 * Common check permissions method @@ -32,7 +37,7 @@ const checkPermissions = (authority, currentAuthority, target, Exception) => { } // Promise 处理 - if (authority.constructor.name === 'Promise') { + if (isPromise(authority)) { return () => ( ); -- GitLab