feat: introduce message popup component

This commit is contained in:
Tim
2025-08-23 02:58:24 +08:00
parent a15d541b72
commit 2613fe6cf1
2 changed files with 92 additions and 0 deletions

View File

@@ -7,6 +7,7 @@
@close="closeMilkTeaPopup"
/>
<NotificationSettingPopup :visible="showNotificationPopup" @close="closeNotificationPopup" />
<MessagePopup :visible="showMessagePopup" @close="closeMessagePopup" />
<MedalPopup :visible="showMedalPopup" :medals="newMedals" @close="closeMedalPopup" />
<ActivityPopup
@@ -22,6 +23,7 @@
import ActivityPopup from '~/components/ActivityPopup.vue'
import MedalPopup from '~/components/MedalPopup.vue'
import NotificationSettingPopup from '~/components/NotificationSettingPopup.vue'
import MessagePopup from '~/components/MessagePopup.vue'
import { authState } from '~/utils/auth'
const config = useRuntimeConfig()
@@ -33,6 +35,7 @@ const milkTeaIcon = ref('')
const inviteCodeIcon = ref('')
const showNotificationPopup = ref(false)
const showMessagePopup = ref(false)
const showMedalPopup = ref(false)
const newMedals = ref([])
@@ -43,6 +46,9 @@ onMounted(async () => {
await checkInviteCodeActivity()
if (showInviteCodePopup.value) return
await checkMessageFeature()
if (showMessagePopup.value) return
await checkNotificationSetting()
if (showNotificationPopup.value) return
@@ -97,6 +103,18 @@ const closeMilkTeaPopup = () => {
showMilkTeaPopup.value = false
}
const checkMessageFeature = async () => {
if (!import.meta.client) return
if (!authState.loggedIn) return
if (localStorage.getItem('messageFeaturePopupShown')) return
showMessagePopup.value = true
}
const closeMessagePopup = () => {
if (!import.meta.client) return
localStorage.setItem('messageFeaturePopupShown', 'true')
showMessagePopup.value = false
}
const checkNotificationSetting = async () => {
if (!import.meta.client) return
if (!authState.loggedIn) return

View File

@@ -0,0 +1,74 @@
<template>
<BasePopup :visible="visible" @close="close">
<div class="message-popup">
<div class="message-popup-title">📨 站内信上线啦</div>
<div class="message-popup-text">现在可以在右上角使用站内信功能</div>
<div class="message-popup-actions">
<div class="message-popup-close" @click="close">知道了</div>
<div class="message-popup-button" @click="gotoMessage">去看看</div>
</div>
</div>
</BasePopup>
</template>
<script setup>
import BasePopup from '~/components/BasePopup.vue'
defineProps({
visible: { type: Boolean, default: false },
})
const emit = defineEmits(['close'])
const gotoMessage = () => {
emit('close')
navigateTo('/message-box', { replace: true })
}
const close = () => emit('close')
</script>
<style scoped>
.message-popup {
display: flex;
flex-direction: column;
align-items: center;
text-align: center;
gap: 10px;
min-width: 200px;
}
.message-popup-title {
font-size: 18px;
font-weight: bold;
margin-bottom: 10px;
}
.message-popup-actions {
margin-top: 10px;
display: flex;
flex-direction: row;
gap: 20px;
}
.message-popup-button {
background-color: var(--primary-color);
color: #fff;
padding: 8px 16px;
border-radius: 8px;
cursor: pointer;
}
.message-popup-button:hover {
background-color: var(--primary-color-hover);
}
.message-popup-close {
cursor: pointer;
color: var(--primary-color);
display: flex;
align-items: center;
}
.message-popup-close:hover {
text-decoration: underline;
}
</style>