From ac7462ec67aa2a1775999bd7399c4281303b35ae Mon Sep 17 00:00:00 2001 From: carlossa Date: Fri, 4 Aug 2023 06:18:47 +0200 Subject: [PATCH] refs #5989 comment --- src/components/NavBar.vue | 35 ++++++++++++++++++++++++----------- 1 file changed, 24 insertions(+), 11 deletions(-) diff --git a/src/components/NavBar.vue b/src/components/NavBar.vue index 561197a18..4c543cb1b 100644 --- a/src/components/NavBar.vue +++ b/src/components/NavBar.vue @@ -7,6 +7,7 @@ import { useState } from 'src/composables/useState'; import { useStateStore } from 'stores/useStateStore'; import PinnedModules from './PinnedModules.vue'; import { getUrl } from 'src/composables/getUrl'; +import { useRoute } from 'vue-router'; const { t } = useI18n(); const session = useSession(); @@ -14,21 +15,28 @@ const stateStore = useStateStore(); const state = useState(); const user = state.getUser(); const token = session.getToken(); +const route = useRoute(); -onMounted(() => stateStore.setMounted()); +onMounted(() => stateStore. setMounted()); -function redirect() { +async function redirect() { const currentURL = window.location.href; - const routeRegex = /\/#\/(\w+)(?:\/(\d+))?/; - + const routeRegex = /\/(\w+)(?:\/(\d+))?/; const match = currentURL.match(routeRegex); - if (match) { - const [, element, number] = match; - const redirectURL = - getUrl() + (number ? `${element}/${number}/summary` : `${element}/index`); - window.location.href = redirectURL; + const [, element, number] = match; + console.log(route.path); + const section = route.path.substring(route.path.indexOf('/')); + console.log(section); + if (route?.params?.id) { + // const redirectURL = + // getUrl() + (number ? `${element}/${number}/summary` : `${element}/index`); + // window.location.href = redirectURL; + console.log(await getUrl(section)); + window.location.href = await getUrl(section + route.params); } else { - window.location.href = getUrl(); + console.log(await getUrl(section)); + + // window.location.href = await getUrl('claim'); } } @@ -80,7 +88,12 @@ function redirect() { {{ t('globals.pinnedModules') }} - + + +