feat: @提及发送通知 + 通知点击定位高亮
- 新增 NotifyCommentMention 通知类型,归属 mention 分类 TAB - parseMentions 中向被@用户发送通知(排除自己和重复通知) - 消息中心 mention 通知可点击跳转至文章页面 - 通过 mention 通知进入时,来源评论置顶并持久半透明高亮 - 普通评论链接保持原有短暂高亮行为不变
This commit is contained in:
@ -97,6 +97,12 @@
|
||||
{{else}}
|
||||
{{$link = printf "/posts/%d#comments" (derefUint $m.RelatedID)}}
|
||||
{{end}}
|
||||
{{else if eq $m.NotifyType "comment_mention"}}
|
||||
{{if $m.CommentID}}
|
||||
{{$link = printf "/posts/%d#mention-%d" (derefUint $m.RelatedID) (derefUint $m.CommentID)}}
|
||||
{{else}}
|
||||
{{$link = printf "/posts/%d#comments" (derefUint $m.RelatedID)}}
|
||||
{{end}}
|
||||
{{else if or (eq $m.NotifyType "audit_approved") (eq $m.NotifyType "audit_rejected")}}
|
||||
{{$link = "/settings"}}
|
||||
{{else if eq $m.NotifyType "follow"}}
|
||||
|
||||
@ -1096,6 +1096,12 @@
|
||||
border-bottom: none;
|
||||
}
|
||||
|
||||
/* @提及通知进入:持久半透明高亮 */
|
||||
.comment-card.highlight-mention,
|
||||
.comment-reply-card.highlight-mention {
|
||||
background: rgba(255, 248, 225, 0.5) !important;
|
||||
}
|
||||
|
||||
.comment-header {
|
||||
display: flex;
|
||||
justify-content: space-between;
|
||||
|
||||
@ -498,21 +498,45 @@
|
||||
}
|
||||
|
||||
// ====== 评论高亮 ======
|
||||
function highlightComment(commentId) {
|
||||
function highlightComment(commentId, persistent) {
|
||||
var card = commentsList.querySelector('.comment-card[data-id="' + commentId + '"]') ||
|
||||
commentsList.querySelector('.comment-reply-card[data-id="' + commentId + '"]');
|
||||
if (card) {
|
||||
commentsList.insertBefore(card, commentsList.firstChild);
|
||||
card.scrollIntoView({ behavior: 'smooth', block: 'start' });
|
||||
card.style.background = '#fff8e1';
|
||||
card.style.transition = 'background 1.5s';
|
||||
setTimeout(function() { card.style.background = ''; }, 2000);
|
||||
if (persistent) {
|
||||
card.classList.add('highlight-mention');
|
||||
} else {
|
||||
card.style.background = '#fff8e1';
|
||||
card.style.transition = 'background 1.5s';
|
||||
setTimeout(function() { card.style.background = ''; }, 2000);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
var hash = window.location.hash;
|
||||
|
||||
// @提及通知进入:置顶 + 持久高亮
|
||||
var mentionMatch = hash.match(/^#mention-(\d+)$/);
|
||||
if (mentionMatch) {
|
||||
var mentionCommentId = mentionMatch[1];
|
||||
var mentionInterval = setInterval(function() {
|
||||
if (highlightComment(mentionCommentId, true)) {
|
||||
clearInterval(mentionInterval);
|
||||
}
|
||||
}, 300);
|
||||
setTimeout(function() {
|
||||
clearInterval(mentionInterval);
|
||||
if (!commentsList.querySelector('.comment-card[data-id="' + mentionCommentId + '"]') &&
|
||||
!commentsList.querySelector('.comment-reply-card[data-id="' + mentionCommentId + '"]')) {
|
||||
showToast('该评论已不存在');
|
||||
}
|
||||
}, 3000);
|
||||
}
|
||||
|
||||
// 普通评论/回复链接:短暂高亮
|
||||
var commentMatch = hash.match(/^#comment-(\d+)$/);
|
||||
if (commentMatch) {
|
||||
var targetCommentId = commentMatch[1];
|
||||
|
||||
Reference in New Issue
Block a user