mirror of
				https://github.com/pure-admin/vue-pure-admin.git
				synced 2025-11-03 13:44:47 +08:00 
			
		
		
		
	feat: add hasPermissions util
This commit is contained in:
		
							parent
							
								
									653bafaa2b
								
							
						
					
					
						commit
						e97bd9c8c4
					
				@ -249,11 +249,31 @@ const getHistoryMode = (): RouterHistory => {
 | 
			
		||||
  }
 | 
			
		||||
};
 | 
			
		||||
 | 
			
		||||
// 是否有权限
 | 
			
		||||
const hasPermissions = (value: Array<string>): boolean => {
 | 
			
		||||
  if (value && value instanceof Array && value.length > 0) {
 | 
			
		||||
    const roles = usePermissionStoreHook().buttonAuth;
 | 
			
		||||
    const permissionRoles = value;
 | 
			
		||||
 | 
			
		||||
    const hasPermission = roles.some(role => {
 | 
			
		||||
      return permissionRoles.includes(role);
 | 
			
		||||
    });
 | 
			
		||||
 | 
			
		||||
    if (!hasPermission) {
 | 
			
		||||
      return false;
 | 
			
		||||
    }
 | 
			
		||||
    return true;
 | 
			
		||||
  } else {
 | 
			
		||||
    return false;
 | 
			
		||||
  }
 | 
			
		||||
};
 | 
			
		||||
 | 
			
		||||
export {
 | 
			
		||||
  ascending,
 | 
			
		||||
  filterTree,
 | 
			
		||||
  initRouter,
 | 
			
		||||
  resetRouter,
 | 
			
		||||
  hasPermissions,
 | 
			
		||||
  getHistoryMode,
 | 
			
		||||
  addAsyncRoutes,
 | 
			
		||||
  delAliveRoutes,
 | 
			
		||||
 | 
			
		||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user