feat(user-center): upgrade posts panel to creator center
This commit is contained in:
1 parent
7891ce7096
commit
2f9384f368
7 files changed
+123
-36
No files matched your search
@@ -479,6 +479,29 @@
|
||||
padding-bottom: 12px;
|
||||
border-bottom: 2px solid var(--color-primary-50);
|
||||
}
|
||||
|
||||
.creator-center-header {
|
||||
align-items: flex-start;
|
||||
}
|
||||
.creator-center-heading {
|
||||
min-width: 220px;
|
||||
}
|
||||
.creator-center-heading__summary {
|
||||
margin: 4px 0 0;
|
||||
color: var(--color-ink-4);
|
||||
font-size: 12px;
|
||||
}
|
||||
.creator-center-actions {
|
||||
display: flex;
|
||||
flex-wrap: wrap;
|
||||
align-items: center;
|
||||
justify-content: flex-end;
|
||||
gap: 10px;
|
||||
}
|
||||
.creator-center-actions .profile-status-filter {
|
||||
justify-content: flex-end;
|
||||
}
|
||||
|
||||
.widget-title--inline {
|
||||
margin: 0;
|
||||
padding: 0;
|
||||
|
||||
@@ -16,6 +16,7 @@
|
||||
var ajaxUrl = cfg.ajaxUrl || '';
|
||||
var publicNonce = cfg.publicNonce || '';
|
||||
var settingsNonce = cfg.settingsNonce || '';
|
||||
var submitNonce = cfg.submitNonce || '';
|
||||
var userId = cfg.userId || 0;
|
||||
var i18n = cfg.i18n || {};
|
||||
var tabAliases = cfg.tabAliases || {};
|
||||
@@ -698,13 +699,44 @@
|
||||
});
|
||||
}
|
||||
|
||||
/* ==================== 初始化 ==================== */
|
||||
/* ==================== 创作中心文章操作 ==================== */
|
||||
function initCreatorPostActions() {
|
||||
document.addEventListener('click', function(e) {
|
||||
var btn = e.target.closest('[data-action="delete-post"]');
|
||||
if (!btn || btn.disabled) return;
|
||||
if (!confirm(i18n.confirmDeletePost || '确定删除这篇文章?')) return;
|
||||
var postId = btn.getAttribute('data-post-id');
|
||||
var nonce = btn.getAttribute('data-nonce') || submitNonce;
|
||||
if (!postId || !nonce) return;
|
||||
btn.disabled = true;
|
||||
var body = new URLSearchParams();
|
||||
body.set('action', 'aksrt_delete_post');
|
||||
body.set('id', postId);
|
||||
body.set('_nonce', nonce);
|
||||
fetch(ajaxUrl, { method: 'POST', headers: { 'Content-Type': 'application/x-www-form-urlencoded; charset=UTF-8' }, credentials: 'same-origin', body: body.toString() })
|
||||
.then(function(r) { return r.json(); })
|
||||
.then(function(res) {
|
||||
if (res && res.success) {
|
||||
var item = btn.closest('.profile-list-item');
|
||||
if (item) item.remove();
|
||||
showToast((res.data && res.data.message) || '文章已经删除');
|
||||
} else {
|
||||
btn.disabled = false;
|
||||
showToast((res && res.data && res.data.message) || i18n.operationFailed || '操作失败');
|
||||
}
|
||||
})
|
||||
.catch(function() { btn.disabled = false; showToast(i18n.networkError || '网络错误'); });
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
if (document.readyState === 'loading') {
|
||||
document.addEventListener('DOMContentLoaded', function() {
|
||||
initDashboardNavigation();
|
||||
initProfileForm();
|
||||
initAuthForm();
|
||||
initUnfavorite();
|
||||
initCreatorPostActions();
|
||||
initNotifications();
|
||||
initSettings();
|
||||
});
|
||||
@@ -713,6 +745,7 @@
|
||||
initProfileForm();
|
||||
initAuthForm();
|
||||
initUnfavorite();
|
||||
initCreatorPostActions();
|
||||
initNotifications();
|
||||
initSettings();
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user