1.工程中引起pamirs-user-api
<dependency>
<groupId>pro.shushi.pamirs.core</groupId>
<artifactId>pamirs-user-api</artifactId>
</dependency>
2.实现扩展接口TopBarUserBlockDataApi
/**
* 自定义扩展TopBarUserBlock
*/
@Order(10)
@Component
@SPI.Service
public class DemoTopBarUserBlockDataApi implements TopBarUserBlockDataApi {
@Override
public TopBarUserBlock extendData(TopBarUserBlock data) {
List<TopBarActionGroup> actionGroups = data.getActionGroups();
TopBarActionGroup actionGroup = new TopBarActionGroup();
List<Action> actions = new ArrayList<>();
//例如增加一个菜单
ViewAction demoViewAction = new ViewAction().setName("DemoMenus_ItemPMenu_DemoItemMenu").setModel(ProducePlanDetail.MODEL_MODEL).queryOne();
if(demoViewAction != null){
//设置菜单的icon
Map<String, Object> attributes = Optional.ofNullable(demoViewAction.getAttributes()).orElse(new HashMap<>());
attributes.put("icon", "oinone-xiugaimima");
demoViewAction.setAttributes(attributes);
actions.add(demoViewAction);
actionGroup.setActions(actions);
}
//例如增加一个菜单
ViewAction demoViewAction2 = new ViewAction().setName("DemoMenus_ItemPMenu_DemoItemCategoryMenu").setModel(ProducePlanDetail.MODEL_MODEL).queryOne();
if(demoViewAction2 != null){
//设置菜单2的icon
Map<String, Object> attributes = Optional.ofNullable(demoViewAction2.getAttributes()).orElse(new HashMap<>());
attributes.put("icon", "oinone-xiugaimima");
demoViewAction2.setAttributes(attributes);
actions.add(demoViewAction2);
actionGroup.setActions(actions);
}
actionGroups.add(new TopBarActionGroup().setActions(actions));
data.setActionGroups(actionGroups);
return data;
}
}
实现效果
Oinone社区 作者:数式-海波原创文章,如若转载,请注明出处:https://doc.oinone.top/backend/4764.html
访问Oinone官网:https://www.oinone.top获取数式Oinone低代码应用平台体验