1
This commit is contained in:
@@ -0,0 +1,36 @@
|
||||
import { BusinessError, pasteboard } from '@kit.BasicServicesKit';
|
||||
|
||||
|
||||
export const setClipboardData = (data : string) : Promise<boolean> => {
|
||||
let pasteData : pasteboard.PasteData = pasteboard.createData(pasteboard.MIMETYPE_TEXT_PLAIN, data);
|
||||
let systemPasteboard : pasteboard.SystemPasteboard = pasteboard.getSystemPasteboard();
|
||||
return new Promise((res, rej) => {
|
||||
|
||||
systemPasteboard.setData(pasteData).then(() => {
|
||||
console.info("成功")
|
||||
res(true)
|
||||
})
|
||||
.catch((e) => {
|
||||
const err = e as BusinessError
|
||||
console.error(err.message)
|
||||
rej(false)
|
||||
})
|
||||
})
|
||||
|
||||
}
|
||||
|
||||
export const getClipboardData = () : Promise<string> => {
|
||||
let systemPasteboard : pasteboard.SystemPasteboard = pasteboard.getSystemPasteboard();
|
||||
// return new Promise((res, rej) => {
|
||||
// systemPasteboard.getData((err, data) => {
|
||||
// if (err) {
|
||||
// console.error(err.message)
|
||||
// return rej(err.message);
|
||||
// }
|
||||
// res(data.getPrimaryText())
|
||||
// })
|
||||
// })
|
||||
|
||||
return Promise.resolve('')
|
||||
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
{
|
||||
"module": {
|
||||
"name": "uni_modules__x_clipboard_s",
|
||||
"type":"har",
|
||||
"deviceTypes": [
|
||||
"default",
|
||||
"tablet",
|
||||
"2in1"
|
||||
]
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,8 @@
|
||||
{
|
||||
"string": [
|
||||
{
|
||||
"name": "permission_read_pasteboard",
|
||||
"value": "应用需要读取剪粘板进行应用的个性化需要"
|
||||
}
|
||||
]
|
||||
}
|
||||
Reference in New Issue
Block a user