mirror of
https://gitee.com/h_mo/uniapp-vue3-vite-ts-template
synced 2025-04-06 03:58:03 +08:00
feat: 新增设置系统剪贴板的内容工具函数
This commit is contained in:
parent
75dfdf4911
commit
b7ccd95e9b
@ -0,0 +1,37 @@
|
|||||||
|
/**
|
||||||
|
* @description 设置系统剪贴板的内容
|
||||||
|
* @param data 需要设置的内容
|
||||||
|
* @param showToast 配置是否弹出提示,默认弹出提示
|
||||||
|
* @constructor
|
||||||
|
*/
|
||||||
|
export const SetClipboardData = (data: string, showToast = true) => {
|
||||||
|
return new Promise((resolve, reject) => {
|
||||||
|
uni.setClipboardData({
|
||||||
|
data: data,
|
||||||
|
showToast: showToast,
|
||||||
|
success: (res) => {
|
||||||
|
resolve(res);
|
||||||
|
},
|
||||||
|
fail: (err) => {
|
||||||
|
reject(err);
|
||||||
|
},
|
||||||
|
});
|
||||||
|
});
|
||||||
|
};
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @description 获取系统剪贴板内容
|
||||||
|
* @constructor
|
||||||
|
*/
|
||||||
|
export const GetClipboardData = () => {
|
||||||
|
return new Promise((resolve, reject) => {
|
||||||
|
uni.getClipboardData({
|
||||||
|
success: (res) => {
|
||||||
|
resolve(res);
|
||||||
|
},
|
||||||
|
fail: (err) => {
|
||||||
|
reject(err);
|
||||||
|
},
|
||||||
|
});
|
||||||
|
});
|
||||||
|
};
|
Loading…
x
Reference in New Issue
Block a user