2021-08-30 02:36:57 -07:00
|
|
|
<template>
|
2022-05-26 02:45:38 -07:00
|
|
|
<section class="mt-4 mt-lg-0 d-print-none">
|
2021-08-30 02:36:57 -07:00
|
|
|
<div class="d-none d-md-inline-flex btn-group btn-block mb-2 w-100">
|
2022-01-19 05:22:40 -08:00
|
|
|
<router-link v-for="{name, icon, iconInverse, route, routesExtra, condition} in links" :key="name"
|
2021-08-30 02:36:57 -07:00
|
|
|
v-if="condition === undefined || condition === true"
|
|
|
|
:to="buildRoute(route)"
|
2022-01-19 05:22:40 -08:00
|
|
|
:class="['btn', isActiveRoute(route, routesExtra) ? 'btn-primary' : 'btn-outline-primary']">
|
2021-10-26 11:13:42 -07:00
|
|
|
<Icon :v="icon" :inverse="iconInverse === undefined ? false : (iconInverse || isActiveRoute(route))"/>
|
2021-08-30 02:36:57 -07:00
|
|
|
<T>{{name}}</T>
|
|
|
|
</router-link>
|
|
|
|
</div>
|
|
|
|
<div class="d-block d-md-none btn-group-vertical btn-block mb-2 w-100">
|
2022-01-19 05:22:40 -08:00
|
|
|
<router-link v-for="{name, icon, iconInverse, route, routesExtra, condition} in links" :key="name"
|
2021-09-14 11:42:15 -07:00
|
|
|
v-if="condition === undefined || condition === true"
|
2021-08-30 02:36:57 -07:00
|
|
|
:to="buildRoute(route)"
|
2022-01-19 05:22:40 -08:00
|
|
|
:class="['btn', isActiveRoute(route, routesExtra) ? 'btn-primary' : 'btn-outline-primary']">
|
2021-10-26 11:13:42 -07:00
|
|
|
<Icon :v="icon" :inverse="iconInverse === undefined ? false : (iconInverse || isActiveRoute(route))"/>
|
2021-08-30 02:36:57 -07:00
|
|
|
<T>{{name}}</T>
|
|
|
|
</router-link>
|
|
|
|
</div>
|
|
|
|
</section>
|
|
|
|
</template>
|
|
|
|
|
|
|
|
<script>
|
|
|
|
export default {
|
|
|
|
props: {
|
|
|
|
prefix: {'default': ''},
|
|
|
|
links: {required: true},
|
|
|
|
},
|
|
|
|
methods: {
|
|
|
|
buildRoute(route) {
|
|
|
|
return `${this.prefix}/${route}`;
|
|
|
|
},
|
2022-01-19 05:22:40 -08:00
|
|
|
isActiveRoute(route, routesExtra) {
|
|
|
|
if (routesExtra && this.$route.name && routesExtra.includes(this.$route.name.split(':')[0])) {
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
2021-08-30 02:36:57 -07:00
|
|
|
let current = decodeURIComponent(this.$route.fullPath).replace(/\/$/, '');
|
|
|
|
if (current.includes('#')) {
|
|
|
|
current = current.substring(0, current.indexOf('#'));
|
|
|
|
}
|
2021-10-03 07:37:00 -07:00
|
|
|
const expected = this.buildRoute(route).replace(/\/$/, '');
|
2022-01-19 05:22:40 -08:00
|
|
|
|
2021-10-03 07:37:00 -07:00
|
|
|
return current === expected || current.startsWith(expected + '/');
|
2021-08-30 02:36:57 -07:00
|
|
|
},
|
|
|
|
},
|
|
|
|
}
|
|
|
|
</script>
|