fix(mp): M2 设备扫描放宽名称匹配 + vibrateShort 异步 catch

1. 扫描匹配放宽:支持 M2 / VPM / VEEPOO 三种广播名前缀
2. 增加诊断日志:SDK 加载状态 + 每个扫描到的设备完整信息
3. 扫描超时从 10s 增加到 15s
4. vibrateShort 改用 .catch() 捕获异步 rejection(DevTools 不支持 type 参数)
This commit is contained in:
iven
2026-05-30 13:36:57 +08:00
parent 7924768df3
commit ec404a3e25
3 changed files with 18 additions and 14 deletions

View File

@@ -16,7 +16,7 @@ export function showToast(options: {
const duration = options.duration ?? (mode === 'elder' ? 3000 : 1500);
if (mode === 'elder') {
try { Taro.vibrateShort({ type: 'light' }); } catch { /* 不支持时静默 */ }
Taro.vibrateShort({ type: 'light' }).catch(() => {});
}
Taro.showToast({ ...options, duration, icon: options.icon ?? 'none' });

View File

@@ -2,21 +2,15 @@ import Taro from '@tarojs/taro';
/** 轻触反馈(按钮点击) */
export function hapticLight(): void {
try {
Taro.vibrateShort({ type: 'light' });
} catch { /* 部分设备不支持 */ }
Taro.vibrateShort({ type: 'light' }).catch(() => { /* DevTools 不支持 type 参数,真机正常 */ });
}
/** 中等反馈(成功操作) */
export function hapticMedium(): void {
try {
Taro.vibrateShort({ type: 'medium' });
} catch { /* ignore */ }
Taro.vibrateShort({ type: 'medium' }).catch(() => { /* ignore */ });
}
/** 重度反馈(错误/警告) */
export function hapticHeavy(): void {
try {
Taro.vibrateShort({ type: 'heavy' });
} catch { /* ignore */ }
Taro.vibrateShort({ type: 'heavy' }).catch(() => { /* ignore */ });
}