From 47596fdb1ac8c295de039a0b50fb6482105b708c Mon Sep 17 00:00:00 2001 From: jialin Date: Wed, 4 Feb 2026 16:04:30 +0800 Subject: [PATCH] fix: copy button do not work --- src/components/copy-button/index.tsx | 84 ++++++------------- src/hooks/use-query-data-list.ts | 14 +++- .../config/backend-parameters/vllm.ts | 5 ++ src/pages/llmodels/config/button-actions.ts | 21 ----- .../system/use-query-system-config.ts | 27 ++++++ 5 files changed, 69 insertions(+), 82 deletions(-) create mode 100644 src/services/system/use-query-system-config.ts diff --git a/src/components/copy-button/index.tsx b/src/components/copy-button/index.tsx index bb4dbd78..a23e71bb 100644 --- a/src/components/copy-button/index.tsx +++ b/src/components/copy-button/index.tsx @@ -1,8 +1,7 @@ import { CheckCircleFilled, CopyOutlined } from '@ant-design/icons'; import { useIntl } from '@umijs/max'; -import { Button, Tooltip, message } from 'antd'; -import ClipboardJS from 'clipboard'; -import React, { useEffect, useMemo, useRef, useState } from 'react'; +import { Typography } from 'antd'; +import React, { useMemo } from 'react'; type CopyButtonProps = { children?: React.ReactNode; @@ -40,65 +39,32 @@ const CopyButton: React.FC = ({ size = 'middle' }) => { const intl = useIntl(); - const [copied, setCopied] = useState(false); - const buttonRef = useRef(null); - const clipboardRef = useRef(null); - const initClipboard = () => { - if (buttonRef.current) { - clipboardRef.current = new ClipboardJS(buttonRef.current); - clipboardRef.current.on('success', () => { - setCopied(true); - setTimeout(() => { - setCopied(false); - }, 3000); - }); - - clipboardRef.current.on('error', (e: any) => { - message.error(intl.formatMessage({ id: 'common.copy.fail' }) as string); - e.clearSelection(); - }); - } - }; - - const tipTitle = useMemo(() => { - if (copied) { - return intl.formatMessage({ id: 'common.button.copied' }); - } - return tips ?? intl.formatMessage({ id: 'common.button.copy' }); - }, [copied, intl, tips]); - - useEffect(() => { - initClipboard(); - return () => { - clipboardRef.current?.destroy(); - }; - }, [buttonRef]); + const tooltips = useMemo(() => { + return [ + intl.formatMessage({ id: 'common.button.copy' }), + intl.formatMessage({ id: 'common.button.copied' }) + ]; + }, [intl]); return ( - - - + , + + ] + }} + > + {children} + ); }; diff --git a/src/hooks/use-query-data-list.ts b/src/hooks/use-query-data-list.ts index 320aabf3..8d2a64c3 100644 --- a/src/hooks/use-query-data-list.ts +++ b/src/hooks/use-query-data-list.ts @@ -21,7 +21,12 @@ export function useQueryDataList(option: { getLabel?: (item: ListItem) => string; getValue?: (item: ListItem) => any; errorMsg?: string; -}) { +}): { + loading: boolean; + dataList: Array; + cancelRequest: () => void; + fetchData: (params: Params, extra?: any) => Promise; +} { const { key, fetchList, getLabel, getValue, errorMsg } = option; const axiosTokenRef = useRef(null); const [dataList, setDataList] = useState< @@ -89,7 +94,12 @@ export function useQueryData(option: { fetchDetail: (params: Params, options?: any) => Promise; getData?: (response: Detail) => any; errorMsg?: string; -}) { +}): { + loading: boolean; + detailData: Detail; + cancelRequest: () => void; + fetchData: (params: Params, extra?: any) => Promise; +} { const { key, fetchDetail, getData, errorMsg, delay } = option; const axiosTokenRef = useRef(null); const [detailData, setDetailData] = useState({} as Detail); diff --git a/src/pages/llmodels/config/backend-parameters/vllm.ts b/src/pages/llmodels/config/backend-parameters/vllm.ts index bd2e7279..a5b08dc6 100644 --- a/src/pages/llmodels/config/backend-parameters/vllm.ts +++ b/src/pages/llmodels/config/backend-parameters/vllm.ts @@ -66,6 +66,11 @@ const options: BackendParameter[] = [ value: '--ssl-certfile', options: [] }, + { + label: '--data-parallel-size-local', + value: '--data-parallel-size-local', + options: [] + }, { label: '--enable-ssl-refresh', value: '--enable-ssl-refresh', diff --git a/src/pages/llmodels/config/button-actions.ts b/src/pages/llmodels/config/button-actions.ts index ba4a170e..12b6fd11 100644 --- a/src/pages/llmodels/config/button-actions.ts +++ b/src/pages/llmodels/config/button-actions.ts @@ -194,24 +194,3 @@ export const hotkeyConfigs = [ }, { keys: HotKeys.NEW4, width: 600, source: modelSourceMap.local_path_value } ]; - -/** - * hotkeyConfigs.map(({ keys, width, source }) => - useHotkeys( - keys.join(','), - () => { - setOpenDeployModal({ - show: true, - width, - source, - gpuOptions: gpuDeviceList.current - }); - }, - { - preventDefault: true, - enabled: !openAddModal && !openDeployModal.show && !openLogModal - } - ) - ); - * - */ diff --git a/src/services/system/use-query-system-config.ts b/src/services/system/use-query-system-config.ts new file mode 100644 index 00000000..d5f65a16 --- /dev/null +++ b/src/services/system/use-query-system-config.ts @@ -0,0 +1,27 @@ +import { useQueryData } from '@/hooks/use-query-data-list'; +import { SystemConfig } from '@/pages/cluster-management/config/types'; +import { request } from '@umijs/max'; + +export const SYSTEM_CONFIG_API = '/config'; + +const useQuerySystemConfig = () => { + async function querySystemConfig() { + return request(`${SYSTEM_CONFIG_API}`, { + method: 'GET' + }); + } + const { detailData, loading, cancelRequest, fetchData } = + useQueryData({ + key: 'system-config', + fetchDetail: querySystemConfig + }); + + return { + systemConfig: detailData, + loading, + cancelRequest, + fetchSystemConfig: fetchData + }; +}; + +export default useQuerySystemConfig;