feat: SSR 评论回复、点赞与私密开关

帖详情支持 reply_to 展示与提交、评论点赞 PRG,以及私密评论选项。

Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
2026-08-29 06:46:41 +08:00
parent 4dc196b055
commit d4b29f5b7c
10 changed files with 209 additions and 20 deletions

View File

@@ -235,12 +235,23 @@ body.j13-body {
}
.j13-comment__meta {
display: flex;
flex-wrap: wrap;
gap: 0.75rem;
color: var(--j13-muted);
font-size: 0.8rem;
margin-bottom: 0.35rem;
align-items: center;
}
.j13-comment__reply-to a { color: var(--j13-accent); text-decoration: none; }
.j13-comment__actions {
display: flex;
gap: 0.75rem;
align-items: center;
margin-top: 0.4rem;
}
.j13-comment-reply-hint { margin: 0 0 0.5rem; }
.j13-comment-form textarea { width: 100%; }
.j13-comment-form .j13-form__row { margin-top: 0.5rem; }
.j13-muted { color: var(--j13-muted); }
.j13-install fieldset {
border: 1px solid var(--j13-border);

View File

@@ -203,3 +203,42 @@ document.documentElement.dataset.j13Ssr = "1";
}
});
})();
// 评论回复:点击「回复」填入 reply_to
(function () {
const form = document.getElementById("comment-form");
if (!form) return;
const replyInput = document.getElementById("comment-reply-to");
const hint = document.getElementById("comment-reply-hint");
const clearBtn = document.getElementById("comment-reply-clear");
const content = document.getElementById("comment-content");
function clearReply() {
if (replyInput) replyInput.value = "";
if (hint) {
hint.hidden = true;
hint.textContent = "";
}
if (clearBtn) clearBtn.hidden = true;
}
function setReply(id, floor, author) {
if (!replyInput) return;
replyInput.value = id;
if (hint) {
hint.hidden = false;
hint.textContent = "回复 #" + floor + (author ? " " + author : "");
}
if (clearBtn) clearBtn.hidden = false;
if (content) content.focus();
form.scrollIntoView({ behavior: "smooth", block: "nearest" });
}
document.querySelectorAll(".j13-comment__reply-btn").forEach((btn) => {
btn.addEventListener("click", () => {
setReply(
btn.getAttribute("data-reply-to") || "",
btn.getAttribute("data-reply-floor") || "",
btn.getAttribute("data-reply-author") || ""
);
});
});
if (clearBtn) clearBtn.addEventListener("click", clearReply);
})();