add cohorts and back to home in default template

This commit is contained in:
lesion
2022-06-01 14:09:22 +02:00
parent fb4279a108
commit 0d6ee8dc4f
4 changed files with 23 additions and 29 deletions

View File

@@ -4,9 +4,12 @@
<Confirm/>
<Nav/>
<v-main app>
<div class="ml-1 mb-1 mt-1" v-if='showCohorts || showBack'>
<v-btn v-show='showBack' text color='primary' to='/'><v-icon v-text='mdiChevronLeft'/></v-btn>
<v-btn v-for='cohort in cohorts' text color='primary' :key='cohort.id' :to='`/g/${cohort.name}`'>{{cohort.name}}</v-btn>
</div>
<v-fade-transition hide-on-leave>
<nuxt keep-alive :keep-alive-props="{ max: 10, include: ['Index'] }"/>
<!-- <nuxt /> -->
<nuxt />
</v-fade-transition>
</v-main>
<Footer/>
@@ -21,6 +24,7 @@ import Snackbar from '../components/Snackbar'
import Footer from '../components/Footer'
import Confirm from '../components/Confirm'
import { mapState } from 'vuex'
import { mdiChevronLeft } from '@mdi/js'
export default {
head () {
@@ -30,9 +34,24 @@ export default {
}
}
},
data () {
return { cohorts: [], mdiChevronLeft }
},
async fetch () {
this.cohorts = await this.$axios.$get('cohorts')
},
name: 'Default',
components: { Nav, Snackbar, Footer, Confirm },
computed: mapState(['settings', 'locale']),
computed: {
...mapState(['settings', 'locale']),
showBack () {
return ['tag-tag', 'g-cohort', 'p-place', 'search', 'announcement-id'].includes(this.$route.name)
},
showCohorts () {
if (!this.cohorts || this.cohorts.length === 0) return false
return ['tag-tag', 'index', 'g-cohort', 'p-place'].includes(this.$route.name)
}
},
created () {
this.$vuetify.theme.dark = this.settings['theme.is_dark']
}