index.vue 765 B

1234567891011121314151617181920212223242526272829303132
  1. <template>
  2. <n-dropdown
  3. trigger="hover"
  4. @select="handleSelect"
  5. :show-arrow="true"
  6. :options="options"
  7. >
  8. <n-button quaternary>
  9. <n-icon size="20" :depth="1">
  10. <language-icon></language-icon>
  11. </n-icon>
  12. </n-button>
  13. </n-dropdown>
  14. </template>
  15. <script lang="ts" setup>
  16. import { useI18n } from "vue-i18n";
  17. import { useLangStore } from '@/store/modules/langStore/langStore'
  18. import { langList } from '@/i18n/index'
  19. import { LangEnum } from '@/enums/styleEnum'
  20. import { icon } from '@/plugins'
  21. const { LanguageIcon } = icon.ionicons5
  22. const { locale } = useI18n();
  23. const langStore = useLangStore()
  24. const options = langList
  25. const handleSelect = (key: LangEnum) => {
  26. locale.value = key;
  27. langStore.changeLang(key)
  28. }
  29. </script>