From 0d80269e2dad1927c9c28c9ed40ae89af047e2ec Mon Sep 17 00:00:00 2001 From: jialin Date: Thu, 27 Mar 2025 12:16:57 +0800 Subject: [PATCH] fix: windows path style --- src/components/page-tools/index.tsx | 143 +++++++++++++++++- src/hooks/use-table-fetch.ts | 2 +- .../resources/components/model-files.tsx | 118 ++++----------- 3 files changed, 171 insertions(+), 92 deletions(-) diff --git a/src/components/page-tools/index.tsx b/src/components/page-tools/index.tsx index 553b9cba..77d059f1 100644 --- a/src/components/page-tools/index.tsx +++ b/src/components/page-tools/index.tsx @@ -1,4 +1,13 @@ -import { useMemo } from 'react'; +import DropDownActions from '@/components/drop-down-actions'; +import { + DeleteOutlined, + DownOutlined, + PlusOutlined, + SyncOutlined +} from '@ant-design/icons'; +import { useIntl } from '@umijs/max'; +import { Button, Input, Select, Space } from 'antd'; +import React, { useMemo } from 'react'; import './index.less'; type PageToolsProps = { @@ -36,4 +45,136 @@ const PageTools: React.FC = (props) => { ); }; +interface ActionItem { + label: string; + locale: boolean; + value: string; + key: string; + icon: React.ReactNode; +} +interface FilterBarProps { + handleInputChange: (e: React.ChangeEvent) => void; + handleSelectChange?: (value: any) => void; + handleSearch: () => void; + handleDeleteByBatch: () => void; + handleClickPrimary: (item: any) => void; + rowSelection: any; + actionItems: ActionItem[]; + selectOptions?: Global.BaseListItem[]; + showSelect?: boolean; + buttonText: string; + buttonIcon?: React.ReactNode; + marginBottom?: number; + marginTop?: number; + inputHolder: string; + selectHolder: string; + actionType: 'dropdown' | 'button'; + width?: { + input: number; + select: number; + }; +} + +export const FilterBar: React.FC = (props) => { + const { + handleInputChange, + handleSelectChange, + handleSearch, + handleDeleteByBatch, + handleClickPrimary, + rowSelection, + actionItems, + selectOptions, + showSelect, + buttonText, + buttonIcon, + actionType, + marginBottom = 10, + marginTop = 10, + inputHolder, + selectHolder, + width + } = props; + const intl = useIntl(); + + return ( + + + {showSelect && ( + + )} + + + } + right={ + + {actionType === 'dropdown' ? ( + + + + ) : ( + + )} + + + } + > + ); +}; + export default PageTools; diff --git a/src/hooks/use-table-fetch.ts b/src/hooks/use-table-fetch.ts index 40b2d155..f683fa0c 100644 --- a/src/hooks/use-table-fetch.ts +++ b/src/hooks/use-table-fetch.ts @@ -122,7 +122,7 @@ export default function useTableFetch(options: { setSortOrder(sorter.order); }; - const handleSearch = (e: any) => { + const handleSearch = () => { fetchData(); }; diff --git a/src/pages/resources/components/model-files.tsx b/src/pages/resources/components/model-files.tsx index f316f208..f943eb56 100644 --- a/src/pages/resources/components/model-files.tsx +++ b/src/pages/resources/components/model-files.tsx @@ -2,9 +2,8 @@ import { modelsExpandKeysAtom } from '@/atoms/models'; import AutoTooltip from '@/components/auto-tooltip'; import CopyButton from '@/components/copy-button'; import DeleteModal from '@/components/delete-modal'; -import DropDownActions from '@/components/drop-down-actions'; import DropdownButtons from '@/components/drop-down-buttons'; -import PageTools from '@/components/page-tools'; +import { FilterBar } from '@/components/page-tools'; import StatusTag from '@/components/status-tag'; import { PageAction } from '@/config'; import useAppUtils from '@/hooks/use-app-utils'; @@ -27,19 +26,8 @@ import { } from '@/pages/llmodels/config/button-actions'; import DownloadModal from '@/pages/llmodels/download'; import { convertFileSize } from '@/utils'; -import { DeleteOutlined, DownOutlined, SyncOutlined } from '@ant-design/icons'; import { useIntl, useNavigate } from '@umijs/max'; -import { - Button, - ConfigProvider, - Empty, - Input, - Select, - Space, - Table, - Tag, - message -} from 'antd'; +import { ConfigProvider, Empty, Table, Tag, message } from 'antd'; import dayjs from 'dayjs'; import { useAtom } from 'jotai'; import _ from 'lodash'; @@ -244,7 +232,7 @@ const ModelFiles = () => { record.ollama_library_model_name || record.model_scope_model_id || record.local_path, - '/' + /[\\/]/ ).pop() ); @@ -405,7 +393,6 @@ const ModelFiles = () => { const handleCreateModel = async (data: any) => { try { const result = getSourceRepoConfigValue(openDeployModal.source, data); - const modelData = await createModel({ data: { ...result.values @@ -530,80 +517,31 @@ const ModelFiles = () => { return ( <> - - - - - - } - right={ - - - - - - - } - > + { item.state === WorkerStatusMap.ready )} > );