From cc4d82f932081ce0edb39f669659a716a479d1f0 Mon Sep 17 00:00:00 2001 From: lyzno1 <92089059+lyzno1@users.noreply.github.com> Date: Thu, 14 Aug 2025 09:22:27 +0800 Subject: [PATCH] fix(web): resolve TypeScript errors in app overview components (#23901) --- .../(appDetailLayout)/[appId]/overview/card-view.tsx | 4 ++-- .../[appId]/overview/chart-view.tsx | 4 ++-- .../app/overview/{appCard.tsx => app-card.tsx} | 12 ++++++++---- .../app/overview/{appChart.tsx => app-chart.tsx} | 2 +- 4 files changed, 13 insertions(+), 9 deletions(-) rename web/app/components/app/overview/{appCard.tsx => app-card.tsx} (98%) rename web/app/components/app/overview/{appChart.tsx => app-chart.tsx} (99%) diff --git a/web/app/(commonLayout)/app/(appDetailLayout)/[appId]/overview/card-view.tsx b/web/app/(commonLayout)/app/(appDetailLayout)/[appId]/overview/card-view.tsx index 3d572b926..e58e79918 100644 --- a/web/app/(commonLayout)/app/(appDetailLayout)/[appId]/overview/card-view.tsx +++ b/web/app/(commonLayout)/app/(appDetailLayout)/[appId]/overview/card-view.tsx @@ -3,7 +3,7 @@ import type { FC } from 'react' import React from 'react' import { useTranslation } from 'react-i18next' import { useContext } from 'use-context-selector' -import AppCard from '@/app/components/app/overview/appCard' +import AppCard from '@/app/components/app/overview/app-card' import Loading from '@/app/components/base/loading' import MCPServiceCard from '@/app/components/tools/mcp/mcp-service-card' import { ToastContext } from '@/app/components/base/toast' @@ -17,7 +17,7 @@ import type { App } from '@/types/app' import type { UpdateAppSiteCodeResponse } from '@/models/app' import { asyncRunSafe } from '@/utils' import { NEED_REFRESH_APP_LIST_KEY } from '@/config' -import type { IAppCardProps } from '@/app/components/app/overview/appCard' +import type { IAppCardProps } from '@/app/components/app/overview/app-card' import { useStore as useAppStore } from '@/app/components/app/store' export type ICardViewProps = { diff --git a/web/app/(commonLayout)/app/(appDetailLayout)/[appId]/overview/chart-view.tsx b/web/app/(commonLayout)/app/(appDetailLayout)/[appId]/overview/chart-view.tsx index 09d3e4317..847de1916 100644 --- a/web/app/(commonLayout)/app/(appDetailLayout)/[appId]/overview/chart-view.tsx +++ b/web/app/(commonLayout)/app/(appDetailLayout)/[appId]/overview/chart-view.tsx @@ -3,8 +3,8 @@ import React, { useState } from 'react' import dayjs from 'dayjs' import quarterOfYear from 'dayjs/plugin/quarterOfYear' import { useTranslation } from 'react-i18next' -import type { PeriodParams } from '@/app/components/app/overview/appChart' -import { AvgResponseTime, AvgSessionInteractions, AvgUserInteractions, ConversationsChart, CostChart, EndUsersChart, MessagesChart, TokenPerSecond, UserSatisfactionRate, WorkflowCostChart, WorkflowDailyTerminalsChart, WorkflowMessagesChart } from '@/app/components/app/overview/appChart' +import type { PeriodParams } from '@/app/components/app/overview/app-chart' +import { AvgResponseTime, AvgSessionInteractions, AvgUserInteractions, ConversationsChart, CostChart, EndUsersChart, MessagesChart, TokenPerSecond, UserSatisfactionRate, WorkflowCostChart, WorkflowDailyTerminalsChart, WorkflowMessagesChart } from '@/app/components/app/overview/app-chart' import type { Item } from '@/app/components/base/select' import { SimpleSelect } from '@/app/components/base/select' import { TIME_PERIOD_MAPPING } from '@/app/components/app/log/filter' diff --git a/web/app/components/app/overview/appCard.tsx b/web/app/components/app/overview/app-card.tsx similarity index 98% rename from web/app/components/app/overview/appCard.tsx rename to web/app/components/app/overview/app-card.tsx index f11e111cb..02fd779df 100644 --- a/web/app/components/app/overview/appCard.tsx +++ b/web/app/components/app/overview/app-card.tsx @@ -35,7 +35,7 @@ import type { AppDetailResponse } from '@/models/app' import { useAppContext } from '@/context/app-context' import type { AppSSO } from '@/types/app' import Indicator from '@/app/components/header/indicator' -import { fetchAppDetail } from '@/service/apps' +import { fetchAppDetailDirect } from '@/service/apps' import { AccessMode } from '@/models/access-control' import AccessControl from '../app-access-control' import { useAppWhiteListSubjects } from '@/service/access-control' @@ -161,11 +161,15 @@ function AppCard({ return setShowAccessControl(true) }, [appDetail]) - const handleAccessControlUpdate = useCallback(() => { - fetchAppDetail({ url: '/apps', id: appDetail!.id }).then((res) => { + const handleAccessControlUpdate = useCallback(async () => { + try { + const res = await fetchAppDetailDirect({ url: '/apps', id: appDetail!.id }) setAppDetail(res) setShowAccessControl(false) - }) + } + catch (error) { + console.error('Failed to fetch app detail:', error) + } }, [appDetail, setAppDetail]) return ( diff --git a/web/app/components/app/overview/appChart.tsx b/web/app/components/app/overview/app-chart.tsx similarity index 99% rename from web/app/components/app/overview/appChart.tsx rename to web/app/components/app/overview/app-chart.tsx index 4e74eda60..1c75f1cfa 100644 --- a/web/app/components/app/overview/appChart.tsx +++ b/web/app/components/app/overview/app-chart.tsx @@ -242,7 +242,7 @@ const Chart: React.FC = ({ ? '' : {t('appOverview.analysis.tokenUsage.consumed')} Tokens ( - ~{sum(statistics.map(item => Number.parseFloat(get(item, 'total_price', '0')))).toLocaleString('en-US', { style: 'currency', currency: 'USD', minimumFractionDigits: 4 })} + ~{sum(statistics.map(item => Number.parseFloat(String(get(item, 'total_price', '0'))))).toLocaleString('en-US', { style: 'currency', currency: 'USD', minimumFractionDigits: 4 })} ) } textStyle={{ main: `!text-3xl !font-normal ${sumData === 0 ? '!text-text-quaternary' : ''}` }} />