diff --git a/src/pages/componentDevelopment/componentCoding/index.tsx b/src/pages/componentDevelopment/componentCoding/index.tsx index c5007b1..577de73 100644 --- a/src/pages/componentDevelopment/componentCoding/index.tsx +++ b/src/pages/componentDevelopment/componentCoding/index.tsx @@ -7,6 +7,7 @@ import { getMyComponentList } from '@/api/componentBase'; import { updateComponentCodingPath } from '@/store/ideContainer'; import { getComponentBaseInfo } from '@/api/componentDevelopProcess'; import { gitCommit, gitPull } from '@/api/componentGitea'; +import copy from 'copy-to-clipboard'; const Option = Select.Option; @@ -102,8 +103,20 @@ const ComponentCoding = () => { }; const copyGitUrlHandler = () => { - navigator.clipboard.writeText(currentComponent.repoHtmlUrl); - Message.success('复制成功'); + if (!currentComponent.repoHtmlUrl) { + Message.error('当前组件没有Git仓库,请选择组件!'); + return; + } + const textToCopy = currentComponent.repoHtmlUrl; + + const success = copy(textToCopy); + + if (success) { + Message.success('复制成功'); + } + else { + Message.error('复制失败'); + } }; useEffect(() => {