mirror of
https://github.com/nagisa77/OpenIsle.git
synced 2026-05-08 19:57:30 +08:00
Merge branch 'main' of github.com:nagisa77/OpenIsle
This commit is contained in:
@@ -17,29 +17,21 @@
|
|||||||
<router-view />
|
<router-view />
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<ActivityPopup
|
<GlobalPopups />
|
||||||
:visible="showMilkTeaPopup"
|
|
||||||
:icon="milkTeaIcon"
|
|
||||||
text="建站送奶茶活动火热进行中,快来参与吧!"
|
|
||||||
@close="closeMilkTeaPopup"
|
|
||||||
/>
|
|
||||||
</div>
|
</div>
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
<script>
|
<script>
|
||||||
import HeaderComponent from './components/HeaderComponent.vue'
|
import HeaderComponent from './components/HeaderComponent.vue'
|
||||||
import MenuComponent from './components/MenuComponent.vue'
|
import MenuComponent from './components/MenuComponent.vue'
|
||||||
import ActivityPopup from './components/ActivityPopup.vue'
|
import GlobalPopups from './components/GlobalPopups.vue'
|
||||||
import { API_BASE_URL } from './main'
|
|
||||||
|
|
||||||
export default {
|
export default {
|
||||||
name: 'App',
|
name: 'App',
|
||||||
components: { HeaderComponent, MenuComponent, ActivityPopup },
|
components: { HeaderComponent, MenuComponent, GlobalPopups },
|
||||||
data() {
|
data() {
|
||||||
return {
|
return {
|
||||||
menuVisible: window.innerWidth > 768,
|
menuVisible: window.innerWidth > 768
|
||||||
showMilkTeaPopup: false,
|
|
||||||
milkTeaIcon: ''
|
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
computed: {
|
computed: {
|
||||||
@@ -48,30 +40,9 @@ export default {
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
async mounted() {
|
async mounted() {
|
||||||
await this.checkMilkTeaActivity()
|
// placeholder for future global initializations
|
||||||
},
|
},
|
||||||
methods: {
|
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>
|
</script>
|
||||||
|
|
||||||
|
|||||||
51
open-isle-cli/src/components/GlobalPopups.vue
Normal file
51
open-isle-cli/src/components/GlobalPopups.vue
Normal file
@@ -0,0 +1,51 @@
|
|||||||
|
<template>
|
||||||
|
<div>
|
||||||
|
<ActivityPopup
|
||||||
|
:visible="showMilkTeaPopup"
|
||||||
|
:icon="milkTeaIcon"
|
||||||
|
text="建站送奶茶活动火热进行中,快来参与吧!"
|
||||||
|
@close="closeMilkTeaPopup"
|
||||||
|
/>
|
||||||
|
</div>
|
||||||
|
</template>
|
||||||
|
|
||||||
|
<script>
|
||||||
|
import ActivityPopup from './ActivityPopup.vue'
|
||||||
|
import { API_BASE_URL } from '../main'
|
||||||
|
|
||||||
|
export default {
|
||||||
|
name: 'GlobalPopups',
|
||||||
|
components: { ActivityPopup },
|
||||||
|
data () {
|
||||||
|
return {
|
||||||
|
showMilkTeaPopup: false,
|
||||||
|
milkTeaIcon: ''
|
||||||
|
}
|
||||||
|
},
|
||||||
|
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