import Taro from '@tarojs/taro'; import { useUIStore } from '../stores/ui'; /** * 关怀模式自适应 Toast * - 正常模式:默认 1500ms * - 关怀模式:默认 3000ms + 触觉反馈 */ export function showToast(options: { title: string; icon?: 'success' | 'error' | 'loading' | 'none'; duration?: number; mask?: boolean; }) { const { mode } = useUIStore.getState(); const duration = options.duration ?? (mode === 'elder' ? 3000 : 1500); if (mode === 'elder') { try { Taro.vibrateShort({ type: 'light' }); } catch { /* 不支持时静默 */ } } Taro.showToast({ ...options, duration, icon: options.icon ?? 'none' }); }