提交 cb607dab 编写于 作者: inkwalk's avatar inkwalk

feat: setClipboardData/getClipboardData support for h5

上级 4caac1f5
...@@ -34,7 +34,6 @@ ...@@ -34,7 +34,6 @@
"release:v3": "npm run lint:cli && lerna publish --no-git-tag-version --force-publish=* --npm-tag=v3" "release:v3": "npm run lint:cli && lerna publish --no-git-tag-version --force-publish=* --npm-tag=v3"
}, },
"dependencies": { "dependencies": {
"@dcloudio/uni-i18n": "^0.0.3",
"base64-arraybuffer": "^0.2.0", "base64-arraybuffer": "^0.2.0",
"intersection-observer": "^0.7.0", "intersection-observer": "^0.7.0",
"pako": "^1.0.11", "pako": "^1.0.11",
...@@ -42,6 +41,7 @@ ...@@ -42,6 +41,7 @@
}, },
"private": true, "private": true,
"devDependencies": { "devDependencies": {
"@dcloudio/uni-i18n": "^2.0.0-31920210514002",
"@rollup/plugin-alias": "^3.1.0", "@rollup/plugin-alias": "^3.1.0",
"@rollup/plugin-commonjs": "^11.1.0", "@rollup/plugin-commonjs": "^11.1.0",
"@rollup/plugin-json": "^4.1.0", "@rollup/plugin-json": "^4.1.0",
...@@ -148,4 +148,4 @@ ...@@ -148,4 +148,4 @@
"main": "index.js", "main": "index.js",
"description": "", "description": "",
"author": "" "author": ""
} }
...@@ -14,7 +14,6 @@ ...@@ -14,7 +14,6 @@
"author": "fxy060608", "author": "fxy060608",
"license": "Apache-2.0", "license": "Apache-2.0",
"dependencies": { "dependencies": {
"@dcloudio/uni-i18n": "^0.0.3",
"base64-arraybuffer": "^0.2.0", "base64-arraybuffer": "^0.2.0",
"intersection-observer": "^0.7.0", "intersection-observer": "^0.7.0",
"pako": "^1.0.11", "pako": "^1.0.11",
......
...@@ -13,8 +13,8 @@ export default [ ...@@ -13,8 +13,8 @@ export default [
'startGyroscope', 'startGyroscope',
'stopGyroscope', 'stopGyroscope',
'scanCode', 'scanCode',
'setClipboardData', // 'setClipboardData',
'getClipboardData', // 'getClipboardData',
'setScreenBrightness', 'setScreenBrightness',
'getScreenBrightness', 'getScreenBrightness',
'setKeepScreenOn', 'setKeepScreenOn',
......
export function getClipboardData () {
const pasteText = document.getElementById('#clipboard')
const data = pasteText?.value
if (data) {
return {
data,
errMsg: 'getClipboardData:ok'
}
} else {
return {
errMsg: 'getClipboardData:fail'
}
}
}
export function setClipboardData ({
data
}) {
const pasteText = document.getElementById('#clipboard')
pasteText?.remove()
const textarea = document.createElement('textarea')
textarea.id = '#clipboard'
textarea.style.position = 'absolute'
textarea.style.top = '0'
textarea.style.zIndex = '-9999'
document.body.appendChild(textarea)
textarea.value = data
textarea.focus()
textarea.select()
const result = document.execCommand('Copy', false, null)
if (result) {
uni.showToast({
title: '复制成功',
icon: 'none'
})
return {
errMsg: 'setClipboardData:ok'
}
} else {
return {
errMsg: 'setClipboardData:fail'
}
}
}
...@@ -743,10 +743,10 @@ ...@@ -743,10 +743,10 @@
exec-sh "^0.3.2" exec-sh "^0.3.2"
minimist "^1.2.0" minimist "^1.2.0"
"@dcloudio/uni-i18n@^0.0.3": "@dcloudio/uni-i18n@^2.0.0-31920210514002":
version "0.0.3" version "2.0.0-31920210514002"
resolved "https://registry.yarnpkg.com/@dcloudio/uni-i18n/-/uni-i18n-0.0.3.tgz#c7ff6ea6a4ea5cd5ef8dc3d674afa2e64502c151" resolved "https://registry.yarnpkg.com/@dcloudio/uni-i18n/-/uni-i18n-2.0.0-31920210514002.tgz#f63d14c234ea0353fabe2d8c681601c7ba07e488"
integrity sha512-BJGl0yUkuTMv6v0r1lUzq2EURkSoM/CoKbjlf7xlDXDTUqkhUGjK5epTq2hwsi26HTxTjvl6/vf50Q5wSTFApA== integrity sha512-shHf27U0KEs//ieCBG1R1aRKNDn6KwcVUIb5GsPuDOqoN7WQY+nEz9QFdOSQY8j9tX4ABOAc1ra0Opz8xFVngA==
"@hapi/address@2.x.x": "@hapi/address@2.x.x":
version "2.1.4" version "2.1.4"
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册