• 首页
  • 产品中心
    • 数式Oinone四大产品

      低代码开发平台无代码开发平台集成开发平台AI大模型开发
    • 数式Oinone体系能力

      用户与组织权限管理文件管理消息中心国际化业务审计
    • 数式Oinone核心产品特性

      低无一体面向软件公司场景无限制应用级扩容可分可合
  • 服务中心
    • 客户服务

      预约演示方案咨询私有部署找人定制
    • 开发者

      问答下载
    • Oinone学院

      社区学习

    《精讲面向软件公司的低代码平台——以Oinone为例》

  • 合作伙伴
    渠道申请伙伴名录专家库
  • 关于数式
0571-88757863

Page Design:Customizing User Center Menu


Implementing User Center Menu Replacement Using Extension Points

Ⅰ、Adding pamirs-user-api Dependency in the Project

<dependency>
  <groupId>pro.shushi.pamirs.core</groupId>
  <artifactId>pamirs-user-api</artifactId>
</dependency>

Ⅱ、Implementing Post Extension of TopBarUserBlockAction

  • Implement the HookAfter post-extension interface
  • Add the @Hook annotation to specify it as a post-extension for the construct function of the TopBarUserBlock model: @Hook(model = {TopBarUserBlock.MODEL_MODEL}, fun = {"construct"})

(Ⅰ)Adding User Center Menu

@Component
@Order(1)
@SPI.Service
public class MyTopBarActionExt implements TopBarActionExtendApi {

    public void edit(List<TopBarAction> list) {
        list.add(new TopBarAction("top_demo", "top.Teacher", "uiView9a0caf1d574a42c9847a057a0c4a4ad1", ActionTypeEnum.VIEW, 1)
                 .setDisplayName("商品管理")
                 .setIcon("oinone-gongzuotai")
                );
    }

}

Implementation Effect

(Ⅱ)Replacing Original User Center Menu

  1. Replacing Original Menu Redirection
@Component
public class DemoTopBarUserBlockDataHookAfter implements HookAfter {

    @Override
    @Hook(model = {TopBarUserBlock.MODEL_MODEL}, fun = {"construct"})
    public Object run(Function function, Object ret) {
        if (ret == null) {
            return null;
        }
        TopBarUserBlock result = null;
        if (ret instanceof Object[]) {
            Object[] rets = (Object[]) ((Object[]) ret);
            if (rets.length == 1) {
                result = (TopBarUserBlock) rets[0];
                // Example: Replace User Center: Change Password Menu
                // Query the model's ViewAction by name and model to replace the change password ViewAction
                ViewAction demoViewAction = PamirsSession.getContext().getExtendCache(ActionCacheApi.class).get(Dog.MODEL_MODEL, "changePassword");
                // Set the menu icon
                Map<String, Object> attributes = Optional.ofNullable(demoViewAction.getAttributes()).orElse(new HashMap<>());
                attributes.put("icon", "oinone-xiugaimima");
                demoViewAction.setAttributes(attributes);
                // The 0th index of UserViewAction is the change password ViewAction; replacing with a custom ViewAction achieves the replacement
                result.getUserViewAction().set(0, demoViewAction);
            }
        } else {
            result = (TopBarUserBlock) ret;
        }
        return result;
    }
}
  1. Adding ViewAction Using @UxRouteButton
@Model.model(Dog.MODEL_MODEL)
@Component
@UxRouteButton(
        action = @UxAction(name = "changePassword", displayName = "修改密码"),
        value = @UxRoute(model = Dog.MODEL_MODEL, openType = ActionTargetEnum.DIALOG))
public class DogAction {
}

Ⅲ、Replacing Original Profile Avatar Redirection

  1. Modifying the Redirection Logic Bound to Avatar Click
@Order(10)
@Component
@SPI.Service
public class DemoTopBarUserBlockDataApi implements TopBarUserBlockDataApi {

    @Override
    public TopBarUserBlock extendData(TopBarUserBlock data) {
        // For example, adding a menu: PamirsDemo.MODEL_MODEL: model. MenuuiMenu31f22466735a4abe8e0544b428ed88ac: viewAction's name.
        Action demoViewAction = PamirsSession.getContext().getExtendCache(ActionCacheApi.class).get(PamirsDemo.MODEL_MODEL, "MenuuiMenu31f22466735a4abe8e0544b428ed88ac");
        if (demoViewAction != null){
            AccessResourceInfo info = PageLoadHelper.generatorAccessResourceInfo(TopModule.MODULE_MODULE, demoViewAction);
            AccessResourceInfoSession.setInfo(info);
            String path = ResourcePath.generatorPath(demoViewAction.getModel(), demoViewAction.getName());
            demoViewAction.setSessionPath(path);
            data.setUserAvatarAction(demoViewAction);
        }
        return data;
    }
}
  1. Adding Permission Nodes for Permission Control
@Component
@Order(88)
@SPI.Service
public class MyTestNodeLoadExtend implements PermissionNodeLoadExtendApi {

    @Override
    public List<PermissionNode> buildRootPermissions(PermissionLoadContext loadContext, List<PermissionNode> nodes) {
        PermissionNode root = AuthNodeHelper.createNodeWithTranslate("CustomNode", "自定义节点");
        List<PermissionNode> newNodes = new ArrayList<>();
        newNodes.add(root);
        Action demoViewAction = PamirsSession.getContext().getExtendCache(ActionCacheApi.class).get(PamirsDemo.MODEL_MODEL, "MenuuiMenu31f22466735a4abe8e0544b428ed88ac");

        if (demoViewAction != null) {
            // Add this Action to the permission tree
            // The permission authentication path is concatenated as 【cacheAction.getModel() + cacheAction.getName()】, irrelevant to MODULE, which can be customized here.
            AuthNodeHelper.addNode(newNodes, root, AuthNodeHelper.createActionNode(TopModule.MODULE_MODULE, demoViewAction, root));
        }
        nodes.add(0, root);
        return newNodes;
    }
}
  1. Controlling Profile Avatar Permissions in the Management Center
Edit this page
Last Updated:1/15/26, 4:02 AM
Prev
Page Design:How to Achieve Page Navigation
Next
Project Integration:Nacos as a Registration Center:How to Invoke SpringCloud Services of Other Systems?
默认页脚
Copyright © 2026 Mr.Hope