import type { UserNotification } from '../types'; export const BALANCE_REFRESH_EVENT = 'tkmind:balance-refresh'; const RECHARGE_NOTIFICATION_TYPES = new Set(['admin_recharge', 'self_recharge', 'recharge']); export function isRechargeNotification( notification: Pick, ): boolean { if (RECHARGE_NOTIFICATION_TYPES.has(String(notification.notificationType ?? '').trim())) { return true; } const title = String(notification.title ?? ''); const body = String(notification.body ?? ''); return /充值/.test(title) && /余额已更新/.test(body); } export function requestBalanceRefresh() { if (typeof window === 'undefined') return; window.dispatchEvent(new CustomEvent(BALANCE_REFRESH_EVENT)); }