提交 a1fe2b94 编写于 作者: inkwalk's avatar inkwalk

feat(App): setClipboardData、getClipboardData

上级 0262f538
export const API_GET_CLIPBOARD_DATA = 'getClipboardData'
export const API_SET_CLIPBOARD_DATA = 'setClipboardData' export const API_SET_CLIPBOARD_DATA = 'setClipboardData'
export type API_TYPE_GET_CLIPBOARD_DATA = typeof uni.getClipboardData
export type API_TYPE_SET_CLIPBOARD_DATA = typeof uni.setClipboardData export type API_TYPE_SET_CLIPBOARD_DATA = typeof uni.setClipboardData
export const SetClipboardDataOptions: ApiOptions<API_TYPE_SET_CLIPBOARD_DATA> = export const SetClipboardDataOptions: ApiOptions<API_TYPE_SET_CLIPBOARD_DATA> =
{ {
......
import {
API_GET_CLIPBOARD_DATA,
API_SET_CLIPBOARD_DATA,
API_TYPE_GET_CLIPBOARD_DATA,
API_TYPE_SET_CLIPBOARD_DATA,
defineAsyncApi,
} from '@dcloudio/uni-api'
import { requireNativePlugin } from '../base'
export const getClipboardData = defineAsyncApi<API_TYPE_GET_CLIPBOARD_DATA>(
API_GET_CLIPBOARD_DATA,
(_, { resolve, reject }) => {
const clipboard = requireNativePlugin('clipboard')
clipboard.getString((ret: any) => {
if (ret.result === 'success') {
resolve({
data: ret.data,
})
} else {
reject('getClipboardData:fail')
}
})
}
)
export const setClipboardData = defineAsyncApi<API_TYPE_SET_CLIPBOARD_DATA>(
API_SET_CLIPBOARD_DATA,
(options, { resolve }) => {
const clipboard = requireNativePlugin('clipboard')
clipboard.setString(options.data)
resolve()
}
)
...@@ -8,6 +8,7 @@ export * from './device/accelerometer' ...@@ -8,6 +8,7 @@ export * from './device/accelerometer'
export * from './device/bluetooth' export * from './device/bluetooth'
export * from './device/ibeacon' export * from './device/ibeacon'
export * from './device/makePhoneCall' export * from './device/makePhoneCall'
export * from './device/clipboard'
export * from './media/getImageInfo' export * from './media/getImageInfo'
export * from './media/getVideoInfo' export * from './media/getVideoInfo'
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册