提交 e07d769b 编写于 作者: D DCloud_LXH

feat(h5): vibrate

上级 4553386d
......@@ -15,6 +15,7 @@ export * from './protocols/device/makePhoneCall'
export * from './protocols/device/setClipboardData'
export * from './protocols/device/accelerometer'
export * from './protocols/device/compass'
export * from './protocols/device/vibrate'
export * from './protocols/storage/storage'
......
export const API_VIBRATE_SHORT = 'vibrateShort'
export type API_TYPE_VIBRATE_SHORT = typeof uni.vibrateShort
export const API_VIBRATE_LONG = 'vibrateLong'
export type API_TYPE_VIBRATE_LONG = typeof uni.vibrateLong
import {
API_VIBRATE_SHORT,
API_VIBRATE_LONG,
defineAsyncApi,
} from '@dcloudio/uni-api'
import {
API_TYPE_VIBRATE_SHORT,
API_TYPE_VIBRATE_LONG,
} from '@dcloudio/uni-api'
const _isSupport = !!window.navigator.vibrate
export const vibrateShort = defineAsyncApi<API_TYPE_VIBRATE_SHORT>(
API_VIBRATE_SHORT,
(args, { resolve, reject }) => {
if (_isSupport && window.navigator.vibrate(15)) {
resolve()
} else {
reject('vibrateLong:fail')
}
}
)
export const vibrateLong = defineAsyncApi<API_TYPE_VIBRATE_LONG>(
API_VIBRATE_LONG,
(args, { resolve, reject }) => {
if (_isSupport && window.navigator.vibrate(400)) {
resolve()
} else {
reject('vibrateLong:fail')
}
}
)
......@@ -6,6 +6,7 @@ export * from './device/getSystemInfoSync'
export * from './device/network'
export * from './device/accelerometer'
export * from './device/compass'
export * from './device/vibrate'
export * from './storage/storage'
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册