onetwo icon indicating copy to clipboard operation
onetwo copied to clipboard

菜单类需要根据环境来决定是否使用

Open wayshall opened this issue 2 years ago • 1 comments

菜单类需要根据环境(开发、测试或者生产)来决定是否使用。 比如有些菜单并不希望在生产的环境中暴露出来。

wayshall avatar May 30 '22 17:05 wayshall

可通过菜单提供者类新增的rootMenuClassListByProfiles方法控制:

@Configuration
public class MgrConfiguration {
    @Bean
    public RootMenuClassProvider menuConfig() {
    	return new TestRootMenuClassProvider();
    }
    
    public static class TestRootMenuClassProvider implements RootMenuClassProvider {

		@Override
		public List<Class<?>> rootMenuClassList() {
	        return Arrays.asList(CommonMgr.class);
		}
		
		public List<Class<?>> rootMenuClassListByProfiles(Collection<String> profiles) {
			if (profiles.contains("dev")) {
		             return Arrays.asList(
		        				DevMgr1.class, 
		        				DevMgr2.class
		        			);
			}
			return Collections.emptyList();
		};
    	
    }
}

wayshall avatar May 30 '22 18:05 wayshall