|
|
@@ -2,113 +2,10 @@
|
|
|
import { onBeforeRouteUpdate } from 'vue-router'
|
|
|
import NotificationMessageCard from '@/components/NotificationMessageCard/src/NotificationMessageCard.vue'
|
|
|
import { useUserStore } from '@/stores/modules/user'
|
|
|
-import { useNotificationMessage } from '@/stores/modules/notificationMessage'
|
|
|
import dayjs from 'dayjs'
|
|
|
|
|
|
const userStore = useUserStore()
|
|
|
-const notificationMsgStore = useNotificationMessage()
|
|
|
const notificationList = ref([])
|
|
|
-// const notificationList = [
|
|
|
-// {
|
|
|
-// notificationType: 'feature',
|
|
|
-// info: {
|
|
|
-// title: 'Feature Update',
|
|
|
-// header: 'New feature online: Quick search has been released!',
|
|
|
-// content:
|
|
|
-// 'We are pleased to announce that the quick search function is now officially online! You can now quickly find what you need by entering keywords, greatly improving your work efficiency. Go and experience it!'
|
|
|
-// }
|
|
|
-// },
|
|
|
-// {
|
|
|
-// notificationType: 'event',
|
|
|
-// info: {
|
|
|
-// type: 'milestone',
|
|
|
-// isMultiple: true,
|
|
|
-// numericRecords: 3,
|
|
|
-// isRead: true,
|
|
|
-// title: 'Milestone Update',
|
|
|
-// mode: 'Ocean Freight',
|
|
|
-// no: 'HBOL: SHJN2301234',
|
|
|
-// tag: 'Booking Confirmed',
|
|
|
-// location: 'Hong Kong',
|
|
|
-// time: 'Jan 10, 2025 14:30 UTC+8'
|
|
|
-// }
|
|
|
-// },
|
|
|
-// {
|
|
|
-// notificationType: 'password',
|
|
|
-// info: {
|
|
|
-// title: 'Password Notifications',
|
|
|
-// isExpiration: true,
|
|
|
-// tips: 'Password Expiration in 311 Days',
|
|
|
-// content:
|
|
|
-// 'Your password will expire in 7 days. To ensure the security of your account, please change your password as soon as possible.'
|
|
|
-// }
|
|
|
-// },
|
|
|
-// {
|
|
|
-// notificationType: 'password',
|
|
|
-// info: {
|
|
|
-// title: 'Password Notifications',
|
|
|
-// isExpiration: false,
|
|
|
-// tips: 'Password Expiration in 3 Days',
|
|
|
-// content:
|
|
|
-// 'Your password will expire in 7 days. To ensure the security of your account, please change your password as soon as possible.'
|
|
|
-// }
|
|
|
-// },
|
|
|
-// {
|
|
|
-// notificationType: 'password',
|
|
|
-// info: {
|
|
|
-// title: 'Password Notifications',
|
|
|
-// isExpiration: true,
|
|
|
-// tips: 'Password Expiration in 31111 Days',
|
|
|
-// content:
|
|
|
-// 'Your password will expire in 7 days. To ensure the security of your account, please change your password as soon as possible.'
|
|
|
-// }
|
|
|
-// },
|
|
|
-// {
|
|
|
-// notificationType: 'event',
|
|
|
-// info: {
|
|
|
-// type: 'milestone',
|
|
|
-// isMultiple: true,
|
|
|
-// numericRecords: 3,
|
|
|
-// isRead: true,
|
|
|
-// title: 'Milestone Update 1',
|
|
|
-// mode: 'Ocean Freight',
|
|
|
-// no: 'HBOL: SHJN2301234',
|
|
|
-// tag: 'Booking Confirmed',
|
|
|
-// location: 'Hong Kong',
|
|
|
-// time: 'Jan 10, 2025 14:30 UTC+8'
|
|
|
-// }
|
|
|
-// },
|
|
|
-// {
|
|
|
-// notificationType: 'event',
|
|
|
-// info: {
|
|
|
-// type: 'milestone',
|
|
|
-// isMultiple: true,
|
|
|
-// numericRecords: 3,
|
|
|
-// isRead: true,
|
|
|
-// title: 'Milestone Update 2',
|
|
|
-// mode: 'Ocean Freight',
|
|
|
-// no: 'HBOL: SHJN2301234',
|
|
|
-// tag: 'Booking Confirmed',
|
|
|
-// location: 'Hong Kong',
|
|
|
-// time: 'Jan 10, 2025 14:30 UTC+8'
|
|
|
-// }
|
|
|
-// },
|
|
|
-// {
|
|
|
-// notificationType: 'event',
|
|
|
-// info: {
|
|
|
-// type: 'milestone',
|
|
|
-// isMultiple: true,
|
|
|
-// numericRecords: 3,
|
|
|
-// isRead: true,
|
|
|
-// title: 'Milestone Update 3',
|
|
|
-// mode: 'Ocean Freight',
|
|
|
-// no: 'HBOL: SHJN2301234',
|
|
|
-// tag: 'Booking Confirmed',
|
|
|
-// location: 'Hong Kong',
|
|
|
-// time: 'Jan 10, 2025 14:30 UTC+8'
|
|
|
-// }
|
|
|
-// }
|
|
|
-// ]
|
|
|
|
|
|
const curCard = computed(() => {
|
|
|
return notificationList.value[curIndex.value] || null
|
|
|
@@ -121,20 +18,19 @@ let trainingIntervalId = null
|
|
|
let newMessageIntervalId = null
|
|
|
// 轮询最新未读消息
|
|
|
const pollingNewMessage = () => {
|
|
|
- if (newMessageIntervalId) return
|
|
|
// 每隔5分钟轮询一次
|
|
|
newMessageIntervalId = setInterval(() => {
|
|
|
getNotificationList(dayjs().format('MM/DD/YYYY HH:mm:ss'))
|
|
|
}, 300000)
|
|
|
}
|
|
|
+pollingNewMessage()
|
|
|
|
|
|
// 登录后自动轮播消息
|
|
|
const trainingCardAfterLogin = () => {
|
|
|
curIndex.value = curIndex.value + 1
|
|
|
- // 如果到达最后一个消息,设置为null以清除显示
|
|
|
+ // 如果消息展示完毕,清除定时器
|
|
|
if (curIndex.value >= notificationList.value.length) {
|
|
|
clearInterval(trainingIntervalId)
|
|
|
- pollingNewMessage()
|
|
|
}
|
|
|
}
|
|
|
|
|
|
@@ -172,6 +68,7 @@ onBeforeRouteUpdate((to, from, next) => {
|
|
|
if (to.name === 'Login') {
|
|
|
clearInterval(trainingIntervalId)
|
|
|
clearInterval(newMessageIntervalId)
|
|
|
+ newMessageIntervalId = null
|
|
|
}
|
|
|
next()
|
|
|
})
|
|
|
@@ -202,7 +99,6 @@ const closeMessage = () => {
|
|
|
if (!newMessageIntervalId) {
|
|
|
clearInterval(trainingIntervalId)
|
|
|
curIndex.value = -1
|
|
|
- pollingNewMessage()
|
|
|
return
|
|
|
}
|
|
|
|
|
|
@@ -216,7 +112,7 @@ const closeMessage = () => {
|
|
|
trainingIntervalId = setInterval(nextNotification, 2000)
|
|
|
}
|
|
|
// 将当前消息标记为已读
|
|
|
- notificationMsgStore.setReadCardMap(curCard.value?.info?.id)
|
|
|
+ // notificationMsgStore.setReadCardMap(curCard.value?.info?.id)
|
|
|
}
|
|
|
</script>
|
|
|
|
|
|
@@ -229,7 +125,11 @@ const closeMessage = () => {
|
|
|
>
|
|
|
<span class="font_family icon-icon_reject_b"></span>
|
|
|
</el-button>
|
|
|
- <NotificationMessageCard v-if="curCard" :data="[curCard]"></NotificationMessageCard>
|
|
|
+ <NotificationMessageCard
|
|
|
+ :isObserver="false"
|
|
|
+ v-if="curCard"
|
|
|
+ :data="[curCard]"
|
|
|
+ ></NotificationMessageCard>
|
|
|
</div>
|
|
|
</template>
|
|
|
|