clipboard.js 563 字节
Newer Older
d-u-a's avatar
d-u-a 已提交
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33
import clipboard from '@system.clipboard'

import {
  invoke
} from '../../bridge'

export function getClipboardData (options, callbackId) {
  clipboard.get({
    success: (ret) => {
      invoke(callbackId, {
        data: ret.text,
        errMsg: 'getClipboardData:ok'
      })
    },
    fail: (data, code) => {
      invoke(callbackId, {
        data: code,
        errMsg: 'getClipboardData:fail'
      })
    }
  })
}

export function setClipboardData ({
  data
}) {
  clipboard.set({
    text: data
  })
  return {
    errMsg: 'setClipboardData:ok'
  }
}