mirror of
https://github.com/nagisa77/OpenIsle.git
synced 2026-04-21 11:27:27 +08:00
feat: improve notification details
This commit is contained in:
@@ -67,6 +67,29 @@
|
|||||||
进行了表态
|
进行了表态
|
||||||
</div>
|
</div>
|
||||||
</template>
|
</template>
|
||||||
|
<template v-else-if="item.type === 'POST_VIEWED'">
|
||||||
|
<div class="notif-content-container">
|
||||||
|
<router-link class="notif-content-text" @click="markRead(item.id)" :to="`/users/${item.fromUser.id}`">
|
||||||
|
{{ item.fromUser.username }}
|
||||||
|
</router-link>
|
||||||
|
查看了您的帖子
|
||||||
|
<router-link class="notif-content-text" @click="markRead(item.id)" :to="`/posts/${item.post.id}`">
|
||||||
|
{{ sanitizeDescription(item.post.title) }}
|
||||||
|
</router-link>
|
||||||
|
</div>
|
||||||
|
</template>
|
||||||
|
<template v-else-if="item.type === 'POST_UPDATED'">
|
||||||
|
<div class="notif-content-container">
|
||||||
|
您关注的帖子
|
||||||
|
<router-link class="notif-content-text" @click="markRead(item.id)" :to="`/posts/${item.post.id}`">
|
||||||
|
{{ sanitizeDescription(item.post.title) }}
|
||||||
|
</router-link>
|
||||||
|
下面有新评论
|
||||||
|
<router-link class="notif-content-text" @click="markRead(item.id)" :to="`/posts/${item.post.id}#comment-${item.comment.id}`">
|
||||||
|
{{ sanitizeDescription(item.comment.content) }}
|
||||||
|
</router-link>
|
||||||
|
</div>
|
||||||
|
</template>
|
||||||
<template v-else-if="item.type === 'USER_FOLLOWED'">
|
<template v-else-if="item.type === 'USER_FOLLOWED'">
|
||||||
<div class="notif-content-container">
|
<div class="notif-content-container">
|
||||||
<router-link class="notif-content-text" @click="markRead(item.id)" :to="`/users/${item.fromUser.id}`">
|
<router-link class="notif-content-text" @click="markRead(item.id)" :to="`/users/${item.fromUser.id}`">
|
||||||
@@ -225,6 +248,27 @@ export default {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
} else if (n.type === 'POST_VIEWED') {
|
||||||
|
notifications.value.push({
|
||||||
|
...n,
|
||||||
|
src: n.fromUser ? n.fromUser.avatar : null,
|
||||||
|
icon: n.fromUser ? undefined : iconMap[n.type],
|
||||||
|
iconClick: () => {
|
||||||
|
if (n.fromUser) {
|
||||||
|
markRead(n.id)
|
||||||
|
router.push(`/users/${n.fromUser.id}`)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
})
|
||||||
|
} else if (n.type === 'POST_UPDATED') {
|
||||||
|
notifications.value.push({
|
||||||
|
...n,
|
||||||
|
src: n.comment.author.avatar,
|
||||||
|
iconClick: () => {
|
||||||
|
markRead(n.id)
|
||||||
|
router.push(`/users/${n.comment.author.id}`)
|
||||||
|
}
|
||||||
|
})
|
||||||
} else if (n.type === 'USER_FOLLOWED' || n.type === 'USER_UNFOLLOWED') {
|
} else if (n.type === 'USER_FOLLOWED' || n.type === 'USER_UNFOLLOWED') {
|
||||||
notifications.value.push({
|
notifications.value.push({
|
||||||
...n,
|
...n,
|
||||||
|
|||||||
@@ -105,7 +105,12 @@ public class PostService {
|
|||||||
post.setViews(post.getViews() + 1);
|
post.setViews(post.getViews() + 1);
|
||||||
post = postRepository.save(post);
|
post = postRepository.save(post);
|
||||||
if (viewer != null && !viewer.equals(post.getAuthor().getUsername())) {
|
if (viewer != null && !viewer.equals(post.getAuthor().getUsername())) {
|
||||||
notificationService.createNotification(post.getAuthor(), NotificationType.POST_VIEWED, post, null, null);
|
User viewerUser = userRepository.findByUsername(viewer).orElse(null);
|
||||||
|
if (viewerUser != null) {
|
||||||
|
notificationService.createNotification(post.getAuthor(), NotificationType.POST_VIEWED, post, null, null, viewerUser, null);
|
||||||
|
} else {
|
||||||
|
notificationService.createNotification(post.getAuthor(), NotificationType.POST_VIEWED, post, null, null);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
return post;
|
return post;
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user