From b73eca349a07d991e7e963a254f2e4f6d83be766 Mon Sep 17 00:00:00 2001 From: Fine Date: Mon, 28 Aug 2023 19:59:00 +0800 Subject: [PATCH] feat: update paths --- src/layout/components/NavBar.vue | 44 ++++++++++++++++++++------------ 1 file changed, 28 insertions(+), 16 deletions(-) diff --git a/src/layout/components/NavBar.vue b/src/layout/components/NavBar.vue index 2e0972d8..ee19b996 100644 --- a/src/layout/components/NavBar.vue +++ b/src/layout/components/NavBar.vue @@ -62,13 +62,11 @@ limitations under the License. --> const dashboardStore = useDashboardStore(); const selectorStore = useSelectorStore(); const route = useRoute(); - const pageName = ref(""); const pathNames = ref([]); const timeRange = ref(0); resetDuration(); getVersion(); - // getPathNames(); function handleReload() { const gap = appStore.duration.end.getTime() - appStore.duration.start.getTime(); @@ -84,10 +82,6 @@ limitations under the License. --> appStore.setDuration(timeFormat(val)); } - function setConfig(value: string) { - pageName.value = value || ""; - } - function getPathNames() { const dashboard = dashboardStore.currentDashboard; pathNames.value = []; @@ -107,17 +101,35 @@ limitations under the License. --> } } pathNames.value.push(root); - if (dashboard.entity !== MetricCatalog.ALL) { - const d = dashboardStore.dashboards.filter( - (d: DashboardItem) => dashboard.entity === d.entity && dashboard.layer === d.layer, - )[0]; - const id = route.params.id; - const path = `/dashboard/${dashboard.layer}/${dashboard.entity}/${id}/${dashboard.name}`; - pathNames.value.push({ - ...d, - path, - }); + if (dashboard.entity === MetricCatalog.ALL) { + return; } + if (dashboard.entity === MetricCatalog.SERVICE) { + pathNames.value.push({ + name: dashboard.name, + }); + return; + } + const serviceDashboard = dashboardStore.dashboards.filter( + (d: DashboardItem) => MetricCatalog.SERVICE === d.entity && dashboard.layer === d.layer, + )[0]; + if (!serviceDashboard) { + return; + } + const serviceId = route.params.serviceId; + let path = `/dashboard/${serviceDashboard.layer}/${serviceDashboard.entity}/${serviceDashboard.name}`; + if (serviceId) { + path = `/dashboard/${serviceDashboard.layer}/${serviceDashboard.entity}/${serviceId}/${serviceDashboard.name}`; + } + pathNames.value.push( + { + ...serviceDashboard, + path, + }, + { + name: dashboard.name, + }, + ); } async function getVersion() {