mirror of
https://github.com/nagisa77/OpenIsle.git
synced 2026-03-02 18:10:47 +08:00
Compare commits
4 Commits
codex/fix-
...
codex/add-
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
13cc981421 | ||
|
|
efc8589ca0 | ||
|
|
940690889c | ||
|
|
d46420ef81 |
@@ -107,14 +107,52 @@ const likeCount = computed(() => counts.value['LIKE'] || 0)
|
|||||||
const userReacted = (type) =>
|
const userReacted = (type) =>
|
||||||
reactions.value.some((r) => r.type === type && r.user === authState.username)
|
reactions.value.some((r) => r.type === type && r.user === authState.username)
|
||||||
|
|
||||||
const displayedReactions = computed(() => {
|
const baseReactionOrder = computed(() => {
|
||||||
return Object.entries(counts.value)
|
if (reactionTypes.value.length) return [...reactionTypes.value]
|
||||||
.sort((a, b) => b[1] - a[1])
|
|
||||||
.slice(0, 3)
|
const order = []
|
||||||
.map(([type]) => ({ type }))
|
const seen = new Set()
|
||||||
|
for (const reaction of reactions.value) {
|
||||||
|
if (!seen.has(reaction.type)) {
|
||||||
|
seen.add(reaction.type)
|
||||||
|
order.push(reaction.type)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return order
|
||||||
})
|
})
|
||||||
|
|
||||||
const panelTypes = computed(() => reactionTypes.value.filter((t) => t !== 'LIKE'))
|
const sortedReactionTypes = computed(() => {
|
||||||
|
const baseOrder = [...baseReactionOrder.value]
|
||||||
|
for (const type of Object.keys(counts.value)) {
|
||||||
|
if (!baseOrder.includes(type)) baseOrder.push(type)
|
||||||
|
}
|
||||||
|
|
||||||
|
const withMetadata = baseOrder.map((type, index) => ({
|
||||||
|
type,
|
||||||
|
count: counts.value[type] || 0,
|
||||||
|
index,
|
||||||
|
}))
|
||||||
|
|
||||||
|
const nonZero = withMetadata
|
||||||
|
.filter((item) => item.count > 0)
|
||||||
|
.sort((a, b) => {
|
||||||
|
if (b.count !== a.count) return b.count - a.count
|
||||||
|
return a.index - b.index
|
||||||
|
})
|
||||||
|
|
||||||
|
const zero = withMetadata.filter((item) => item.count === 0)
|
||||||
|
|
||||||
|
return [...nonZero, ...zero].map((item) => item.type)
|
||||||
|
})
|
||||||
|
|
||||||
|
const displayedReactions = computed(() => {
|
||||||
|
return sortedReactionTypes.value
|
||||||
|
.filter((type) => counts.value[type] > 0)
|
||||||
|
.slice(0, 3)
|
||||||
|
.map((type) => ({ type }))
|
||||||
|
})
|
||||||
|
|
||||||
|
const panelTypes = computed(() => sortedReactionTypes.value.filter((t) => t !== 'LIKE'))
|
||||||
|
|
||||||
const panelVisible = ref(false)
|
const panelVisible = ref(false)
|
||||||
let hideTimer = null
|
let hideTimer = null
|
||||||
|
|||||||
@@ -122,7 +122,8 @@
|
|||||||
<l-hatch size="28" stroke="4" speed="3.5" color="var(--primary-color)"></l-hatch>
|
<l-hatch size="28" stroke="4" speed="3.5" color="var(--primary-color)"></l-hatch>
|
||||||
</div>
|
</div>
|
||||||
<div v-else class="comments-container">
|
<div v-else class="comments-container">
|
||||||
<BaseTimeline :items="timelineItems">
|
<BasePlaceholder v-if="timelineItems.length === 0" text="暂无评论" icon="inbox" />
|
||||||
|
<BaseTimeline v-else :items="timelineItems">
|
||||||
<template #item="{ item }">
|
<template #item="{ item }">
|
||||||
<CommentItem
|
<CommentItem
|
||||||
v-if="item.kind === 'comment'"
|
v-if="item.kind === 'comment'"
|
||||||
@@ -184,6 +185,7 @@ import { useRoute } from 'vue-router'
|
|||||||
import CommentItem from '~/components/CommentItem.vue'
|
import CommentItem from '~/components/CommentItem.vue'
|
||||||
import CommentEditor from '~/components/CommentEditor.vue'
|
import CommentEditor from '~/components/CommentEditor.vue'
|
||||||
import BaseTimeline from '~/components/BaseTimeline.vue'
|
import BaseTimeline from '~/components/BaseTimeline.vue'
|
||||||
|
import BasePlaceholder from '~/components/BasePlaceholder.vue'
|
||||||
import PostChangeLogItem from '~/components/PostChangeLogItem.vue'
|
import PostChangeLogItem from '~/components/PostChangeLogItem.vue'
|
||||||
import ArticleTags from '~/components/ArticleTags.vue'
|
import ArticleTags from '~/components/ArticleTags.vue'
|
||||||
import ArticleCategory from '~/components/ArticleCategory.vue'
|
import ArticleCategory from '~/components/ArticleCategory.vue'
|
||||||
@@ -813,9 +815,7 @@ const fetchCommentsAndChangeLog = async () => {
|
|||||||
|
|
||||||
for (const item of data) {
|
for (const item of data) {
|
||||||
const mappedPayload =
|
const mappedPayload =
|
||||||
item.kind === 'comment'
|
item.kind === 'comment' ? mapComment(item.payload) : mapChangeLog(item.payload)
|
||||||
? mapComment(item.payload)
|
|
||||||
: mapChangeLog(item.payload)
|
|
||||||
newTimelineItemList.push(mappedPayload)
|
newTimelineItemList.push(mappedPayload)
|
||||||
|
|
||||||
if (item.kind === 'comment') {
|
if (item.kind === 'comment') {
|
||||||
|
|||||||
Reference in New Issue
Block a user