diff --git a/src/pages/llmodels/components/model-item.tsx b/src/pages/llmodels/components/model-item.tsx index 0b3b2a60..d21ac2e8 100644 --- a/src/pages/llmodels/components/model-item.tsx +++ b/src/pages/llmodels/components/model-item.tsx @@ -44,7 +44,7 @@ const ModelItemContent = styled.div` flex-direction: column; height: 100%; width: 100%; - cursor: default; + cursor: pointer; .content { display: flex; justify-content: space-between; @@ -127,15 +127,23 @@ const renderTag = (item: any, index = 0) => { const ModelItem: React.FC<{ model: Record; + onClick?: (model: Record) => void; }> = (props) => { - const { model } = props; + const { model, onClick } = props; const intl = useIntl(); const navigate = useNavigate(); + const handleCardClick = () => { + onClick?.(model); + }; + // ``model.name`` from ``/v2/my-models`` is the OpenAI-style id // (org-prefixed for non-platform routes, bare for platform). Use it // verbatim — the playground / dispatcher both key off that exact id. - const handleOpenPlayGroundClick = () => { + const handleOpenPlayGroundClick = (e: React.MouseEvent) => { + // Card is clickable (opens API access info); keep the playground + // action isolated so it doesn't also trigger the card click. + e.stopPropagation(); const modelName = encodeURIComponent(model.name); for (const [category, path] of Object.entries(categoryToPathMap)) { if ( @@ -178,9 +186,10 @@ const ModelItem: React.FC<{ diff --git a/src/pages/llmodels/hooks/use-view-api-info.ts b/src/pages/llmodels/hooks/use-view-api-info.ts new file mode 100644 index 00000000..8bee346a --- /dev/null +++ b/src/pages/llmodels/hooks/use-view-api-info.ts @@ -0,0 +1,30 @@ +import { useState } from 'react'; + +const useViewApIInfo = () => { + const [apiAccessInfo, setAPIAccessInfo] = useState({ + show: false, + data: {} + }); + + const openViewAPIInfo = (row: any) => { + setAPIAccessInfo({ + show: true, + data: row + }); + }; + + const closeViewAPIInfo = () => { + setAPIAccessInfo({ + show: false, + data: {} + }); + }; + + return { + apiAccessInfo, + openViewAPIInfo, + closeViewAPIInfo + }; +}; + +export default useViewApIInfo; diff --git a/src/pages/llmodels/user-models.tsx b/src/pages/llmodels/user-models.tsx index 5c52080e..e222d679 100644 --- a/src/pages/llmodels/user-models.tsx +++ b/src/pages/llmodels/user-models.tsx @@ -14,8 +14,10 @@ import { Button, Input, Space } from 'antd'; import React, { useCallback, useMemo } from 'react'; import PageBox from '../_components/page-box'; import { MY_MODELS_API, queryMyModels } from './apis'; +import APIAccessInfoModal from './components/api-access-info'; import ModelItem from './components/model-item'; import { categoryOptions, MyModelsStatusValueMap } from './config'; +import useViewApIInfo from './hooks/use-view-api-info'; const Dot = ({ color }: { color: string }) => { return ( { } }); const intl = useIntl(); + const { apiAccessInfo, openViewAPIInfo, closeViewAPIInfo } = useViewApIInfo(); const statusOptions = useMemo(() => { return [ @@ -91,7 +94,7 @@ const UserModels: React.FC = () => { }; const renderCard = (data: any) => { - return ; + return ; }; const loadMore = useMemoizedFn((nextPage: number) => { @@ -152,86 +155,95 @@ const UserModels: React.FC = () => { }; return ( - - - - handleNameChange({ - target: { - value: '' - } - }) - } - onChange={handleNameChange} - > - - - - - } - > - - - } - filters={{ ...queryParams }} - noFoundText={intl.formatMessage({ - id: 'noresult.mymodels.nofound' - })} - title={intl.formatMessage({ id: 'noresult.mymodels.title' })} - subTitle={intl.formatMessage({ id: 'noresult.mymodels.subTitle' })} - > - - + <> + + + + handleNameChange({ + target: { + value: '' + } + }) + } + onChange={handleNameChange} + > + + + + + } + > + + + } + filters={{ ...queryParams }} + noFoundText={intl.formatMessage({ + id: 'noresult.mymodels.nofound' + })} + title={intl.formatMessage({ id: 'noresult.mymodels.title' })} + subTitle={intl.formatMessage({ id: 'noresult.mymodels.subTitle' })} + > + + + + ); };