|
@@ -11,20 +11,18 @@ const notificationMsgStore = useNotificationMessage()
|
|
|
const notificationList = ref([])
|
|
const notificationList = ref([])
|
|
|
|
|
|
|
|
const curIndex = ref(0)
|
|
const curIndex = ref(0)
|
|
|
-// const displayedList = ref([])
|
|
|
|
|
-// const isNewCard = (id) => {
|
|
|
|
|
-// if (!id) return false
|
|
|
|
|
-// return !displayedList.value.some((item) => item.info.id === id)
|
|
|
|
|
-// }
|
|
|
|
|
|
|
+const displayedList = ref([])
|
|
|
|
|
+const isNewCard = (id) => {
|
|
|
|
|
+ if (!id) return false
|
|
|
|
|
+ return !displayedList.value.some((item) => item.info.id === id)
|
|
|
|
|
+}
|
|
|
const curCard = computed(() => {
|
|
const curCard = computed(() => {
|
|
|
- // if (
|
|
|
|
|
- // notificationList.value[curIndex.value] &&
|
|
|
|
|
- // isNewCard(notificationList.value[curIndex.value].info.id)
|
|
|
|
|
- // ) {
|
|
|
|
|
- // displayedList.value.push(notificationList.value[curIndex.value])
|
|
|
|
|
- // } else {
|
|
|
|
|
- // console.log('no curCard')
|
|
|
|
|
- // }
|
|
|
|
|
|
|
+ if (
|
|
|
|
|
+ notificationList.value[curIndex.value] &&
|
|
|
|
|
+ isNewCard(notificationList.value[curIndex.value].info.id)
|
|
|
|
|
+ ) {
|
|
|
|
|
+ displayedList.value.push(notificationList.value[curIndex.value])
|
|
|
|
|
+ }
|
|
|
return notificationList.value[curIndex.value] || null
|
|
return notificationList.value[curIndex.value] || null
|
|
|
})
|
|
})
|
|
|
|
|
|
|
@@ -48,6 +46,11 @@ const trainingCardAfterLogin = () => {
|
|
|
// 如果消息展示完毕,清除定时器
|
|
// 如果消息展示完毕,清除定时器
|
|
|
if (curIndex.value >= notificationList.value.length) {
|
|
if (curIndex.value >= notificationList.value.length) {
|
|
|
clearInterval(trainingIntervalId)
|
|
clearInterval(trainingIntervalId)
|
|
|
|
|
+ // 将已经展示的消息标记为已读
|
|
|
|
|
+ notificationMsgStore.markMessageAsReadAfterCarousel(
|
|
|
|
|
+ displayedList.value.map((item) => item.info.id)
|
|
|
|
|
+ )
|
|
|
|
|
+ displayedList.value = []
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
|
|
|
|
|
@@ -67,6 +70,12 @@ const nextNotification = () => {
|
|
|
if (curIndex.value >= notificationList.value.length) {
|
|
if (curIndex.value >= notificationList.value.length) {
|
|
|
clearInterval(trainingIntervalId)
|
|
clearInterval(trainingIntervalId)
|
|
|
result = false
|
|
result = false
|
|
|
|
|
+
|
|
|
|
|
+ // 将已经展示的消息标记为已读
|
|
|
|
|
+ notificationMsgStore.markMessageAsReadAfterCarousel(
|
|
|
|
|
+ displayedList.value.map((item) => item.info.id)
|
|
|
|
|
+ )
|
|
|
|
|
+ displayedList.value = []
|
|
|
}
|
|
}
|
|
|
return result
|
|
return result
|
|
|
}
|
|
}
|
|
@@ -117,6 +126,12 @@ const getNotificationList = (time?: string) => {
|
|
|
|
|
|
|
|
// 关闭消息,如果是登录后自动轮播的消息,则需清除定时器,如果不是则继续轮播下一条消息
|
|
// 关闭消息,如果是登录后自动轮播的消息,则需清除定时器,如果不是则继续轮播下一条消息
|
|
|
const closeMessage = () => {
|
|
const closeMessage = () => {
|
|
|
|
|
+ // 将已经展示的消息标记为已读
|
|
|
|
|
+ notificationMsgStore.markMessageAsReadAfterCarousel(
|
|
|
|
|
+ displayedList.value.map((item) => item.info.id)
|
|
|
|
|
+ )
|
|
|
|
|
+ displayedList.value = []
|
|
|
|
|
+
|
|
|
if (!newMessageIntervalId) {
|
|
if (!newMessageIntervalId) {
|
|
|
clearInterval(trainingIntervalId)
|
|
clearInterval(trainingIntervalId)
|
|
|
curIndex.value = -1
|
|
curIndex.value = -1
|
|
@@ -147,6 +162,7 @@ const closeMessage = () => {
|
|
|
<NotificationMessageCard
|
|
<NotificationMessageCard
|
|
|
v-if="curCard"
|
|
v-if="curCard"
|
|
|
:data="[curCard]"
|
|
:data="[curCard]"
|
|
|
|
|
+ :isObserver="false"
|
|
|
:topOffset="0"
|
|
:topOffset="0"
|
|
|
:isDrawer="true"
|
|
:isDrawer="true"
|
|
|
></NotificationMessageCard>
|
|
></NotificationMessageCard>
|