fix(frontend): simplify report dialog controls and feedback
Use highlight-only reason choices, show the associated target on one line, and replace inline submission progress with shared toast feedback. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
This commit is contained in:
1 parent
80aecab586
commit
b2811cc248
4 files changed
+86
-49
No files matched your search
@@ -66,34 +66,22 @@
|
||||
|
||||
.aksrt-report-target {
|
||||
display: flex;
|
||||
align-items: flex-start;
|
||||
gap: 12px;
|
||||
padding: 14px;
|
||||
margin-bottom: 24px;
|
||||
border-radius: 8px;
|
||||
background: var(--modal-surface-3);
|
||||
align-items: baseline;
|
||||
margin-bottom: 22px;
|
||||
}
|
||||
|
||||
.aksrt-report-target > div { min-width: 0; }
|
||||
|
||||
.aksrt-report-target__icon {
|
||||
display: grid;
|
||||
.aksrt-report-target__label {
|
||||
flex: none;
|
||||
place-items: center;
|
||||
width: 36px;
|
||||
height: 36px;
|
||||
border: 1px solid var(--modal-line);
|
||||
border-radius: 8px;
|
||||
background: var(--modal-surface);
|
||||
color: var(--modal-ink-2);
|
||||
color: var(--modal-muted);
|
||||
}
|
||||
|
||||
.aksrt-report-target__name {
|
||||
display: block;
|
||||
margin: 2px 0 4px;
|
||||
font-size: 15px;
|
||||
font-weight: 600;
|
||||
overflow-wrap: anywhere;
|
||||
min-width: 0;
|
||||
overflow: hidden;
|
||||
font-size: 14px;
|
||||
font-weight: 500;
|
||||
text-overflow: ellipsis;
|
||||
white-space: nowrap;
|
||||
}
|
||||
|
||||
.aksrt-report-hint,
|
||||
@@ -104,7 +92,6 @@
|
||||
}
|
||||
|
||||
.aksrt-report-form p { margin: 6px 0 0; }
|
||||
.aksrt-report-target p { margin: 0; }
|
||||
.aksrt-report-count { font-variant-numeric: tabular-nums; }
|
||||
|
||||
.aksrt-report-reasons {
|
||||
@@ -135,9 +122,10 @@
|
||||
}
|
||||
|
||||
.aksrt-report-reason {
|
||||
position: relative;
|
||||
display: flex;
|
||||
align-items: center;
|
||||
gap: 9px;
|
||||
justify-content: center;
|
||||
min-height: 44px;
|
||||
padding: 10px 12px;
|
||||
margin: 0;
|
||||
@@ -145,25 +133,31 @@
|
||||
border-radius: 8px;
|
||||
background: var(--modal-surface);
|
||||
font-weight: 400;
|
||||
text-align: center;
|
||||
cursor: pointer;
|
||||
overflow-wrap: anywhere;
|
||||
}
|
||||
|
||||
.aksrt-report-reason input[type="radio"] {
|
||||
position: static;
|
||||
display: block;
|
||||
flex: none;
|
||||
width: 16px;
|
||||
height: 16px;
|
||||
margin: 0;
|
||||
opacity: 1;
|
||||
appearance: auto;
|
||||
accent-color: var(--modal-primary);
|
||||
position: absolute;
|
||||
width: 1px;
|
||||
height: 1px;
|
||||
padding: 0;
|
||||
margin: -1px;
|
||||
overflow: hidden;
|
||||
border: 0;
|
||||
clip-path: inset(50%);
|
||||
white-space: nowrap;
|
||||
}
|
||||
|
||||
.aksrt-report-reason:has(input:checked) {
|
||||
border-color: var(--modal-primary);
|
||||
background: color-mix(in srgb, var(--modal-primary) 6%, var(--modal-surface));
|
||||
background: color-mix(in srgb, var(--modal-primary) 10%, var(--modal-surface));
|
||||
}
|
||||
|
||||
.aksrt-report-reason:has(input:focus-visible) {
|
||||
outline: 2px solid var(--modal-primary);
|
||||
outline-offset: 3px;
|
||||
}
|
||||
|
||||
.aksrt-report-reason input:checked + span { font-weight: 600; }
|
||||
|
||||
+14
-13
@@ -11,9 +11,9 @@
|
||||
var MAX_IMAGES = 3;
|
||||
var sequence = 0;
|
||||
var TARGETS = {
|
||||
user: { title: '举报用户', label: '用户', icon: 'fa-user' },
|
||||
post: { title: '举报文章', label: '文章', icon: 'fa-file-alt' },
|
||||
comment: { title: '举报评论', label: '评论', icon: 'fa-comment' },
|
||||
user: { title: '举报用户', label: '用户' },
|
||||
post: { title: '举报文章', label: '文章' },
|
||||
comment: { title: '举报评论', label: '评论' },
|
||||
};
|
||||
|
||||
function escapeHtml(value) {
|
||||
@@ -31,13 +31,11 @@
|
||||
var target = TARGETS[data.target_type];
|
||||
var report = config.report || {};
|
||||
var id = 'aksrt-report-' + (++sequence);
|
||||
var html = '<form class="aksrt-report-form" novalidate>';
|
||||
var name = data.target_name || target.label + ' #' + data.target_id;
|
||||
var html = '<form id="' + id + '" class="aksrt-report-form" novalidate>';
|
||||
html += '<div class="aksrt-report-body mini-scrollbar">';
|
||||
html += '<div class="aksrt-report-target">';
|
||||
html += '<span class="aksrt-report-target__icon" aria-hidden="true"><i class="fas ' + target.icon + '"></i></span>';
|
||||
html += '<div><span class="aksrt-report-hint">举报对象 · ' + target.label + '</span>';
|
||||
html += '<strong class="aksrt-report-target__name">' + escapeHtml(data.target_name || target.label + ' #' + data.target_id) + '</strong>';
|
||||
html += '<p class="aksrt-report-hint">已自动关联该' + target.label + ',无需填写链接</p></div></div>';
|
||||
html += '<div class="aksrt-report-target"><span class="aksrt-report-target__label">关联对象:</span>';
|
||||
html += '<strong class="aksrt-report-target__name" title="' + escapeHtml(name) + '">' + escapeHtml(name) + '</strong></div>';
|
||||
html += '<fieldset class="aksrt-report-reasons" aria-describedby="' + id + '-reason-error">';
|
||||
html += '<legend>举报原因<span class="aksrt-report-hint">必选一项</span></legend>';
|
||||
html += '<div class="aksrt-report-reasons__options">';
|
||||
@@ -90,6 +88,7 @@
|
||||
var descInput = form.querySelector('[name="report_desc"]');
|
||||
var fileInput = form.querySelector('[data-aksrt-report-file]');
|
||||
var images = [];
|
||||
var submitAttempts = 0;
|
||||
var submitting = false;
|
||||
var closed = false;
|
||||
|
||||
@@ -100,9 +99,9 @@
|
||||
function syncState() {
|
||||
var uploading = images.some(function (image) { return image.status === 'uploading'; });
|
||||
submit.disabled = submitting || uploading;
|
||||
submit.textContent = submitting ? '正在提交…' : uploading ? '图片上传中…' : '提交举报';
|
||||
submit.textContent = uploading ? '图片上传中…' : '提交举报';
|
||||
form.setAttribute('aria-busy', String(submitting || uploading));
|
||||
status.textContent = submitting ? '正在提交举报,请稍候' : uploading ? '图片正在上传,完成后即可提交' : '';
|
||||
status.textContent = uploading ? '图片正在上传,完成后即可提交' : '';
|
||||
var add = form.querySelector('[data-aksrt-report-add]');
|
||||
if (add) {
|
||||
add.disabled = submitting || images.length >= MAX_IMAGES;
|
||||
@@ -244,6 +243,8 @@
|
||||
if (images.length) reason += '\n图片举证:\n' + images.map(function (image) { return image.url; }).join('\n');
|
||||
submitting = true;
|
||||
syncState();
|
||||
var toastId = form.id + '-submit-' + (++submitAttempts);
|
||||
notyf('正在提交举报…', 'load', '', toastId);
|
||||
form.querySelectorAll('input, textarea, [data-aksrt-report-remove], [data-aksrt-report-retry]').forEach(function (element) { element.disabled = true; });
|
||||
window.fetch(API_ROOT + '/report/submit', {
|
||||
method: 'POST',
|
||||
@@ -258,8 +259,9 @@
|
||||
status.textContent = result.message || '举报已提交,我们会尽快处理';
|
||||
form.querySelector('[data-aksrt-modal-close]').textContent = '关闭';
|
||||
if (isActive()) window.AksrtModalRuntime.close('submit');
|
||||
notyf(result.message || '举报已提交,我们会尽快处理', 'success');
|
||||
notyf(result.message || '举报已提交,我们会尽快处理', 'success', 5, toastId);
|
||||
}).catch(function (failure) {
|
||||
notyf(failure.message || '网络错误,请重试', 'danger', 5, toastId);
|
||||
submitting = false;
|
||||
if (closed) {
|
||||
images.forEach(deletePending);
|
||||
@@ -268,7 +270,6 @@
|
||||
form.querySelectorAll('input, textarea, [data-aksrt-report-remove], [data-aksrt-report-retry]').forEach(function (element) { element.disabled = false; });
|
||||
otherInput.disabled = otherBox.hidden;
|
||||
syncState();
|
||||
showError(error, failure.message || '网络错误,请重试');
|
||||
});
|
||||
});
|
||||
|
||||
|
||||
Reference in new issue
Block a user