Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
DCloud
uni-app
提交
6b0586dc
U
uni-app
项目概览
DCloud
/
uni-app
3 个月 前同步成功
通知
725
Star
38705
Fork
3642
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
7
列表
看板
标记
里程碑
合并请求
1
DevOps
流水线
流水线任务
计划
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
U
uni-app
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
7
Issue
7
列表
看板
标记
里程碑
合并请求
1
合并请求
1
Pages
DevOps
DevOps
流水线
流水线任务
计划
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
流水线任务
提交
Issue看板
体验新版 GitCode,发现更多精彩内容 >>
提交
6b0586dc
编写于
10月 22, 2021
作者:
D
DCloud_LXH
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
feat(H5): setClipboardData、getClipboardData
上级
02488769
变更
9
隐藏空白更改
内联
并排
Showing
9 changed file
with
119 addition
and
6 deletion
+119
-6
packages/uni-core/src/i18n/en.json
packages/uni-core/src/i18n/en.json
+2
-0
packages/uni-core/src/i18n/es.json
packages/uni-core/src/i18n/es.json
+2
-0
packages/uni-core/src/i18n/fr.json
packages/uni-core/src/i18n/fr.json
+2
-0
packages/uni-core/src/i18n/messages.ts
packages/uni-core/src/i18n/messages.ts
+56
-6
packages/uni-core/src/i18n/zh-Hans.json
packages/uni-core/src/i18n/zh-Hans.json
+2
-0
packages/uni-core/src/i18n/zh-Hant.json
packages/uni-core/src/i18n/zh-Hant.json
+2
-0
packages/uni-h5-vite/lib/api.json
packages/uni-h5-vite/lib/api.json
+2
-0
packages/uni-h5/src/service/api/device/clipboard.ts
packages/uni-h5/src/service/api/device/clipboard.ts
+50
-0
packages/uni-h5/src/service/api/index.ts
packages/uni-h5/src/service/api/index.ts
+1
-0
未找到文件。
packages/uni-core/src/i18n/en.json
浏览文件 @
6b0586dc
...
...
@@ -17,6 +17,8 @@
"uni.previewImage.save.success"
:
"Saved successfully"
,
"uni.previewImage.save.fail"
:
"Save failed"
,
"uni.setClipboardData.success"
:
"Content copied"
,
"uni.setClipboardData.fail"
:
"Copy failed, please copy manually"
,
"uni.getClipboardData.fail"
:
"Reading failed, please paste manually"
,
"uni.scanCode.title"
:
"Scan code"
,
"uni.scanCode.album"
:
"Album"
,
"uni.scanCode.fail"
:
"Recognition failure"
,
...
...
packages/uni-core/src/i18n/es.json
浏览文件 @
6b0586dc
...
...
@@ -17,6 +17,8 @@
"uni.previewImage.save.success"
:
"Guardado exitosamente"
,
"uni.previewImage.save.fail"
:
"Error al guardar"
,
"uni.setClipboardData.success"
:
"Contenido copiado"
,
"uni.setClipboardData.fail"
:
"Error al copiar, copie manualmente"
,
"uni.getClipboardData.fail"
:
"Error de lectura, pegue manualmente"
,
"uni.scanCode.title"
:
"Código de escaneo"
,
"uni.scanCode.album"
:
"Álbum"
,
"uni.scanCode.fail"
:
"Échec de la reconnaissance"
,
...
...
packages/uni-core/src/i18n/fr.json
浏览文件 @
6b0586dc
...
...
@@ -17,6 +17,8 @@
"uni.previewImage.save.success"
:
"Enregistré avec succès"
,
"uni.previewImage.save.fail"
:
"Échec de la sauvegarde"
,
"uni.setClipboardData.success"
:
"Contenu copié"
,
"uni.setClipboardData.fail"
:
"Échec de la copie, copiez manuellement"
,
"uni.getClipboardData.fail"
:
"Échec de la lecture, veuillez coller manuellement"
,
"uni.scanCode.title"
:
"Code d’analyse"
,
"uni.scanCode.album"
:
"Album"
,
"uni.scanCode.fail"
:
"Fallo de reconocimiento"
,
...
...
packages/uni-core/src/i18n/messages.ts
浏览文件 @
6b0586dc
...
...
@@ -410,39 +410,89 @@ export const initI18nPreviewImageMsgsOnce = /*#__PURE__*/ once(() => {
})
export
const
initI18nSetClipboardDataMsgsOnce
=
/*#__PURE__*/
once
(()
=>
{
const
name
=
'
uni.setClipboardData.
'
const
keys
=
[
'
success
'
]
const
keys
=
[
'
success
'
,
'
fail
'
]
if
(
__UNI_FEATURE_I18N_EN__
)
{
useI18n
().
add
(
LOCALE_EN
,
normalizeMessages
(
name
,
keys
,
[
'
Content copied
'
]),
normalizeMessages
(
name
,
keys
,
[
'
Content copied
'
,
'
Copy failed, please copy manually
'
,
]),
false
)
}
if
(
__UNI_FEATURE_I18N_ES__
)
{
useI18n
().
add
(
LOCALE_ES
,
normalizeMessages
(
name
,
keys
,
[
'
Contenido copiado
'
]),
normalizeMessages
(
name
,
keys
,
[
'
Contenido copiado
'
,
'
Error al copiar, copie manualmente
'
,
]),
false
)
}
if
(
__UNI_FEATURE_I18N_FR__
)
{
useI18n
().
add
(
LOCALE_FR
,
normalizeMessages
(
name
,
keys
,
[
'
Contenu copié
'
]),
normalizeMessages
(
name
,
keys
,
[
'
Contenu copié
'
,
'
Échec de la copie, copiez manuellement
'
,
]),
false
)
}
if
(
__UNI_FEATURE_I18N_ZH_HANS__
)
{
useI18n
().
add
(
LOCALE_ZH_HANS
,
normalizeMessages
(
name
,
keys
,
[
'
内容已复制
'
,
'
复制失败,请手动复制
'
]),
false
)
}
if
(
__UNI_FEATURE_I18N_ZH_HANT__
)
{
useI18n
().
add
(
LOCALE_ZH_HANT
,
normalizeMessages
(
name
,
keys
,
[
'
內容已復制
'
,
'
復制失敗,請手動復製
'
]),
false
)
}
})
export
const
initI18nGetClipboardDataMsgsOnce
=
/*#__PURE__*/
once
(()
=>
{
const
name
=
'
uni.getClipboardData.
'
const
keys
=
[
'
fail
'
]
if
(
__UNI_FEATURE_I18N_EN__
)
{
useI18n
().
add
(
LOCALE_EN
,
normalizeMessages
(
name
,
keys
,
[
'
Reading failed, please paste manually
'
]),
false
)
}
if
(
__UNI_FEATURE_I18N_ES__
)
{
useI18n
().
add
(
LOCALE_ES
,
normalizeMessages
(
name
,
keys
,
[
'
Error de lectura, pegue manualmente
'
]),
false
)
}
if
(
__UNI_FEATURE_I18N_FR__
)
{
useI18n
().
add
(
LOCALE_FR
,
normalizeMessages
(
name
,
keys
,
[
'
Échec de la lecture, veuillez coller manuellement
'
,
]),
false
)
}
if
(
__UNI_FEATURE_I18N_ZH_HANS__
)
{
useI18n
().
add
(
LOCALE_ZH_HANS
,
normalizeMessages
(
name
,
keys
,
[
'
内容已复制
'
]),
normalizeMessages
(
name
,
keys
,
[
'
读取失败,请手动粘贴
'
]),
false
)
}
if
(
__UNI_FEATURE_I18N_ZH_HANT__
)
{
useI18n
().
add
(
LOCALE_ZH_HANT
,
normalizeMessages
(
name
,
keys
,
[
'
內容已復制
'
]),
normalizeMessages
(
name
,
keys
,
[
'
讀取失敗,請手動粘貼
'
]),
false
)
}
...
...
packages/uni-core/src/i18n/zh-Hans.json
浏览文件 @
6b0586dc
...
...
@@ -17,6 +17,8 @@
"uni.previewImage.save.success"
:
"保存图像到相册成功"
,
"uni.previewImage.save.fail"
:
"保存图像到相册失败"
,
"uni.setClipboardData.success"
:
"内容已复制"
,
"uni.setClipboardData.fail"
:
"复制失败,请手动复制"
,
"uni.getClipboardData.fail"
:
"读取失败,请手动粘贴"
,
"uni.scanCode.title"
:
"扫码"
,
"uni.scanCode.album"
:
"相册"
,
"uni.scanCode.fail"
:
"识别失败"
,
...
...
packages/uni-core/src/i18n/zh-Hant.json
浏览文件 @
6b0586dc
...
...
@@ -17,6 +17,8 @@
"uni.previewImage.save.success"
:
"保存圖像到相冊成功"
,
"uni.previewImage.save.fail"
:
"保存圖像到相冊失敗"
,
"uni.setClipboardData.success"
:
"內容已復制"
,
"uni.setClipboardData.fail"
:
"復制失敗,請手動復製"
,
"uni.getClipboardData.fail"
:
"讀取失敗,請手動粘貼"
,
"uni.scanCode.title"
:
"掃碼"
,
"uni.scanCode.album"
:
"相冊"
,
"uni.scanCode.fail"
:
"識別失敗"
,
...
...
packages/uni-h5-vite/lib/api.json
浏览文件 @
6b0586dc
...
...
@@ -30,6 +30,7 @@
"createSelectorQuery"
,
"createVideoContext"
,
"downloadFile"
,
"getClipboardData"
,
"getFileInfo"
,
"getImageInfo"
,
"getLeftWindowStyle"
,
...
...
@@ -103,6 +104,7 @@
"saveVideoToPhotosAlbum"
,
"scanCode"
,
"sendSocketMessage"
,
"setClipboardData"
,
"setKeepScreenOn"
,
"setLeftWindowStyle"
,
"setLocale"
,
...
...
packages/uni-h5/src/service/api/device/clipboard.ts
0 → 100644
浏览文件 @
6b0586dc
import
{
API_GET_CLIPBOARD_DATA
,
API_SET_CLIPBOARD_DATA
,
API_TYPE_GET_CLIPBOARD_DATA
,
API_TYPE_SET_CLIPBOARD_DATA
,
SetClipboardDataOptions
,
SetClipboardDataProtocol
,
defineAsyncApi
,
}
from
'
@dcloudio/uni-api
'
import
{
showModal
}
from
'
../../api/ui/popup/showModal
'
import
{
useI18n
,
initI18nSetClipboardDataMsgsOnce
,
initI18nGetClipboardDataMsgsOnce
,
}
from
'
@dcloudio/uni-core
'
export
const
getClipboardData
=
defineAsyncApi
<
API_TYPE_GET_CLIPBOARD_DATA
>
(
API_GET_CLIPBOARD_DATA
,
async
(
_
,
{
resolve
,
reject
})
=>
{
initI18nGetClipboardDataMsgsOnce
()
const
{
t
}
=
useI18n
()
try
{
const
data
=
await
navigator
.
clipboard
.
readText
()
resolve
({
data
})
}
catch
(
error
:
any
)
{
reject
(
`
${
error
}
${
t
(
'
uni.getClipboardData.fail
'
)}
`
)
}
}
)
export
const
setClipboardData
=
defineAsyncApi
<
API_TYPE_SET_CLIPBOARD_DATA
>
(
API_SET_CLIPBOARD_DATA
,
async
({
data
},
{
resolve
,
reject
})
=>
{
initI18nSetClipboardDataMsgsOnce
()
const
{
t
}
=
useI18n
()
try
{
await
navigator
.
clipboard
.
writeText
(
data
)
resolve
()
}
catch
(
error
)
{
reject
()
showModal
({
title
:
t
(
'
uni.setClipboardData.fail
'
),
content
:
data
,
editable
:
true
,
})
}
},
SetClipboardDataProtocol
,
SetClipboardDataOptions
)
packages/uni-h5/src/service/api/index.ts
浏览文件 @
6b0586dc
...
...
@@ -20,6 +20,7 @@ export * from './device/network'
export
*
from
'
./device/accelerometer
'
export
*
from
'
./device/compass
'
export
*
from
'
./device/vibrate
'
export
*
from
'
./device/clipboard
'
export
*
from
'
./storage/storage
'
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录