feat(user-center): upgrade posts panel to creator center

This commit is contained in:
kate522 committed 2026-08-06 16:24:59 +08:00
1 parent 7891ce7096
commit 2f9384f368
7 files changed
+123 -36

No files matched your search

+34 -1
View File
@@ -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();
}