fix(#24,#25,#26,#27,#30): action按钮顺序; group边界; Notification权限; queue catch; 新增功能测试
This commit is contained in:
+15
-4
@@ -1018,7 +1018,7 @@ const meToast = {
|
||||
|
||||
const t = this._emit({
|
||||
...normalized,
|
||||
html: _actionHTML(actions) + (normalized.html || ''),
|
||||
html: (normalized.html || '') + _actionHTML(actions),
|
||||
});
|
||||
|
||||
if (Array.isArray(actions)) {
|
||||
@@ -1090,6 +1090,7 @@ const meToast = {
|
||||
});
|
||||
return {
|
||||
then: (fn, rj) => promise.then(fn, rj),
|
||||
catch: (rj) => promise.catch(rj),
|
||||
cancel: () => { cancelled = true; },
|
||||
};
|
||||
},
|
||||
@@ -1167,9 +1168,19 @@ const meToast = {
|
||||
const g = { _group: name };
|
||||
methods.forEach(m => {
|
||||
g[m] = (...args) => {
|
||||
const last = typeof args[args.length - 1] === 'object' && args[args.length - 1] !== null && !Array.isArray(args[args.length - 1])
|
||||
? args.pop() : {};
|
||||
return self[m](...args, { ...last, group: name });
|
||||
const lastArg = args[args.length - 1];
|
||||
const isObj = typeof lastArg === 'object' && lastArg !== null && !Array.isArray(lastArg);
|
||||
// 单对象参数:直接合并group
|
||||
if (isObj && args.length === 1) {
|
||||
return self[m]({ ...lastArg, group: name });
|
||||
}
|
||||
// 末尾是配置对象:pop后合并
|
||||
if (isObj) {
|
||||
args.pop();
|
||||
return self[m](...args, { ...lastArg, group: name });
|
||||
}
|
||||
// 无配置对象
|
||||
return self[m](...args, { group: name });
|
||||
};
|
||||
});
|
||||
g.dismiss = () => self.dismissGroup(name);
|
||||
|
||||
+10
-2
@@ -260,10 +260,18 @@ if (typeof window !== 'undefined') {
|
||||
|
||||
// Notification API — 页面不可见时自动发送系统通知
|
||||
enhancedMeToast._notify = (toast) => {
|
||||
if (typeof Notification === 'undefined' || Notification.permission !== 'granted') return;
|
||||
if (typeof Notification === 'undefined') return;
|
||||
if (Notification.permission === 'denied') return;
|
||||
if (!document.hidden) return;
|
||||
if (Notification.permission === 'default') {
|
||||
Notification.requestPermission().then(p => { if (p === 'granted') sendNotification(toast); });
|
||||
return;
|
||||
}
|
||||
sendNotification(toast);
|
||||
};
|
||||
const sendNotification = (toast) => {
|
||||
try {
|
||||
new Notification(toast.title || toast.type, { body: toast.message, icon: '/favicon.ico' });
|
||||
new Notification(toast.title || toast.type, { body: toast.message });
|
||||
} catch (_) {}
|
||||
};
|
||||
Toast.on('afterShow', (toast) => {
|
||||
|
||||
Reference in New Issue
Block a user