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
@@ -21,15 +21,6 @@
|
||||
return '/wp-admin/admin-ajax.php';
|
||||
}
|
||||
|
||||
function toast(msg, type) {
|
||||
if (window.aksrt && typeof window.aksrt.toast === 'function') {
|
||||
window.aksrt.toast(msg, type || 'info');
|
||||
return;
|
||||
}
|
||||
// eslint-disable-next-line no-alert
|
||||
window.alert(msg);
|
||||
}
|
||||
|
||||
function initModal() {
|
||||
var modal = qs('#post-navs-sz');
|
||||
if (!modal) return;
|
||||
@@ -144,7 +135,7 @@
|
||||
if (id) ids.push(id);
|
||||
});
|
||||
if (!ids.length) {
|
||||
toast('请选择需要显示的分类', 'danger');
|
||||
notyf('请选择需要显示的分类', 'danger');
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -167,16 +158,16 @@
|
||||
.then(function (r) { return r.json(); })
|
||||
.then(function (data) {
|
||||
if (!data || data.error) {
|
||||
toast((data && data.msg) || '保存失败', 'danger');
|
||||
notyf((data && data.msg) || '保存失败', 'danger');
|
||||
return;
|
||||
}
|
||||
toast(data.msg || '保存成功', 'success');
|
||||
notyf(data.msg || '保存成功', 'success');
|
||||
if (data.reload) {
|
||||
window.setTimeout(function () { window.location.reload(); }, 400);
|
||||
}
|
||||
})
|
||||
.catch(function () {
|
||||
toast('网络错误', 'danger');
|
||||
notyf('网络错误', 'danger');
|
||||
})
|
||||
.finally(function () {
|
||||
if (btn) btn.disabled = false;
|
||||
|
||||
Reference in new issue
Block a user