HeaderTool.vue 1.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445
  1. <script setup lang="ts">
  2. import { useLocale, useTheme } from 'vuetify'
  3. import { availableLocales, loadLanguageAsync } from '~/modules/i18n'
  4. const { t, locale } = useI18n()
  5. const { current } = useLocale()
  6. const theme = useTheme()
  7. function toggleTheme() {
  8. toggleDark()
  9. theme.global.name.value = isDark.value ? 'light' : 'dark'
  10. }
  11. async function toggleLocales() {
  12. // change to some real logic
  13. const locales = availableLocales
  14. const newLocale = locales[(locales.indexOf(locale.value) + 1) % locales.length]
  15. await loadLanguageAsync(newLocale)
  16. locale.value = newLocale
  17. current.value = newLocale === 'zh-CN' ? 'zhHans' : newLocale
  18. }
  19. </script>
  20. <template>
  21. <nav flex="~ gap-4" justify-center text-xl>
  22. <!-- <RouterLink icon-btn to="/" :title="t('button.home')">
  23. <div i-carbon-campsite />
  24. </RouterLink> -->
  25. <button icon-btn :title="t('button.toggle_dark')" @click="toggleTheme">
  26. <div i="carbon-sun dark:carbon-moon" />
  27. </button>
  28. <a icon-btn :title="t('button.toggle_langs')" @click="toggleLocales()">
  29. <div i-carbon-language />
  30. </a>
  31. <!-- <RouterLink icon-btn to="/about" :title="t('button.about')" data-test-id="about">
  32. <div i-carbon-dicom-overlay />
  33. </RouterLink>
  34. <a icon-btn rel="noreferrer" href="https://github.com/antfu/vitesse" target="_blank" title="GitHub">
  35. <div i-carbon-logo-github />
  36. </a> -->
  37. </nav>
  38. </template>