代码提交

This commit is contained in:
黄少君
2023-11-14 17:21:03 +08:00
parent d0b337c596
commit dcab74274f
567 changed files with 22414 additions and 7375 deletions

50
hooks/useShearPlate.js Normal file
View File

@ -0,0 +1,50 @@
/**
* @name: 剪切版封装
* @author: kahu4
* @date: 2023-10-30 14:06
* @descriptionuseShearPlate
* @update: 2023-10-30 14:06
* */
export const useShearPlate = () => {
/**
* 设置剪切版
* @param text{string} 设置的内容
* @param toast{string} 是否需要toast提示
* @returns {Promise<unknown>}
*/
function setData(text, toast = '') {
return new Promise((resolve, reject) => {
uni.setClipboardData({
data:text,
showToast:false,
success:()=>{
if(toast){
uni.showToast({title:toast})
}
return resolve(true)
},
fail:(error)=> {
reject(error)
}
})
})
}
/**
* 获取当前剪切板内容
* @returns {Promise<unknown>}
*/
function getData() {
return new Promise((resolve, reject) => {
uni.getClipboardData({
success: (res) => resolve(res),
fail: (error) => reject(error)
})
})
}
return {
setData,
getData,
}
}