Skip to content

Commit

Permalink
Get current component title from config
Browse files Browse the repository at this point in the history
  • Loading branch information
wkramer committed Dec 12, 2023
1 parent a209d8d commit c9c396f
Showing 1 changed file with 7 additions and 10 deletions.
17 changes: 7 additions & 10 deletions src/layouts/DefaultLayout.vue
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@
</template>

<script setup lang="ts">
import { ref, watch, onBeforeMount } from 'vue'
import { ref, watchEffect } from 'vue'
import { useRtl } from 'vuetify'
import { useConfigStore } from '../stores/config.ts'
import { Alert, useAlertsStore } from '../stores/alerts.ts'
Expand All @@ -89,17 +89,14 @@ const currentItem = ref('')
const { isRtl } = useRtl()
const route = useRoute()
onBeforeMount(async () => {
currentItem.value = route.name?.toString() ?? ''
watchEffect(async () => {
const component = configStore.activeComponents.find(
(c) => c.to.name === route.name,
)
const routeName = component ? component.title : route.name?.toString()
currentItem.value = routeName
})
watch(
() => route.name,
async (name) => {
currentItem.value = name?.toString() ?? ''
},
)
function onCloseAlert(alert: Alert) {
alert.active = false
}
Expand Down

0 comments on commit c9c396f

Please sign in to comment.