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
@@ -29,27 +29,6 @@
|
||||
return (window.aksrtData && window.aksrtData.restNonce) || '';
|
||||
}
|
||||
|
||||
function toast(msg, type) {
|
||||
type = type || 'info';
|
||||
// Site-wide notification widget (aksrt-runtime notyf).
|
||||
if (window.aksrt && typeof window.aksrt.notyf === 'function') {
|
||||
window.aksrt.notyf(msg, { type: type, duration: 2200 });
|
||||
return;
|
||||
}
|
||||
if (typeof window.aksrtToast === 'function') {
|
||||
window.aksrtToast(msg, type);
|
||||
return;
|
||||
}
|
||||
if (typeof window.AksrtToast === 'function') {
|
||||
window.AksrtToast(msg, type);
|
||||
return;
|
||||
}
|
||||
// Last resort: non-blocking console (never native alert for UX).
|
||||
if (window.console && typeof window.console.log === 'function') {
|
||||
window.console.log('[aksrt]', type, msg);
|
||||
}
|
||||
}
|
||||
|
||||
function openModal(id) {
|
||||
var modal = document.getElementById(id);
|
||||
if (!modal) return;
|
||||
@@ -110,11 +89,11 @@
|
||||
.then(function (res) {
|
||||
if (!res.ok) {
|
||||
var msg = (res.data && (res.data.message || res.data.msg)) || '签到失败';
|
||||
toast(msg, 'danger');
|
||||
notyf(msg, 'danger');
|
||||
btn.disabled = false;
|
||||
return;
|
||||
}
|
||||
toast((res.data && res.data.message) || '签到成功', 'success');
|
||||
notyf((res.data && res.data.message) || '签到成功', 'success');
|
||||
btn.classList.add('is-done');
|
||||
btn.disabled = true;
|
||||
btn.setAttribute('disabled', 'disabled');
|
||||
@@ -127,7 +106,7 @@
|
||||
'<span>' + signedLabel + '</span>';
|
||||
})
|
||||
.catch(function () {
|
||||
toast('网络错误', 'danger');
|
||||
notyf('网络错误', 'danger');
|
||||
btn.disabled = false;
|
||||
});
|
||||
});
|
||||
|
||||
Reference in new issue
Block a user