diff --git a/bk_dataview/grafana/settings.py b/bk_dataview/grafana/settings.py index 520edb66b..4ccf7c0d2 100644 --- a/bk_dataview/grafana/settings.py +++ b/bk_dataview/grafana/settings.py @@ -57,29 +57,44 @@ ) + f"""window.ageisId = "{settings.TAM_AEGIS_KEY}";""" + """ -{} - -var _wr = function(type) {{ +setTimeout(function(){ + if(window.ageisId) { + const aegis = new Aegis({ + id: window.ageisId, // 项目ID + uin: window.grafanaBootData ? (window.grafanaBootData.user ? window.grafanaBootData.user.name : "dev") : "dev", + reportApiSpeed: true, // 接口测速 + reportAssetSpeed: true, // 静态资源测速 + pagePerformance: true, // 页面测速 + onError: true, // 当前实例是否需要进行错误监听,获取错误日志 + delay: 1000, // 上报节流时间,在该时间段内的上报将会合并到一个上报请求中 + repeat: 5, // 重复上报次数,对于同一个错误超过多少次不上报 + offlineLog: false, // 是否使用离线日志 + restfulApiList: [], // 当开启了接口测速,且项目中有些接口采用了 restful 规范,需要在该配置中列出,帮助 Aegis 识别哪些接口是同一条接 + spa: true + }) + } +},5000); +var _wr = function(type) { var orig = history[type]; - return function() {{ + return function() { var rv = orig.apply(this, arguments); var e = new Event(type); e.arguments = arguments; window.dispatchEvent(e); return rv; - }}; -}}; + }; +}; history.pushState = _wr('pushState'); history.replaceState = _wr('replaceState'); - ["popstate", "replaceState", "pushState"].forEach(function(eventName) {{ - window.addEventListener(eventName, function() {{ - window.parent.postMessage({{ pathname: this.location.pathname }}, "*"); - }}); - }}); - window.addEventListener('message', function(e) {{ - if(e && e.data ) {{ + ["popstate", "replaceState", "pushState"].forEach(function(eventName) { + window.addEventListener(eventName, function() { + window.parent.postMessage({ pathname: this.location.pathname }, "*"); + }); + }); + window.addEventListener('message', function(e) { + if(e && e.data ) { var dom = null; - switch(e.data) {{ + switch(e.data) { case 'create': dom = document.querySelector('.sidemenu__top .sidemenu-item:nth-child(2) .dropdown-menu li:nth-child(2) a'); break; @@ -89,33 +104,12 @@ case 'import': dom = document.querySelector('.sidemenu__top .sidemenu-item:nth-child(2) .dropdown-menu li:nth-child(4) a'); break; - }} + } dom && dom.click() - }} - }}) + } + }) - """.format( - """ -setTimeout(function(){ - if(window.ageisId) { - const aegis = new Aegis({ - id: window.ageisId, // 项目ID - uin: window.grafanaBootData ? (window.grafanaBootData.user ? window.grafanaBootData.user.name : "dev") : "dev", - reportApiSpeed: true, // 接口测速 - reportAssetSpeed: true, // 静态资源测速 - pagePerformance: true, // 页面测速 - onError: true, // 当前实例是否需要进行错误监听,获取错误日志 - delay: 1000, // 上报节流时间,在该时间段内的上报将会合并到一个上报请求中 - repeat: 5, // 重复上报次数,对于同一个错误超过多少次不上报 - offlineLog: false, // 是否使用离线日志 - restfulApiList: [], // 当开启了接口测速,且项目中有些接口采用了 restful 规范,需要在该配置中列出,帮助 Aegis 识别哪些接口是同一条接 - spa: true - }) - } -},5000);""" - if settings.TAM_AEGIS_KEY - else "" - ) + """ }, "BACKEND_CLASS": "bk_dataview.grafana.backends.api.APIHandler", } diff --git a/web/src/components/nav/head-nav.vue b/web/src/components/nav/head-nav.vue index 12fe8151f..eb470852e 100644 --- a/web/src/components/nav/head-nav.vue +++ b/web/src/components/nav/head-nav.vue @@ -755,7 +755,7 @@ export default { resMenu.children.forEach((item) => { item.id = this.routeMap[item.id] || item.id; if (resMenu.id === 'dashboard') { - item.id = item.id.replace(/_/g, '-'); + item.id = item.id.replace(/-/g, '_'); } const menu = oldMenu.children.find(menuItem => menuItem.id === item.id); if (menu) {