Salesforce Aura UtilityBar获取主屏幕URL

问题描述

我正在根据用户当前的URL开发一些逻辑。当我弹出实用工具栏时,是否可以获取其他Chrome主窗口的URL?这是我的示例代码

组件:

<aura:component implements="flexipage:availableForAllPageTypeslightning:utilityItem" access="global">
    
    <lightning:utilityBaraPI aura:id="MyUtilityBar" />

    <!-- Base init -->
    <aura:handler name="init" value="{!this}" action="{!c.doInit}"/>
    <aura:method name="checkUrl" action="{!c.urlChanged}" />
    <aura:handler event="aura:locationChange" action="{!c.urlChanged}"/>
    
</aura:component>

控制器:

({
    doInit : function(component,event,helper)
    {
        // Check for any changes in record values every 20 seconds since we can't listen for 
        // record edits
        component.checkUrl();

        window.setInterval(
            $A.getCallback(function() {
                component.checkUrl()
            }),20 * 1000
        );
    },urlChanged : function (component,helper) 
    {       
       // This always show the popout url like below when popped out
       // https://blah.lightning.force.com/lightning/popout/utility?0.windowed=true
       console.log(window.location.pathname);
    }
})

如何获取其他窗口或弹出的主窗口的URL?代替

“ https://blah.lightning.force.com/lightning/popout/utility?0.windowed=true”(显示的网址),

我想看类似的东西

“ https://blah.lightning.force.com/lightning/page/home”(主页)

解决方法

暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!

如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。

小编邮箱:dio#foxmail.com (将#修改为@)