refactor(frontend): replace toast system with zibll notyf
This commit is contained in:
1 parent
fb11a7ed0c
commit
86614c4905
33 files changed
+603
-802
No files matched your search
+7
-24
@@ -10,23 +10,6 @@
|
||||
(function () {
|
||||
'use strict';
|
||||
|
||||
function notify(message, type) {
|
||||
if (!message) return;
|
||||
if (typeof window.AksrtToast === 'function') {
|
||||
window.AksrtToast(message, type || 'info');
|
||||
return;
|
||||
}
|
||||
if (typeof window.showToast === 'function') {
|
||||
window.showToast(message, type || 'info');
|
||||
return;
|
||||
}
|
||||
if (typeof window.aksrtToast === 'function') {
|
||||
window.aksrtToast(message, type || 'info');
|
||||
return;
|
||||
}
|
||||
window.alert(message);
|
||||
}
|
||||
|
||||
function getMetaContent(selectors) {
|
||||
for (var i = 0; i < selectors.length; i += 1) {
|
||||
var node = document.querySelector(selectors[i]);
|
||||
@@ -208,7 +191,7 @@
|
||||
|
||||
var share = window.AksrtShare;
|
||||
if (!share || typeof share.openWeixinShare !== 'function') {
|
||||
notify('微信分享模块未加载', 'error');
|
||||
notyf('微信分享模块未加载', 'danger');
|
||||
return Promise.resolve({ mode: 'error' });
|
||||
}
|
||||
|
||||
@@ -230,7 +213,7 @@
|
||||
qrImage: options.qrImage || null
|
||||
}).then(function (result) {
|
||||
if (result && result.message) {
|
||||
notify(result.message, result.mode === 'error' ? 'error' : (result.mode === 'bridge' ? 'success' : 'info'));
|
||||
notyf(result.message, result.mode === 'error' ? 'danger' : (result.mode === 'bridge' ? 'success' : 'info'));
|
||||
}
|
||||
return result;
|
||||
});
|
||||
@@ -245,13 +228,13 @@
|
||||
|
||||
if (platform === 'copy') {
|
||||
return copyLink(payload.url).then(function () {
|
||||
notify('链接已复制', 'success');
|
||||
notyf('链接已复制', 'success');
|
||||
if (options && typeof options.closeDropdown === 'function') {
|
||||
options.closeDropdown();
|
||||
}
|
||||
return { mode: 'copy' };
|
||||
}).catch(function () {
|
||||
notify('复制失败,请手动复制链接', 'error');
|
||||
notyf('复制失败,请手动复制链接', 'danger');
|
||||
return { mode: 'error' };
|
||||
});
|
||||
}
|
||||
@@ -271,7 +254,7 @@
|
||||
if (options && typeof options.closeDropdown === 'function') options.closeDropdown();
|
||||
return Promise.resolve({ mode: 'poster' });
|
||||
}
|
||||
notify('海报模块未加载', 'error');
|
||||
notyf('海报模块未加载', 'danger');
|
||||
return Promise.resolve({ mode: 'error' });
|
||||
}
|
||||
|
||||
@@ -304,9 +287,9 @@
|
||||
event.preventDefault();
|
||||
var url = node.getAttribute('data-share-url') || window.location.href;
|
||||
copyLink(url).then(function () {
|
||||
notify('链接已复制', 'success');
|
||||
notyf('链接已复制', 'success');
|
||||
}).catch(function () {
|
||||
notify('复制失败,请手动复制链接', 'error');
|
||||
notyf('复制失败,请手动复制链接', 'danger');
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user