From 243c069fa490aca2b4f8b8e5a297e736cfbbb5be Mon Sep 17 00:00:00 2001 From: DCloud_LXH <283700113@qq.com> Date: Thu, 21 Oct 2021 17:37:24 +0800 Subject: [PATCH] =?UTF-8?q?feat:=20setClipboardData=20=E6=94=AF=E6=8C=81?= =?UTF-8?q?=E9=85=8D=E7=BD=AE=E6=98=AF=E5=90=A6=E5=BC=B9=E5=87=BA=E6=8F=90?= =?UTF-8?q?=E7=A4=BA?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/core/helpers/api.js | 2 +- .../helpers/protocol/device/set-clipboard-data.js | 13 +++++++++++-- src/platforms/h5/service/api/device/clipboard.js | 6 +----- 3 files changed, 13 insertions(+), 8 deletions(-) diff --git a/src/core/helpers/api.js b/src/core/helpers/api.js index 22bffff77d..b6f3a583d5 100644 --- a/src/core/helpers/api.js +++ b/src/core/helpers/api.js @@ -204,7 +204,7 @@ function createApiCallback (apiName, params = {}, extras = {}) { const errMsg = res.errMsg if (errMsg.indexOf(apiName + ':ok') === 0) { - isFn(beforeSuccess) && beforeSuccess(res) + isFn(beforeSuccess) && beforeSuccess(res, params) hasSuccess && success(res) diff --git a/src/core/helpers/protocol/device/set-clipboard-data.js b/src/core/helpers/protocol/device/set-clipboard-data.js index 7f1da9a979..55314d79bf 100644 --- a/src/core/helpers/protocol/device/set-clipboard-data.js +++ b/src/core/helpers/protocol/device/set-clipboard-data.js @@ -3,11 +3,20 @@ import { } from 'uni-core/helpers/i18n' export const setClipboardData = { - beforeSuccess () { + data: { + type: String, + required: true + }, + showToast: { + type: Boolean, + default: true + }, + beforeSuccess (res, params) { + if (!params.showToast) return const title = t('uni.setClipboardData.success') if (title) { uni.showToast({ - title: t('uni.setClipboardData.success'), + title, icon: 'success', mask: false, style: { diff --git a/src/platforms/h5/service/api/device/clipboard.js b/src/platforms/h5/service/api/device/clipboard.js index 1926a75645..63a0e1cc38 100644 --- a/src/platforms/h5/service/api/device/clipboard.js +++ b/src/platforms/h5/service/api/device/clipboard.js @@ -22,7 +22,7 @@ export function setClipboardData ({ const textarea = document.createElement('textarea') textarea.id = '#clipboard' textarea.style.position = 'absolute' - textarea.style.top = '0' + textarea.style.top = '-9999px' textarea.style.zIndex = '-9999' document.body.appendChild(textarea) textarea.value = data @@ -30,10 +30,6 @@ export function setClipboardData ({ textarea.select() const result = document.execCommand('Copy', false, null) if (result) { - uni.showToast({ - title: '倍刢成功', - icon: 'none' - }) return { errMsg: 'setClipboardData:ok' } -- GitLab