Selaa lähdekoodia

add components

Benjamin Kornblum 8 kuukautta sitten
vanhempi
sitoutus
47c28df62d
2 muutettua tiedostoa jossa 18 lisäystä ja 5 poistoa
  1. 5 2
      src/components/Navigation.vue
  2. 13 3
      src/main.ts

+ 5 - 2
src/components/Navigation.vue

@@ -114,9 +114,12 @@ nav a:first-of-type {
             const oldLink = this.footerLinksStroe.getLinkByLabel(this.route.name)
             this.links = await this.footerLinksStroe.getLinks(locale)
             const newLink = this.footerLinksStroe.getLinkByLabel(oldLink.localizations[0].Label)
+            if(newLink){
+              setTimeout(() => {this.$router.push(newLink.page.path)}, 100)
+            }else{
+              setTimeout(() => {this.$router.push("/")}, 100)
+            }
 
-
-            setTimeout(() => {this.$router.push(newLink.page.path)}, 100)
           }
         }
 

+ 13 - 3
src/main.ts

@@ -10,14 +10,24 @@ import VueCountdown from '@chenfengyuan/vue-countdown';
 import { useFooterLinksStore } from '@/stores/footer-content-pages'
 import { useTimelineStore } from '@/stores/timeline'
 
+
+
+
 const pinia = createPinia()
 const app = createApp(App)
 
 app.use(pinia)
    .use(i18n)
-await useFooterLinksStore().setLocale(localStorage.getItem('lang') || 'de')
-await useTimelineStore().setLocale(localStorage.getItem('lang') || 'de')
-await loadDynamicPages(localStorage.getItem('lang') || 'de')
+   const urlParams = new URLSearchParams(window.location.search);
+   let lang = localStorage.getItem('lang') || 'de'
+   if(urlParams.has('lang') && urlParams.get('lang') != lang){
+     lang = urlParams.get('lang')!
+     i18n.global.locale = lang
+     await setTimeout(()=>{localStorage.setItem('lang', lang!)}, 1000)
+   }
+await useFooterLinksStore().setLocale(lang)
+await useTimelineStore().setLocale(lang)
+await loadDynamicPages(lang)
 app.use(router)
 app.component(VueCountdown.name!, VueCountdown)