From b697fe471352b9dfa1703191705e32329d592cc8 Mon Sep 17 00:00:00 2001 From: Fine0830 Date: Tue, 14 Jun 2022 17:01:11 +0800 Subject: [PATCH] feat: set a url parameter to activate tab index (#107) --- src/constants/data.ts | 11 ++ src/layout/components/SideBar.vue | 4 +- src/router/browser.ts | 10 +- src/router/dashboard.ts | 119 +++++++++++++++--- src/router/database.ts | 10 +- src/router/functions.ts | 8 +- src/router/general.ts | 11 +- src/router/infrastructure.ts | 9 ++ src/router/k8s.ts | 22 ++++ src/router/selfObservability.ts | 20 ++- src/router/serviceMesh.ts | 37 +++++- src/views/dashboard/controls/Tab.vue | 38 +++++- .../related/topology/components/Graph.vue | 3 + 13 files changed, 270 insertions(+), 32 deletions(-) diff --git a/src/constants/data.ts b/src/constants/data.ts index 5a8bf137..33779df9 100644 --- a/src/constants/data.ts +++ b/src/constants/data.ts @@ -28,15 +28,26 @@ export const Languages = [ export const RoutesMap: { [key: string]: string } = { GeneralServices: "GENERAL", + GeneralServicesActiveTabIndex: "GENERAL", Database: "VIRTUAL_DATABASE", + DatabaseActiveTabIndex: "VIRTUAL_DATABASE", MeshServices: "MESH", + MeshServicesActiveTabIndex: "MESH", ControlPanel: "MESH_CP", + ControlPanelActiveTabIndex: "MESH_CP", DataPanel: "MESH_DP", + DataPanelActiveTabIndex: "MESH_DP", Linux: "OS_LINUX", SkyWalkingServer: "SO11Y_OAP", + SkyWalkingServerActiveTabIndex: "SO11Y_OAP", + SatelliteActiveTabIndex: "SO11Y_SATELLITE", Satellite: "SO11Y_SATELLITE", Functions: "FAAS", + FunctionsActiveTabIndex: "FAAS", Browser: "BROWSER", + BrowserActiveTabIndex: "BROWSER", KubernetesCluster: "K8S", + KubernetesClusterActiveTabIndex: "K8S", KubernetesService: "K8S_SERVICE", + KubernetesServiceActiveTabIndex: "K8S_SERVICE", }; diff --git a/src/layout/components/SideBar.vue b/src/layout/components/SideBar.vue index 34ad6852..44392bc4 100644 --- a/src/layout/components/SideBar.vue +++ b/src/layout/components/SideBar.vue @@ -55,9 +55,9 @@ limitations under the License. --> - {{ t(m.meta.title) }} + {{ m.meta && t(m.meta.title) }} diff --git a/src/router/browser.ts b/src/router/browser.ts index e0633bb6..a7a4eb20 100644 --- a/src/router/browser.ts +++ b/src/router/browser.ts @@ -33,12 +33,20 @@ export const routesBrowser: Array = [ name: "Browser", meta: { title: "browser", - headPath: "/browser", exact: true, }, component: () => import(/* webpackChunkName: "layer" */ "@/views/Layer.vue"), }, + { + path: "/browser/tab/:activeTabIndex", + name: "BrowserActiveTabIndex", + meta: { + notShow: true, + }, + component: () => + import(/* webpackChunkName: "layer" */ "@/views/Layer.vue"), + }, ], }, ]; diff --git a/src/router/dashboard.ts b/src/router/dashboard.ts index 93fc53ac..c985e2fc 100644 --- a/src/router/dashboard.ts +++ b/src/router/dashboard.ts @@ -54,69 +54,156 @@ export const routesDashboard: Array = [ }, }, { - path: "/dashboard/:layerId/:entity/:name", + path: "", + redirect: "/dashboard/:layerId/:entity/:name", + name: "Create", component: () => import( /* webpackChunkName: "dashboards" */ "@/views/dashboard/Edit.vue" ), - name: "Create", meta: { - title: "dashboardEdit", - exact: false, notShow: true, }, + children: [ + { + path: "/dashboard/:layerId/:entity/:name", + component: () => + import( + /* webpackChunkName: "dashboards" */ "@/views/dashboard/Edit.vue" + ), + name: "CreateChild", + }, + { + path: "/dashboard/:layerId/:entity/:name/tab/:activeTabIndex", + component: () => + import( + /* webpackChunkName: "dashboards" */ "@/views/dashboard/Edit.vue" + ), + name: "CreateActiveTabIndex", + }, + ], }, { - path: "/dashboard/:layerId/:entity/:serviceId/:name", + path: "", component: () => import( /* webpackChunkName: "dashboards" */ "@/views/dashboard/Edit.vue" ), name: "View", + redirect: "/dashboard/:layerId/:entity/:serviceId/:name", meta: { - title: "dashboardEdit", - exact: false, notShow: true, }, + children: [ + { + path: "/dashboard/:layerId/:entity/:serviceId/:name", + component: () => + import( + /* webpackChunkName: "dashboards" */ "@/views/dashboard/Edit.vue" + ), + name: "ViewChild", + }, + { + path: "/dashboard/:layerId/:entity/:serviceId/:name/tab/:activeTabIndex", + component: () => + import( + /* webpackChunkName: "dashboards" */ "@/views/dashboard/Edit.vue" + ), + name: "ViewActiveTabIndex", + }, + ], }, { - path: "/dashboard/related/:layerId/:entity/:serviceId/:destServiceId/:name", + path: "", + redirect: + "/dashboard/related/:layerId/:entity/:serviceId/:destServiceId/:name", component: () => import( /* webpackChunkName: "dashboards" */ "@/views/dashboard/Edit.vue" ), name: "ViewServiceRelation", meta: { - title: "dashboardEdit", - exact: false, notShow: true, }, + children: [ + { + path: "/dashboard/related/:layerId/:entity/:serviceId/:destServiceId/:name", + component: () => + import( + /* webpackChunkName: "dashboards" */ "@/views/dashboard/Edit.vue" + ), + name: "ViewServiceRelation", + }, + { + path: "/dashboard/related/:layerId/:entity/:serviceId/:destServiceId/:name/tab/:activeTabIndex", + component: () => + import( + /* webpackChunkName: "dashboards" */ "@/views/dashboard/Edit.vue" + ), + name: "ViewServiceRelationActiveTabIndex", + }, + ], }, { - path: "/dashboard/:layerId/:entity/:serviceId/:podId/:name", + path: "", + redirect: "/dashboard/:layerId/:entity/:serviceId/:podId/:name", component: () => import( /* webpackChunkName: "dashboards" */ "@/views/dashboard/Edit.vue" ), name: "ViewPod", meta: { - title: "dashboardEdit", - exact: false, notShow: true, }, + children: [ + { + path: "/dashboard/:layerId/:entity/:serviceId/:podId/:name", + component: () => + import( + /* webpackChunkName: "dashboards" */ "@/views/dashboard/Edit.vue" + ), + name: "ViewPod", + }, + { + path: "/dashboard/:layerId/:entity/:serviceId/:podId/:name/tab/:activeTabIndex", + component: () => + import( + /* webpackChunkName: "dashboards" */ "@/views/dashboard/Edit.vue" + ), + name: "ViewPodActiveTabIndex", + }, + ], }, { - path: "/dashboard/:layerId/:entity/:serviceId/:podId/:destServiceId/:destPodId/:name", + path: "", + redirect: + "/dashboard/:layerId/:entity/:serviceId/:podId/:destServiceId/:destPodId/:name", component: () => import( /* webpackChunkName: "dashboards" */ "@/views/dashboard/Edit.vue" ), name: "ViewPodRelation", meta: { - title: "dashboardEdit", - exact: true, notShow: true, }, + children: [ + { + path: "/dashboard/:layerId/:entity/:serviceId/:podId/:destServiceId/:destPodId/:name", + component: () => + import( + /* webpackChunkName: "dashboards" */ "@/views/dashboard/Edit.vue" + ), + name: "ViewPodRelation", + }, + { + path: "/dashboard/:layerId/:entity/:serviceId/:podId/:destServiceId/:destPodId/:name/tab/:activeTabIndex", + component: () => + import( + /* webpackChunkName: "dashboards" */ "@/views/dashboard/Edit.vue" + ), + name: "ViewPodRelationActiveTabIndex", + }, + ], }, ], }, diff --git a/src/router/database.ts b/src/router/database.ts index 7dc0653c..70b82b35 100644 --- a/src/router/database.ts +++ b/src/router/database.ts @@ -34,12 +34,20 @@ export const routesDatabase: Array = [ name: "Database", meta: { title: "virtualDatabase", - headPath: "/database", exact: true, }, component: () => import(/* webpackChunkName: "layer" */ "@/views/Layer.vue"), }, + { + path: "/database/tab/:activeTabIndex", + name: "DatabaseActiveTabIndex", + meta: { + notShow: true, + }, + component: () => + import(/* webpackChunkName: "layer" */ "@/views/Layer.vue"), + }, ], }, ]; diff --git a/src/router/functions.ts b/src/router/functions.ts index be1fa338..ddafec92 100644 --- a/src/router/functions.ts +++ b/src/router/functions.ts @@ -32,13 +32,17 @@ export const routesFunctions: Array = [ path: "/functions", name: "Functions", meta: { - title: "functions", - headPath: "/functions", exact: true, }, component: () => import(/* webpackChunkName: "layer" */ "@/views/Layer.vue"), }, + { + path: "/functions/tab/:activeTabIndex", + name: "FunctionsActiveTabIndex", + component: () => + import(/* webpackChunkName: "layer" */ "@/views/Layer.vue"), + }, ], }, ]; diff --git a/src/router/general.ts b/src/router/general.ts index 393b94f3..e9bb7b8f 100644 --- a/src/router/general.ts +++ b/src/router/general.ts @@ -33,8 +33,15 @@ export const routesGen: Array = [ path: "/general", name: "GeneralServices", meta: { - title: "services", - headPath: "/general/service", + exact: true, + }, + component: () => + import(/* webpackChunkName: "layers" */ "@/views/Layer.vue"), + }, + { + path: "/general/tab/:activeTabIndex", + name: "GeneralServicesActiveTabIndex", + meta: { exact: true, }, component: () => diff --git a/src/router/infrastructure.ts b/src/router/infrastructure.ts index 86bb55ee..555953f5 100644 --- a/src/router/infrastructure.ts +++ b/src/router/infrastructure.ts @@ -39,6 +39,15 @@ export const routesInfra: Array = [ component: () => import(/* webpackChunkName: "layer" */ "@/views/Layer.vue"), }, + { + path: "/linux/tab/:activeTabIndex", + name: "LinuxActiveTabIndex", + meta: { + title: "linux", + }, + component: () => + import(/* webpackChunkName: "layer" */ "@/views/Layer.vue"), + }, // { // path: "/infrastructure/vm", // name: "VirtualMachine", diff --git a/src/router/k8s.ts b/src/router/k8s.ts index 38adf3f7..a9390bd8 100644 --- a/src/router/k8s.ts +++ b/src/router/k8s.ts @@ -33,20 +33,42 @@ export const routesK8s: Array = [ path: "/kubernetes/cluster", name: "KubernetesCluster", meta: { + notShow: false, title: "kubernetesCluster", }, component: () => import(/* webpackChunkName: "layer" */ "@/views/Layer.vue"), }, + { + path: "/kubernetes/cluster/tab/:activeTabIndex", + name: "KubernetesClusterActiveTabIndex", + meta: { + notShow: true, + title: "kubernetesClusterActiveTabIndex", + }, + component: () => + import(/* webpackChunkName: "layer" */ "@/views/Layer.vue"), + }, { path: "/kubernetes/service", name: "KubernetesService", meta: { + notShow: false, title: "kubernetesService", }, component: () => import(/* webpackChunkName: "layer" */ "@/views/Layer.vue"), }, + { + path: "/kubernetes/service/tab/:activeTabIndex", + name: "KubernetesServiceActiveTabIndex", + meta: { + notShow: true, + title: "kubernetesServiceActiveTabIndex", + }, + component: () => + import(/* webpackChunkName: "layer" */ "@/views/Layer.vue"), + }, ], }, ]; diff --git a/src/router/selfObservability.ts b/src/router/selfObservability.ts index 4174e1bb..b2e610b1 100644 --- a/src/router/selfObservability.ts +++ b/src/router/selfObservability.ts @@ -34,7 +34,15 @@ export const routesSelf: Array = [ name: "SkyWalkingServer", meta: { title: "skyWalkingServer", - headPath: "/mesh/services", + }, + component: () => + import(/* webpackChunkName: "layer" */ "@/views/Layer.vue"), + }, + { + path: "/self/skyWalkingServer/tab/:activeTabIndex", + name: "SkyWalkingServerActiveTabIndex", + meta: { + notShow: true, }, component: () => import(/* webpackChunkName: "layer" */ "@/views/Layer.vue"), @@ -44,7 +52,15 @@ export const routesSelf: Array = [ name: "Satellite", meta: { title: "satellite", - headPath: "/mesh/controlPanel", + }, + component: () => + import(/* webpackChunkName: "layer" */ "@/views/Layer.vue"), + }, + { + path: "/self/satellite/tab/:activeTabIndex", + name: "SatelliteActiveTabIndex", + meta: { + notShow: true, }, component: () => import(/* webpackChunkName: "layer" */ "@/views/Layer.vue"), diff --git a/src/router/serviceMesh.ts b/src/router/serviceMesh.ts index 719fae43..04df1bb2 100644 --- a/src/router/serviceMesh.ts +++ b/src/router/serviceMesh.ts @@ -33,8 +33,17 @@ export const routesMesh: Array = [ path: "/mesh/services", name: "MeshServices", meta: { + notShow: false, title: "services", - headPath: "/mesh/services", + }, + component: () => + import(/* webpackChunkName: "layer" */ "@/views/Layer.vue"), + }, + { + path: "/mesh/services/tab/:activeTabIndex", + name: "MeshServicesActiveTabIndex", + meta: { + notShow: true, }, component: () => import(/* webpackChunkName: "layer" */ "@/views/Layer.vue"), @@ -43,8 +52,17 @@ export const routesMesh: Array = [ path: "/mesh/controlPanel", name: "ControlPanel", meta: { + notShow: false, title: "controlPanel", - headPath: "/mesh/controlPanel", + }, + component: () => + import(/* webpackChunkName: "layer" */ "@/views/Layer.vue"), + }, + { + path: "/mesh/controlPanel/tab/:activeTabIndex", + name: "ControlPanelActiveTabIndex", + meta: { + notShow: true, }, component: () => import(/* webpackChunkName: "layer" */ "@/views/Layer.vue"), @@ -53,10 +71,21 @@ export const routesMesh: Array = [ path: "/mesh/dataPanel", name: "DataPanel", meta: { + notShow: false, title: "dataPanel", - headPath: "/mesh/dataPanel", }, - component: () => import("@/views/Layer.vue"), + component: () => + import(/* webpackChunkName: "layer" */ "@/views/Layer.vue"), + }, + { + path: "/mesh/dataPanel/tab/:activeTabIndex", + name: "DataPanelActiveTabIndex", + meta: { + notShow: true, + title: "dataPanelActiveTabIndex", + }, + component: () => + import(/* webpackChunkName: "layer" */ "@/views/Layer.vue"), }, ], }, diff --git a/src/views/dashboard/controls/Tab.vue b/src/views/dashboard/controls/Tab.vue index 50642870..2efe3419 100644 --- a/src/views/dashboard/controls/Tab.vue +++ b/src/views/dashboard/controls/Tab.vue @@ -40,7 +40,14 @@ limitations under the License. --> - + + + + + + + + @@ -99,6 +106,7 @@ limitations under the License. -->