mirror of
https://github.com/nagisa77/OpenIsle.git
synced 2026-03-05 03:20:45 +08:00
feat: add activity popup for milk tea
This commit is contained in:
@@ -14,23 +14,60 @@
|
||||
<router-view />
|
||||
</div>
|
||||
</div>
|
||||
<ActivityPopup
|
||||
:visible="showMilkTeaPopup"
|
||||
:icon="milkTeaIcon"
|
||||
text="建站送奶茶活动火热进行中,快来参与吧!"
|
||||
@close="closeMilkTeaPopup"
|
||||
/>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<script>
|
||||
import HeaderComponent from './components/HeaderComponent.vue'
|
||||
import MenuComponent from './components/MenuComponent.vue'
|
||||
import ActivityPopup from './components/ActivityPopup.vue'
|
||||
import { API_BASE_URL } from './main'
|
||||
|
||||
export default {
|
||||
name: 'App',
|
||||
components: { HeaderComponent, MenuComponent },
|
||||
components: { HeaderComponent, MenuComponent, ActivityPopup },
|
||||
data() {
|
||||
return { menuVisible: window.innerWidth > 768 }
|
||||
return {
|
||||
menuVisible: window.innerWidth > 768,
|
||||
showMilkTeaPopup: false,
|
||||
milkTeaIcon: ''
|
||||
}
|
||||
},
|
||||
computed: {
|
||||
hideMenu() {
|
||||
return ['/login', '/signup', '/404', '/signup-reason', '/github-callback', '/twitter-callback', '/discord-callback', '/forgot-password'].includes(this.$route.path)
|
||||
}
|
||||
},
|
||||
async mounted() {
|
||||
await this.checkMilkTeaActivity()
|
||||
},
|
||||
methods: {
|
||||
async checkMilkTeaActivity() {
|
||||
if (localStorage.getItem('milkTeaActivityPopupShown')) return
|
||||
try {
|
||||
const res = await fetch(`${API_BASE_URL}/api/activities`)
|
||||
if (res.ok) {
|
||||
const list = await res.json()
|
||||
const a = list.find(i => i.type === 'MILK_TEA' && !i.ended)
|
||||
if (a) {
|
||||
this.milkTeaIcon = a.icon
|
||||
this.showMilkTeaPopup = true
|
||||
}
|
||||
}
|
||||
} catch (e) {
|
||||
// ignore network errors
|
||||
}
|
||||
},
|
||||
closeMilkTeaPopup() {
|
||||
localStorage.setItem('milkTeaActivityPopupShown', 'true')
|
||||
this.showMilkTeaPopup = false
|
||||
}
|
||||
}
|
||||
}
|
||||
</script>
|
||||
|
||||
Reference in New Issue
Block a user