From d9eccf1d7c83a3a9b6c2714d9d0ea42ce8cda42f Mon Sep 17 00:00:00 2001 From: Qiuxia Fan Date: Wed, 27 Jul 2022 10:56:45 +0800 Subject: [PATCH] update --- src/hooks/useDashboardsSession.ts | 7 +++---- src/views/dashboard/related/trace/Detail.vue | 6 +----- .../related/trace/components/D3Graph/SpanDetail.vue | 4 +--- 3 files changed, 5 insertions(+), 12 deletions(-) diff --git a/src/hooks/useDashboardsSession.ts b/src/hooks/useDashboardsSession.ts index 71e996a5..4be5e7cc 100644 --- a/src/hooks/useDashboardsSession.ts +++ b/src/hooks/useDashboardsSession.ts @@ -17,18 +17,17 @@ import { useDashboardStore } from "@/store/modules/dashboard"; import { LayoutConfig } from "@/types/dashboard"; -export default function getDashboard(param: { +export default function getDashboard(param?: { name: string; layer: string; entity: string; }) { const dashboardStore = useDashboardStore(); + const opt = param || dashboardStore.currentDashboard; const list = JSON.parse(sessionStorage.getItem("dashboards") || "[]"); const dashboard = list.find( (d: { name: string; layer: string; entity: string }) => - d.name === param.name && - d.entity === param.entity && - d.layer === param.layer + d.name === opt.name && d.entity === opt.entity && d.layer === opt.layer ); const all = dashboardStore.layout; const widgets: LayoutConfig[] = []; diff --git a/src/views/dashboard/related/trace/Detail.vue b/src/views/dashboard/related/trace/Detail.vue index c725442d..fd73a875 100644 --- a/src/views/dashboard/related/trace/Detail.vue +++ b/src/views/dashboard/related/trace/Detail.vue @@ -130,7 +130,6 @@ import graphs from "./components/index"; import LogTable from "@/views/dashboard/related/components/LogTable/Index.vue"; import { ElMessage } from "element-plus"; import getDashboard from "@/hooks/useDashboardsSession"; -import { useDashboardStore } from "@/store/modules/dashboard"; import { LayoutConfig } from "@/types/dashboard"; export default defineComponent({ @@ -147,7 +146,6 @@ export default defineComponent({ const loading = ref(false); const traceId = ref(""); const displayMode = ref("List"); - const dashboardStore = useDashboardStore(); const dateFormat = (date: number, pattern = "YYYY-MM-DD HH:mm:ss") => dayjs(date).format(pattern); @@ -166,9 +164,7 @@ export default defineComponent({ } async function searchTraceLogs() { - const { associationWidget } = getDashboard( - dashboardStore.currentDashboard - ); + const { associationWidget } = getDashboard(); associationWidget( (options.id as any) || "", { diff --git a/src/views/dashboard/related/trace/components/D3Graph/SpanDetail.vue b/src/views/dashboard/related/trace/components/D3Graph/SpanDetail.vue index b769de9f..38e16823 100644 --- a/src/views/dashboard/related/trace/components/D3Graph/SpanDetail.vue +++ b/src/views/dashboard/related/trace/components/D3Graph/SpanDetail.vue @@ -89,7 +89,6 @@ import type { PropType } from "vue"; import dayjs from "dayjs"; import copy from "@/utils/copy"; import getDashboard from "@/hooks/useDashboardsSession"; -import { useDashboardStore } from "@/store/modules/dashboard"; import { LayoutConfig } from "@/types/dashboard"; /*global defineProps, Recordable */ @@ -97,12 +96,11 @@ const options: Recordable = inject("options") || {}; const props = defineProps({ currentSpan: { type: Object as PropType, default: () => ({}) }, }); -const dashboardStore = useDashboardStore(); const { t } = useI18n(); const dateFormat = (date: number, pattern = "YYYY-MM-DD HH:mm:ss") => dayjs(date).format(pattern); async function getTaceLogs() { - const { associationWidget } = getDashboard(dashboardStore.currentDashboard); + const { associationWidget } = getDashboard(); associationWidget( (options.id as any) || "", {