index.vue 919 B

123456789101112131415161718192021222324252627282930
  1. <script lang="ts" setup>
  2. import { useSettingsStore } from '@/store/modules/settings'
  3. import getPageTitle from '@/utils/pageTitle'
  4. import { VabRoute } from '/#/router'
  5. const { locale } = useI18n()
  6. const route: VabRoute = useRoute()
  7. const settingsStore = useSettingsStore()
  8. const { theme } = storeToRefs(settingsStore)
  9. const { changeLanguage } = settingsStore
  10. const handleCommand = (language: string) => {
  11. changeLanguage(language)
  12. locale.value = language
  13. document.title = getPageTitle(route.meta.title)
  14. }
  15. </script>
  16. <template>
  17. <el-dropdown v-if="theme.showLanguage" @command="handleCommand">
  18. <vab-icon icon="translate" />
  19. <template #dropdown>
  20. <el-dropdown-menu>
  21. <el-dropdown-item command="zh">中文简体</el-dropdown-item>
  22. <el-dropdown-item command="en">English</el-dropdown-item>
  23. </el-dropdown-menu>
  24. </template>
  25. </el-dropdown>
  26. </template>