feat(ban): align ban prompts with the reference theme modals and block page
对照参考主题(Zibll)修正四项偏差,申诉链路从页面整体迁移至弹窗:
- feat(ban): 新增三个 1:1 复刻弹窗(REST /user-ban/{info,appeal,log}-modal):
查看禁封状态(多彩头 c-gray + 信息行 + 申诉按钮)、禁封申诉(edit-header
gavel/c-blue + 信息框 + 资料项 data[key] 输入 + 审核中态 + 禁止申诉态)、
禁封记录(多彩头 c-yellow + 计数 + 逐条卡片);user-ban.js 增加
data-aksrt-ban-info/appeal/log 委托与 admin-ajax 申诉提交
- feat(ban): 禁封/解封弹窗的「当前用户已有N次禁封记录」静态文案改为可点击
黄链(N>1),打开禁封记录弹窗;解封视图信息行改复用统一数据源
- refactor(ban): 治理展示态收敛至 Restriction::state_badges()(封号=c-red
违规已封号 / 小黑屋=c-yellow 小黑屋禁封中 / 禁言=c-gray 禁言中,颜色与
字段统一管理)+ get_ban_info()(状态/起止时间/原因/说明/申诉权限,
三弹窗与禁封页共用)
- feat(ban): 登录行为对齐参考主题——移除登录期拦截(enforce_login_ban)
与 complete_login 禁封闸门,封号用户可正常登录;新增 template_redirect
前台禁封页(1:1 zib_user_ban_restrict_login/zib_die_page:红盒提示 +
信息行 + 申诉权限 + 退出登录/申诉按钮,模板 templates/parts/user/ban-block.php)
- feat(profile): 公开主页禁封状态从资料卡下方提示框改为占据身份行元信息位
的 badg 徽章(参考主题 author_header_identity 语义);用户中心元信息改为
but 按钮(徽章+箭头)打开查看禁封状态弹窗;评论拒绝态链接同源
- refactor: 移除申诉页面模板(page-ban-appeal.php)及其资产/注册/入队、
get_profile_notice/profile_notice 链、state_labels/state_notices/
login_ban_message、UserRuntime 的 public_notice/ban_notice_text 死配置、
report_settings 死键、无消费方的 aksrt_ban_appeal_status 端点
- feat(ban): BanAppeal::ajax_submit 兼容弹窗 data[key] 表单结构
(逐项清洗入库,申诉说明取 data['申诉说明'],旧平铺字段保持兼容)
- chore: 重新构建 public.css/public.min.css(三个新弹窗几何与头部样式)
- test: 契约测试重写(徽章元信息位、三弹窗与记录链接、禁封页、允许登录 +
前台拦截、死代码移除断言),全量 362 项通过
This commit is contained in:
@@ -30,7 +30,6 @@
|
||||
binding_conflict: '该第三方账号已绑定其他账号',
|
||||
account_conflict: '该第三方账号无法绑定到当前账号',
|
||||
already_bound: '该第三方账号已绑定其他账号',
|
||||
account_banned: '您的账号已被封禁,禁封期间无法登录',
|
||||
timeout: '第三方授权已超时,请重试',
|
||||
};
|
||||
var oauthProviderLabels = {
|
||||
|
||||
@@ -1,36 +0,0 @@
|
||||
/**
|
||||
* Ban appeal form submit.
|
||||
* @package AKSRT
|
||||
*/
|
||||
(function () {
|
||||
'use strict';
|
||||
function ajaxUrl() {
|
||||
if (window.aksrtData && window.aksrtData.ajaxUrl) return window.aksrtData.ajaxUrl;
|
||||
if (window._win && window._win.ajax_url) return window._win.ajax_url;
|
||||
return '/wp-admin/admin-ajax.php';
|
||||
}
|
||||
function init() {
|
||||
var form = document.querySelector('.aksrt-ban-appeal-form');
|
||||
if (!form) return;
|
||||
form.addEventListener('submit', function (e) {
|
||||
e.preventDefault();
|
||||
var btn = form.querySelector('button[type="submit"]');
|
||||
if (btn) btn.disabled = true;
|
||||
var fd = new FormData(form);
|
||||
if (!fd.get('action')) fd.set('action', 'aksrt_ban_appeal_submit');
|
||||
fetch(ajaxUrl(), { method: 'POST', body: fd, credentials: 'same-origin' })
|
||||
.then(function (r) { return r.json(); })
|
||||
.then(function (data) {
|
||||
if (!data || data.error) {
|
||||
notyf((data && data.msg) || '提交失败', 'danger');
|
||||
return;
|
||||
}
|
||||
notyf(data.msg || '提交成功');
|
||||
if (data.reload) window.setTimeout(function () { location.reload(); }, 400);
|
||||
})
|
||||
.catch(function () { notyf('网络错误', 'danger'); })
|
||||
.finally(function () { if (btn) btn.disabled = false; });
|
||||
});
|
||||
}
|
||||
jQuery(document).off('auto_fun.aksrt-ban-appeal-page').on('auto_fun.aksrt-ban-appeal-page', init);
|
||||
})();
|
||||
@@ -1044,7 +1044,6 @@
|
||||
bind_verification_required: '请先完成人机验证后再绑定',
|
||||
account_conflict: '该第三方账号无法绑定到当前账号',
|
||||
already_bound: '该第三方账号已绑定其他账号',
|
||||
account_banned: '您的账号已被封禁,禁封期间无法登录',
|
||||
timeout: '第三方授权已超时,请重试'
|
||||
};
|
||||
var providerLabel = providerLabels[provider] || '';
|
||||
|
||||
+133
-2
@@ -5,6 +5,10 @@
|
||||
* - zib_get_edit_user_ban_link → [data-aksrt-ban] 委托入口(三点菜单内)
|
||||
* - zib_get_set_user_ban_modal → REST /user-ban/modal 拉取弹窗内容
|
||||
* - zib_ajax_set_user_ban → REST /user-ban/set 提交
|
||||
* - zib_get_ban_info_modal → [data-aksrt-ban-info](查看禁封状态)
|
||||
* - zib_get_user_ban_appeal_modal → [data-aksrt-ban-appeal](禁封申诉)
|
||||
* - zib_get_ban_log_modal → [data-aksrt-ban-log](禁封记录)
|
||||
* - zib_user_ban_appeal(wp-ajax) → admin-ajax aksrt_ban_appeal_submit 提交
|
||||
*
|
||||
* 弹窗经 AksrtModalRuntime.openRemote 打开(与参考主题 refresh_modal 每次刷新
|
||||
* 同语义):桌面 600px 宽(参考主题未传 data-class → Bootstrap .modal-dialog
|
||||
@@ -24,15 +28,28 @@
|
||||
return String(raw).replace(/\/$/, '');
|
||||
})();
|
||||
var NONCE = (window.aksrtData && window.aksrtData.restNonce) || '';
|
||||
var AJAX_URL = (window.aksrtData && window.aksrtData.ajaxUrl)
|
||||
|| (window._win && window._win.ajax_url)
|
||||
|| '/wp-admin/admin-ajax.php';
|
||||
|
||||
var MODAL_HEIGHT = 360;
|
||||
// 参考主题 data_class='modal-mini' + data-height=240:400px 宽、初始高 240。
|
||||
var MINI_MODAL_HEIGHT = 240;
|
||||
|
||||
function openBanModal(userId) {
|
||||
function ajaxUrl() {
|
||||
return AJAX_URL;
|
||||
}
|
||||
|
||||
function openRemoteModal(options) {
|
||||
if (!window.AksrtModalRuntime || typeof window.AksrtModalRuntime.openRemote !== 'function') {
|
||||
notyf('禁封组件加载失败,请刷新页面后重试', 'danger');
|
||||
return;
|
||||
}
|
||||
window.AksrtModalRuntime.openRemote({
|
||||
window.AksrtModalRuntime.openRemote(options);
|
||||
}
|
||||
|
||||
function openBanModal(userId) {
|
||||
openRemoteModal({
|
||||
url: API_ROOT + '/user-ban/modal',
|
||||
method: 'GET',
|
||||
query: { user_id: userId },
|
||||
@@ -47,6 +64,93 @@
|
||||
});
|
||||
}
|
||||
|
||||
// 查看禁封状态弹窗(参考主题 zib_get_ban_info_modal / user_ban_info_modal)。
|
||||
function openInfoModal(userId) {
|
||||
openRemoteModal({
|
||||
url: API_ROOT + '/user-ban/info-modal',
|
||||
method: 'GET',
|
||||
query: { user_id: userId },
|
||||
cache: false,
|
||||
height: MINI_MODAL_HEIGHT,
|
||||
mobileBottom: true,
|
||||
kind: 'user-ban-info',
|
||||
className: 'aksrt-user-ban-info-modal',
|
||||
});
|
||||
}
|
||||
|
||||
// 禁封申诉弹窗(参考主题 zib_get_user_ban_appeal_modal;表单走 admin-ajax)。
|
||||
function openAppealModal(userId) {
|
||||
openRemoteModal({
|
||||
url: API_ROOT + '/user-ban/appeal-modal',
|
||||
method: 'GET',
|
||||
query: { user_id: userId },
|
||||
cache: false,
|
||||
height: MINI_MODAL_HEIGHT,
|
||||
mobileBottom: true,
|
||||
kind: 'user-ban-appeal',
|
||||
className: 'aksrt-user-ban-appeal-modal',
|
||||
onContent: function (html, session) {
|
||||
if (session && session.shell) bindAppealForm(session.shell);
|
||||
},
|
||||
});
|
||||
}
|
||||
|
||||
// 禁封记录弹窗(参考主题 zib_get_ban_log_modal)。
|
||||
function openLogModal(userId) {
|
||||
openRemoteModal({
|
||||
url: API_ROOT + '/user-ban/log-modal',
|
||||
method: 'GET',
|
||||
query: { user_id: userId },
|
||||
cache: false,
|
||||
height: MINI_MODAL_HEIGHT,
|
||||
mobileBottom: true,
|
||||
kind: 'user-ban-log',
|
||||
className: 'aksrt-user-ban-log-modal',
|
||||
});
|
||||
}
|
||||
|
||||
function bindAppealForm(shell) {
|
||||
var form = shell.querySelector('[data-aksrt-appeal-form]');
|
||||
if (!form || form.dataset.aksrtAppealBound === '1') return;
|
||||
form.dataset.aksrtAppealBound = '1';
|
||||
Array.prototype.forEach.call(form.querySelectorAll('textarea.form-control'), bindAutoHeight);
|
||||
form.addEventListener('submit', function (event) {
|
||||
event.preventDefault();
|
||||
submitAppeal(form);
|
||||
});
|
||||
}
|
||||
|
||||
function submitAppeal(form) {
|
||||
var btn = form.querySelector('[data-aksrt-appeal-submit]');
|
||||
if (btn) btn.disabled = true;
|
||||
notyf('正在提交申诉…', 'load', 3000, 'aksrt-appeal-submit');
|
||||
var fd = new FormData(form);
|
||||
if (!fd.get('action')) fd.set('action', 'aksrt_ban_appeal_submit');
|
||||
fetch(ajaxUrl(), { method: 'POST', body: fd, credentials: 'same-origin' })
|
||||
.then(function (res) { return res.json(); })
|
||||
.then(function (data) {
|
||||
if (data && !data.error) {
|
||||
notyf(data.msg || '申诉已提交', 'success');
|
||||
if (data.reload) {
|
||||
window.setTimeout(function () { window.location.reload(); }, 400);
|
||||
} else if (window.AksrtModalRuntime && typeof window.AksrtModalRuntime.close === 'function') {
|
||||
window.AksrtModalRuntime.close('submit');
|
||||
}
|
||||
} else {
|
||||
if (btn) btn.disabled = false;
|
||||
notyf((data && data.msg) || '提交失败', 'danger');
|
||||
}
|
||||
})
|
||||
.catch(function () {
|
||||
if (btn) btn.disabled = false;
|
||||
notyf('网络错误,请重试', 'danger');
|
||||
})
|
||||
.then(function () {
|
||||
var toast = document.getElementById('aksrt-appeal-submit');
|
||||
if (toast) toast.remove();
|
||||
});
|
||||
}
|
||||
|
||||
function collectPayload(shell, userId, unban) {
|
||||
var payload = { user_id: userId, ban: unban ? 0 : 1 };
|
||||
if (unban) {
|
||||
@@ -212,6 +316,33 @@
|
||||
return;
|
||||
}
|
||||
|
||||
// 查看禁封状态入口(用户中心元信息 / 评论拒绝态 / 禁封信息弹窗内申诉按钮)。
|
||||
var infoBtn = event.target.closest('[data-aksrt-ban-info]');
|
||||
if (infoBtn) {
|
||||
event.preventDefault();
|
||||
var infoUser = parseInt(infoBtn.getAttribute('data-aksrt-ban-info'), 10);
|
||||
if (infoUser > 0) openInfoModal(infoUser);
|
||||
return;
|
||||
}
|
||||
|
||||
// 申诉入口(禁封信息弹窗 / 登录后禁封页)。
|
||||
var appealBtn = event.target.closest('[data-aksrt-ban-appeal]');
|
||||
if (appealBtn) {
|
||||
event.preventDefault();
|
||||
var appealUser = parseInt(appealBtn.getAttribute('data-aksrt-ban-appeal'), 10);
|
||||
if (appealUser > 0) openAppealModal(appealUser);
|
||||
return;
|
||||
}
|
||||
|
||||
// 禁封记录入口(禁封/解封弹窗内的记录链接,仅管理员)。
|
||||
var logBtn = event.target.closest('[data-aksrt-ban-log]');
|
||||
if (logBtn) {
|
||||
event.preventDefault();
|
||||
var logUser = parseInt(logBtn.getAttribute('data-aksrt-ban-log'), 10);
|
||||
if (logUser > 0) openLogModal(logUser);
|
||||
return;
|
||||
}
|
||||
|
||||
// 弹窗内交互(事件委托到 document,弹窗壳由 runtime portal 到 body)。
|
||||
var active = window.AksrtModalRuntime && window.AksrtModalRuntime.getActive
|
||||
? window.AksrtModalRuntime.getActive()
|
||||
|
||||
Reference in New Issue
Block a user