From d5a602cb1979f5243cc32a5a3a7db44b86c2306c Mon Sep 17 00:00:00 2001 From: ZLY Date: Thu, 4 Dec 2025 11:25:08 +0800 Subject: [PATCH] =?UTF-8?q?feat(componentDeployment):=20=E4=BD=BF=E7=94=A8?= =?UTF-8?q?=E7=AC=AC=E4=B8=89=E6=96=B9=E5=BA=93copy-to-clipboard=E5=AE=9E?= =?UTF-8?q?=E7=8E=B0=E5=A4=8D=E5=88=B6=E5=8A=9F=E8=83=BD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- package.json | 2 +- pnpm-lock.yaml | 2 +- .../componentDeployment/envConfigModal.tsx | 12 ++++++++++-- 3 files changed, 12 insertions(+), 4 deletions(-) diff --git a/package.json b/package.json index 1ec4fa7..c5a6080 100644 --- a/package.json +++ b/package.json @@ -32,7 +32,7 @@ "axios": "^0.24.0", "bizcharts": "^4.1.15", "classnames": "^2.3.1", - "copy-to-clipboard": "^3.3.1", + "copy-to-clipboard": "^3.3.3", "cron-parser": "^5.3.1", "cronstrue": "^3.2.0", "crypto-js": "^4.2.0", diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index 6941dc6..4a4370b 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -63,7 +63,7 @@ importers: specifier: ^2.3.1 version: 2.5.1 copy-to-clipboard: - specifier: ^3.3.1 + specifier: ^3.3.3 version: 3.3.3 cron-parser: specifier: ^5.3.1 diff --git a/src/pages/componentDevelopment/componentDeployment/envConfigModal.tsx b/src/pages/componentDevelopment/componentDeployment/envConfigModal.tsx index 2fb8320..d2815cf 100644 --- a/src/pages/componentDevelopment/componentDeployment/envConfigModal.tsx +++ b/src/pages/componentDevelopment/componentDeployment/envConfigModal.tsx @@ -1,6 +1,7 @@ import React, { useState, useEffect } from 'react'; import { Modal, Button, Input, Message, Tooltip } from '@arco-design/web-react'; import { IconQuestionCircle, IconCopy, IconDelete, IconPlus } from '@arco-design/web-react/icon'; +import copy from 'copy-to-clipboard'; import styles from './style/envConfigModal.module.less'; import { getComponentEnvConfig, saveComponentEnvConfig } from '@/api/componentInstance'; @@ -83,8 +84,15 @@ const EnvConfigModal: React.FC = ({ }; const handleCopyCommand = () => { - navigator.clipboard.writeText(configData.javaCommand); - Message.success('复制成功'); + const textToCopy = language.includes('Python') ? configData.pythonCommand : configData.javaCommand; + + const success = copy(textToCopy); + + if (success) { + Message.success('复制成功'); + } else { + Message.error('复制失败'); + } }; const handleSave = async () => {