mirror of
https://github.com/nagisa77/OpenIsle.git
synced 2026-04-21 11:27:27 +08:00
feat: allow navigating to notification settings
This commit is contained in:
@@ -6,6 +6,7 @@
|
|||||||
text="建站送奶茶活动火热进行中,快来参与吧!"
|
text="建站送奶茶活动火热进行中,快来参与吧!"
|
||||||
@close="closeMilkTeaPopup"
|
@close="closeMilkTeaPopup"
|
||||||
/>
|
/>
|
||||||
|
<NotificationSettingPopup :visible="showNotificationPopup" @close="closeNotificationPopup" />
|
||||||
<MedalPopup :visible="showMedalPopup" :medals="newMedals" @close="closeMedalPopup" />
|
<MedalPopup :visible="showMedalPopup" :medals="newMedals" @close="closeMedalPopup" />
|
||||||
</div>
|
</div>
|
||||||
</template>
|
</template>
|
||||||
@@ -13,16 +14,18 @@
|
|||||||
<script>
|
<script>
|
||||||
import ActivityPopup from '~/components/ActivityPopup.vue'
|
import ActivityPopup from '~/components/ActivityPopup.vue'
|
||||||
import MedalPopup from '~/components/MedalPopup.vue'
|
import MedalPopup from '~/components/MedalPopup.vue'
|
||||||
|
import NotificationSettingPopup from '~/components/NotificationSettingPopup.vue'
|
||||||
import { API_BASE_URL } from '~/main'
|
import { API_BASE_URL } from '~/main'
|
||||||
import { authState } from '~/utils/auth'
|
import { authState } from '~/utils/auth'
|
||||||
|
|
||||||
export default {
|
export default {
|
||||||
name: 'GlobalPopups',
|
name: 'GlobalPopups',
|
||||||
components: { ActivityPopup, MedalPopup },
|
components: { ActivityPopup, MedalPopup, NotificationSettingPopup },
|
||||||
data() {
|
data() {
|
||||||
return {
|
return {
|
||||||
showMilkTeaPopup: false,
|
showMilkTeaPopup: false,
|
||||||
milkTeaIcon: '',
|
milkTeaIcon: '',
|
||||||
|
showNotificationPopup: false,
|
||||||
showMedalPopup: false,
|
showMedalPopup: false,
|
||||||
newMedals: [],
|
newMedals: [],
|
||||||
}
|
}
|
||||||
@@ -30,7 +33,10 @@ export default {
|
|||||||
async mounted() {
|
async mounted() {
|
||||||
await this.checkMilkTeaActivity()
|
await this.checkMilkTeaActivity()
|
||||||
if (!this.showMilkTeaPopup) {
|
if (!this.showMilkTeaPopup) {
|
||||||
await this.checkNewMedals()
|
await this.checkNotificationSetting()
|
||||||
|
if (!this.showNotificationPopup) {
|
||||||
|
await this.checkNewMedals()
|
||||||
|
}
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
methods: {
|
methods: {
|
||||||
@@ -55,6 +61,18 @@ export default {
|
|||||||
if (!process.client) return
|
if (!process.client) return
|
||||||
localStorage.setItem('milkTeaActivityPopupShown', 'true')
|
localStorage.setItem('milkTeaActivityPopupShown', 'true')
|
||||||
this.showMilkTeaPopup = false
|
this.showMilkTeaPopup = false
|
||||||
|
this.checkNotificationSetting()
|
||||||
|
},
|
||||||
|
async checkNotificationSetting() {
|
||||||
|
if (!process.client) return
|
||||||
|
if (!authState.loggedIn) return
|
||||||
|
if (localStorage.getItem('notificationSettingPopupShown')) return
|
||||||
|
this.showNotificationPopup = true
|
||||||
|
},
|
||||||
|
closeNotificationPopup() {
|
||||||
|
if (!process.client) return
|
||||||
|
localStorage.setItem('notificationSettingPopupShown', 'true')
|
||||||
|
this.showNotificationPopup = false
|
||||||
this.checkNewMedals()
|
this.checkNewMedals()
|
||||||
},
|
},
|
||||||
async checkNewMedals() {
|
async checkNewMedals() {
|
||||||
|
|||||||
81
frontend_nuxt/components/NotificationSettingPopup.vue
Normal file
81
frontend_nuxt/components/NotificationSettingPopup.vue
Normal file
@@ -0,0 +1,81 @@
|
|||||||
|
<template>
|
||||||
|
<BasePopup :visible="visible" @close="close">
|
||||||
|
<div class="notification-popup">
|
||||||
|
<div class="notification-popup-title">通知设置上线啦</div>
|
||||||
|
<div class="notification-popup-text">现在可以调整通知类型</div>
|
||||||
|
<div class="notification-popup-actions">
|
||||||
|
<div class="notification-popup-close" @click="close">知道了</div>
|
||||||
|
<div class="notification-popup-button" @click="gotoSetting">去看看</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</BasePopup>
|
||||||
|
</template>
|
||||||
|
|
||||||
|
<script>
|
||||||
|
import BasePopup from '~/components/BasePopup.vue'
|
||||||
|
import { useRouter } from 'vue-router'
|
||||||
|
|
||||||
|
export default {
|
||||||
|
name: 'NotificationSettingPopup',
|
||||||
|
components: { BasePopup },
|
||||||
|
props: {
|
||||||
|
visible: { type: Boolean, default: false },
|
||||||
|
},
|
||||||
|
emits: ['close'],
|
||||||
|
setup(props, { emit }) {
|
||||||
|
const router = useRouter()
|
||||||
|
const gotoSetting = () => {
|
||||||
|
emit('close')
|
||||||
|
router.push('/message?tab=control')
|
||||||
|
}
|
||||||
|
const close = () => emit('close')
|
||||||
|
return { gotoSetting, close }
|
||||||
|
},
|
||||||
|
}
|
||||||
|
</script>
|
||||||
|
|
||||||
|
<style scoped>
|
||||||
|
.notification-popup {
|
||||||
|
display: flex;
|
||||||
|
flex-direction: column;
|
||||||
|
align-items: center;
|
||||||
|
text-align: center;
|
||||||
|
gap: 10px;
|
||||||
|
min-width: 200px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.notification-popup-title {
|
||||||
|
font-size: 18px;
|
||||||
|
font-weight: bold;
|
||||||
|
}
|
||||||
|
|
||||||
|
.notification-popup-actions {
|
||||||
|
margin-top: 10px;
|
||||||
|
display: flex;
|
||||||
|
flex-direction: row;
|
||||||
|
gap: 20px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.notification-popup-button {
|
||||||
|
background-color: var(--primary-color);
|
||||||
|
color: #fff;
|
||||||
|
padding: 8px 16px;
|
||||||
|
border-radius: 8px;
|
||||||
|
cursor: pointer;
|
||||||
|
}
|
||||||
|
|
||||||
|
.notification-popup-button:hover {
|
||||||
|
background-color: var(--primary-color-hover);
|
||||||
|
}
|
||||||
|
|
||||||
|
.notification-popup-close {
|
||||||
|
cursor: pointer;
|
||||||
|
color: var(--primary-color);
|
||||||
|
display: flex;
|
||||||
|
align-items: center;
|
||||||
|
}
|
||||||
|
|
||||||
|
.notification-popup-close:hover {
|
||||||
|
text-decoration: underline;
|
||||||
|
}
|
||||||
|
</style>
|
||||||
@@ -480,7 +480,7 @@
|
|||||||
|
|
||||||
<script>
|
<script>
|
||||||
import { ref, onMounted, computed } from 'vue'
|
import { ref, onMounted, computed } from 'vue'
|
||||||
import { useRouter } from 'vue-router'
|
import { useRouter, useRoute } from 'vue-router'
|
||||||
import { API_BASE_URL } from '../main'
|
import { API_BASE_URL } from '../main'
|
||||||
import BaseTimeline from '../components/BaseTimeline.vue'
|
import BaseTimeline from '../components/BaseTimeline.vue'
|
||||||
import BasePlaceholder from '../components/BasePlaceholder.vue'
|
import BasePlaceholder from '../components/BasePlaceholder.vue'
|
||||||
@@ -503,9 +503,12 @@ export default {
|
|||||||
components: { BaseTimeline, BasePlaceholder, NotificationContainer },
|
components: { BaseTimeline, BasePlaceholder, NotificationContainer },
|
||||||
setup() {
|
setup() {
|
||||||
const router = useRouter()
|
const router = useRouter()
|
||||||
|
const route = useRoute()
|
||||||
const notifications = ref([])
|
const notifications = ref([])
|
||||||
const isLoadingMessage = ref(false)
|
const isLoadingMessage = ref(false)
|
||||||
const selectedTab = ref('unread')
|
const selectedTab = ref(
|
||||||
|
['all', 'unread', 'control'].includes(route.query.tab) ? route.query.tab : 'unread',
|
||||||
|
)
|
||||||
const notificationPrefs = ref([])
|
const notificationPrefs = ref([])
|
||||||
const filteredNotifications = computed(() =>
|
const filteredNotifications = computed(() =>
|
||||||
selectedTab.value === 'all'
|
selectedTab.value === 'all'
|
||||||
|
|||||||
Reference in New Issue
Block a user