门户定制案例-调整功能树宽度

运行效果

系统默认功能树宽度为300,如下图所示

1757483554592

调整为200,如下图所示

1757484944848

实现方法

  • 定制企业门户应用,参考《门户定制
  • 在门户页 /entry/pcxapp/pcx/index.w 中,onInitState 是初始化状态方法,使用 @after 追加对于 state 的赋值
  • state 中的 siderWidth 用于设置功能树宽度

添加扩展点

桌面端门户的扩展点方法写在 /UI2/comp/portalConfig/components/portalConfig/portalConfig.config.pc.js 文件的 onConfigContextInit 方法中,如果没有 portalConfig.config.pc.js 文件,将 portalConfig.config.js 文件复制为 portalConfig.config.pc.js 文件

添加门户页 /entry/pcxapp/pcx/index.w 初始化状态方法 onInitState 的 after 扩展点,此时的 result 就是 state,设置 siderWidth 作为功能树的宽度,代码如下

    async onConfigContextInit(configContextProcessor) {
        //获取当前页面
        let _this = configContextProcessor.page;
        let portalConfig = {
            "config": {
                "/entry": {
                    "/pcxapp": {
                        "/pcx": {
                            "/index.w": {
                                "onInitState":{
                                    "@after": async (result,...args)=>{
                                        result.siderWidth = 200;
                                        return result;
                                    }
                                }
                            }
                        }
                    }
                }
            }
        };
        merge(_this.configContext, portalConfig);
        ConfigContextProcessor.enhancePageAdvice(_this);
    }

完整代码

/UI2/comp/portalConfig/components/portalConfig/portalConfig.config.pc.js 文件的完整代码如下

import { merge } from "lodash";
import ConfigContextProcessor from 'core/framework/ConfigContextProcessor';
import React from 'react';

export default {

    processConfigContext(configContext) {
    },

    //自定义
    async onConfigContextInit(configContextProcessor) {
        //获取当前页
        let _this = configContextProcessor.page;

        let portalConfig = {
            "config": {  
                "/entry": {
                    "/pcxapp": {
                        "/pcx": {
                            "/index.w": {
                                "onInitState":{
                                    "@after": async (result,...args)=>{
                                        result.siderWidth = 200;
                                        return result;
                                    }
                                }
                            }
                        }
                    }
                }
            }
        };
        //处理自定义内容
        merge(_this.configContext, portalConfig);
        ConfigContextProcessor.enhancePageAdvice(_this);
    }
}

results matching ""

    No results matching ""