feat: Notification API + 自定义渲染函数 + stack独立配置完善

This commit is contained in:
tianhao
2026-06-16 13:02:23 +08:00
parent 88ae899d96
commit 23745952e5
2 changed files with 19 additions and 0 deletions
+12
View File
@@ -257,6 +257,18 @@ if (typeof window !== 'undefined') {
window.MeToast = enhancedMeToast;
window.Met = enhancedMeToast;
window.metonaToast = enhancedMeToast;
// Notification API — 页面不可见时自动发送系统通知
enhancedMeToast._notify = (toast) => {
if (typeof Notification === 'undefined' || Notification.permission !== 'granted') return;
if (!document.hidden) return;
try {
new Notification(toast.title || toast.type, { body: toast.message, icon: '/favicon.ico' });
} catch (_) {}
};
Toast.on('afterShow', (toast) => {
if (toast.config.notifyWhenHidden) enhancedMeToast._notify(toast);
});
}
// 导出