From 245f87ef3502bf6a0fdfb2dd8330343fac74767c Mon Sep 17 00:00:00 2001 From: zyycn Date: Sun, 26 Jul 2026 21:57:25 +0800 Subject: [PATCH] refactor(web): share dashboard tone maps and retire dead surfaces Hoist the tone-to-class maps duplicated between MetricCard and AccountOverviewCard into dashboard constants, move the generic ECharts tooltip parameter helpers to components/charts/tooltip.ts shared by the dashboard trend chart and usage charts, derive the health popover's segment and metric lists from one outcome metadata source, and rebuild useOpsErrorsTable on the shared usePagedQuery composable (same stale-response guard and empty-page clamp, first-paint loading preserved). Remove the dead trend-loading prop chain, the unused showAvatar prop, and two unused exports. Built CSS unchanged. Co-authored-by: Claude --- frontend/src/components/charts/tooltip.ts | 14 +++ .../components/AccountIdentityCell.vue | 3 - .../composables/useAccountConnectionTest.ts | 28 +++++- frontend/src/views/accounts/constants.ts | 2 +- .../components/AccountOverviewCard.vue | 31 +++---- .../components/HealthTimelinePointPopover.vue | 50 ++++------ .../views/dashboard/components/MetricCard.vue | 23 +---- .../dashboard/components/RequestTrendCard.vue | 1 - .../views/dashboard/composables/presenter.ts | 2 +- .../dashboard/composables/useDashboard.ts | 23 +---- .../composables/useRequestTrendChart.ts | 8 +- frontend/src/views/dashboard/constants.ts | 19 ++++ frontend/src/views/dashboard/index.vue | 2 - .../usage/composables/useOpsErrorsTable.ts | 92 +++++++------------ frontend/src/views/usage/utils/chart.ts | 13 +-- 15 files changed, 132 insertions(+), 179 deletions(-) create mode 100644 frontend/src/components/charts/tooltip.ts diff --git a/frontend/src/components/charts/tooltip.ts b/frontend/src/components/charts/tooltip.ts new file mode 100644 index 000000000..2fc1c6c4d --- /dev/null +++ b/frontend/src/components/charts/tooltip.ts @@ -0,0 +1,14 @@ +// ECharts tooltip 回调参数的通用安全取值:参数形状不受控(数组/对象混合), +// 统一在此收敛类型判断。 +export function tooltipRows(params: unknown): Record[] { + const values = Array.isArray(params) ? params : [params] + return values.filter( + (value): value is Record => typeof value === 'object' && value !== null, + ) +} + +export function tooltipIndex(source: unknown) { + if (typeof source !== 'object' || source === null || !('dataIndex' in source)) + return -1 + return typeof source.dataIndex === 'number' ? source.dataIndex : -1 +} diff --git a/frontend/src/views/accounts/components/AccountIdentityCell.vue b/frontend/src/views/accounts/components/AccountIdentityCell.vue index a5787f95e..08e05a2e9 100644 --- a/frontend/src/views/accounts/components/AccountIdentityCell.vue +++ b/frontend/src/views/accounts/components/AccountIdentityCell.vue @@ -14,14 +14,12 @@ const props = withDefaults( account: AccountIdentity size?: 'md' | 'lg' showPlan?: boolean - showAvatar?: boolean titleMode?: 'local-part' | 'email' metaPosition?: 'title' | 'secondary' }>(), { size: 'md', showPlan: false, - showAvatar: true, titleMode: 'local-part', metaPosition: 'title', }, @@ -72,7 +70,6 @@ const avatarClass = computed(() => {