Navigation.vue 2.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091
  1. <template>
  2. <nav>
  3. <RouterLink to="/">{{ t("Home") }}</RouterLink>
  4. <RouterLink v-for="link in links" v-model="links" :to="`${link.page.path}`">
  5. {{ link.Label }}
  6. </RouterLink>
  7. <select @change="changeLocale()" v-model="$i18n.locale">
  8. <option v-for="(lang, i) in $i18n.availableLocales" :key="`Lang${i}`" :value="lang">
  9. {{ lang }}
  10. </option>
  11. </select>
  12. </nav>
  13. </template>
  14. <style scoped>
  15. nav {
  16. width: 100%;
  17. font-size: 12px;
  18. text-align: center;
  19. line-height: 90px;
  20. margin: 0;
  21. padding: 0;
  22. }
  23. nav a.router-link-exact-active {
  24. color: var(--color-text);
  25. }
  26. nav a.router-link-exact-active:hover {
  27. background-color: transparent;
  28. }
  29. nav a, nav select {
  30. display: inline-block;
  31. padding: 0 1rem;
  32. border-left: 1px solid var(--color-border);
  33. }
  34. nav a:first-of-type {
  35. border: 0;
  36. }
  37. </style>
  38. <script lang="ts">
  39. import { useFooterLinksStore } from '@/stores/footer-content-pages'
  40. import {loadDynamicPages} from '@/router'
  41. import { useI18n } from 'vue-i18n'
  42. export default {
  43. name: 'Navigation',
  44. data () {
  45. return {
  46. links: [] as Array<any>,
  47. error: null as any,
  48. footerLinksStroe: null as any
  49. }
  50. },
  51. setup(){
  52. const { t } = useI18n({
  53. inheritLocale: true
  54. })
  55. return{
  56. t
  57. }
  58. },
  59. async mounted () {
  60. if(!this.footerLinksStroe){
  61. this.footerLinksStroe = useFooterLinksStore()
  62. }
  63. this.links = await this.footerLinksStroe.getLinks(this.$i18n.locale)
  64. },
  65. methods:{
  66. async changeLocale(){
  67. let locale = this.$i18n.locale
  68. loadDynamicPages(locale)
  69. localStorage.setItem('lang',locale)
  70. if(!this.footerLinksStroe){
  71. this.footerLinksStroe = useFooterLinksStore()
  72. }
  73. this.links = await this.footerLinksStroe.getLinks(locale)
  74. }
  75. }
  76. }
  77. </script>