如何增强SAPUI5应用的About对话框并添加额外属性?
增强SAPUI5应用的「About」对话框显示额外属性的方案

当然可以增强FLP的「About」对话框来显示额外属性,你之前尝试的标准视图扩展方案不适用,因为这个对话框属于FLP Shell层面的组件,而非应用自身的视图。以下是两种可行的实现方案:
方法一:通过FLP插件自定义对话框内容
FLP支持通过插件扩展Shell功能,核心思路是覆盖默认的showAbout方法,自定义对话框的内容组件:
- 创建FLP插件文件,示例代码如下:
sap.ui.define([ "sap/ushell/services/ShellUIService", "sap/m/Dialog", "sap/m/VBox", "sap/m/Text", "sap/m/Button" ], function(ShellUIService, Dialog, VBox, Text, Button) { "use strict"; return ShellUIService.extend("custom.plugins.AboutEnhancer", { init: function() { const oShell = this.getShell(); // 保存原始方法,按需保留原有内容 const fnOriginalShowAbout = oShell.showAbout.bind(oShell); // 覆盖默认的showAbout方法 oShell.showAbout = () => { // 构建自定义内容,添加额外属性 const oCustomContent = new VBox({ items: [ new Text({ text: "应用名称: 我的Fiori应用" }), new Text({ text: "应用版本: v2.1.0" }), new Text({ text: "构建时间: 2024-05-20" }), new Text({ text: "业务线标识: SALES-APP-001" }), new Text({ text: "维护团队: 前端开发组" }) ], spacing: "0.5rem" }); const oDialog = new Dialog({ title: "关于应用", content: oCustomContent, endButton: new Button({ text: "确定", press: () => oDialog.close() }), afterClose: () => oDialog.destroy() }); oDialog.open(); // 若需保留原始对话框,取消下方注释 // fnOriginalShowAbout(); }; } }); });
- 在FLP的全局配置中注册该插件,确保FLP启动时加载生效。
方法二:在应用Component中动态修改
如果只需要针对单个应用增强,可在应用的Component.js中获取Shell实例,修改对话框内容:
sap.ui.define([ "sap/ui/core/UIComponent", "sap/ushell/Container" ], function(UIComponent, Container) { "use strict"; return UIComponent.extend("my.app.Component", { metadata: { manifest: "json" }, init: function() { UIComponent.prototype.init.apply(this, arguments); // 获取FLP Shell实例 const oShell = Container.getService("ShellUIService").getShell(); const fnOriginalShowAbout = oShell.showAbout.bind(oShell); oShell.showAbout = () => { // 自定义内容逻辑同方法一,此处省略 // ... }; } }); });
关键注意事项
- 不同版本FLP的Shell API可能存在差异,需对应参考SAP官方文档调整代码。
- 自定义对话框时建议使用SAPUI5标准控件,保持与FLP原生风格一致,避免样式冲突。
- 若需保留原始对话框内容,可在自定义方法中调用保存的
fnOriginalShowAbout,或合并原生内容与自定义内容。
内容的提问来源于stack exchange,提问作者Michael Sturm
相关产品推荐
相关产品推荐

