接入移动壳原生触觉反馈
H5 HostBridge 增加 haptics.impact 受控调用入口 运行时点击反馈优先请求 Expo 触觉能力并保留浏览器震动回退 补充触觉反馈测试和宿主壳能力文档
This commit is contained in:
@@ -1,3 +1,4 @@
|
||||
import * as Haptics from 'expo-haptics';
|
||||
import * as Linking from 'expo-linking';
|
||||
import * as Sharing from 'expo-sharing';
|
||||
import { Share } from 'react-native';
|
||||
@@ -116,6 +117,7 @@ function expectFailed(response: HostBridgeResponse) {
|
||||
}
|
||||
|
||||
afterEach(() => {
|
||||
vi.mocked(Haptics.impactAsync).mockReset();
|
||||
vi.mocked(Linking.openURL).mockReset();
|
||||
vi.mocked(Sharing.isAvailableAsync).mockReset();
|
||||
vi.mocked(Sharing.isAvailableAsync).mockResolvedValue(true);
|
||||
@@ -220,6 +222,19 @@ describe('handleMobileHostBridgeMessage', () => {
|
||||
expect(Linking.openURL).not.toHaveBeenCalled();
|
||||
});
|
||||
|
||||
test('haptics.impact 调起 Expo 触觉反馈', async () => {
|
||||
const response = await send(
|
||||
request('haptics.impact', {
|
||||
style: 'heavy',
|
||||
}),
|
||||
);
|
||||
|
||||
expectOk(response);
|
||||
expect(Haptics.impactAsync).toHaveBeenCalledWith(
|
||||
Haptics.ImpactFeedbackStyle.Heavy,
|
||||
);
|
||||
});
|
||||
|
||||
test('share.open 使用直接分享 payload 调起系统分享', async () => {
|
||||
const response = await send(
|
||||
request('share.open', {
|
||||
|
||||
Reference in New Issue
Block a user