代码之家  ›  专栏  ›  技术社区  ›  ic3

启动iCube report时,如何获取用户名

  •  2
  • ic3  · 技术社区  · 7 年前

    在ic3Report中。html文件,是否可以在回调函数中获取用户名?

    var options = {
            root: "ic3-report/app/",
            rootLocal: "ic3-report/app-local/",
            rootVersion: "_IC3_ROOT_VERSION_",
            callback: function () {
                $('#intro').remove();
                window.ic3application = ic3.startReport(
                        {
                            <!-- ic3-start-report-options (DO NOT REMOVE - USED TO GENERATE FILES) -->
                        });
               // get user name here !
            }
    
        };
    
    1 回复  |  直到 7 年前
        1
  •  2
  •   ic3    7 年前

    为了收集当前用户信息,您应该设置GVI配置。可以采用适当的方法:

    var options = {
        root: "ic3-report/app/",
        rootLocal: "ic3-report/app-local/",
        rootVersion: "_IC3_ROOT_VERSION_",
        callback: function () {
            $('#intro').remove();
            var ic3reporting = new ic3.Reporting(
                        {
                            noticesLevel: ic3.NoticeLevel.INFO,
                            dsSettings: {
                                url: GVI_URL
                            }
                        });
            ic3reporting.setupGVIConfiguration(function () {
                var userName = ic3reporting.userName();
            })
        }
    };
    

    使现代化

    一个更强大的解决方案是将代码添加到本地文件中,这些文件不会被新版本的报告覆盖。您可以使用 中的函数 管理>通用JS 配置

    function ic3bootstrapLocal(options) {  
       var ic3reporting = new ic3.Reporting({
           noticesLevel: ic3.NoticeLevel.INFO,
        });
    
       ic3reporting.setupGVIConfiguration(function(){
          ic3reporting.userName()
          options.callback && options.callback();     
       });        
    }
    
    推荐文章