From caea43590ace1ac9aec601f10ae16a29ba8e7dbd Mon Sep 17 00:00:00 2001 From: jialin Date: Wed, 3 Jun 2026 18:27:34 +0800 Subject: [PATCH] chore: useMemo deps --- .../public-keys/services/use-query-sshkeys.ts | 2 +- .../templates/components/template-card.tsx | 25 ++++++++++--------- .../gpu-service/templates/forms/basic.tsx | 2 +- 3 files changed, 15 insertions(+), 14 deletions(-) diff --git a/src/pages/gpu-service/public-keys/services/use-query-sshkeys.ts b/src/pages/gpu-service/public-keys/services/use-query-sshkeys.ts index 4ef3bbd0..14be72fa 100644 --- a/src/pages/gpu-service/public-keys/services/use-query-sshkeys.ts +++ b/src/pages/gpu-service/public-keys/services/use-query-sshkeys.ts @@ -16,7 +16,7 @@ export default function useQuerySshkeys() { >({ key: 'sshkeyOptions', fetchList, - getLabel: (item) => item.displayName || (item?.name as string), + getLabel: (item) => item?.displayName || (item?.name as string), getValue: (item) => item?.name as string }); diff --git a/src/pages/gpu-service/templates/components/template-card.tsx b/src/pages/gpu-service/templates/components/template-card.tsx index 1b0b296f..15ff7d88 100644 --- a/src/pages/gpu-service/templates/components/template-card.tsx +++ b/src/pages/gpu-service/templates/components/template-card.tsx @@ -27,6 +27,7 @@ import { } from '@gpustack/core-ui'; import { useIntl } from '@umijs/max'; import { Button, Tag } from 'antd'; +import { useMemo } from 'react'; import styled from 'styled-components'; import { manufactureColorMap, templateActions } from '../config'; import { ListItem } from '../config/types'; @@ -135,18 +136,18 @@ interface TemplateCardProps { const TemplateCardItem: React.FC = ({ data, onSelect }) => { const intl = useIntl(); - const manufacturerLabelMap: Record = Object.values( - GPUsConfigs - ).reduce( - (acc, item) => { - if (item.gpuVendor) - acc[item.gpuVendor] = item.locales.locale - ? intl.formatMessage({ id: item.locales.label }) - : item.locales.label; - return acc; - }, - { cpu: 'CPU' } as Record - ); + const manufacturerLabelMap: Record = useMemo(() => { + return Object.values(GPUsConfigs).reduce( + (acc, item) => { + if (item.gpuVendor) + acc[item.gpuVendor] = item.locales.locale + ? intl.formatMessage({ id: item.locales.label }) + : item.locales.label; + return acc; + }, + { cpu: 'CPU' } as Record + ); + }, [intl]); const handleOnSelect = (item: any) => { onSelect?.({ action: item.key, data }); diff --git a/src/pages/gpu-service/templates/forms/basic.tsx b/src/pages/gpu-service/templates/forms/basic.tsx index 86cef6ac..ac8c4ce3 100644 --- a/src/pages/gpu-service/templates/forms/basic.tsx +++ b/src/pages/gpu-service/templates/forms/basic.tsx @@ -52,7 +52,7 @@ const Basic: React.FC = ({ : item.locales.label, value: item.gpuVendor })), - [] + [intl] ); const renderStorageLabel = (): React.ReactNode => {