feat: i18n lazy load
This commit is contained in:
parent
ccffe9daa8
commit
07209a7d29
6 changed files with 25 additions and 17 deletions
|
@ -1,15 +1,9 @@
|
|||
<script lang="ts" setup>
|
||||
import type { ComputedRef } from 'vue'
|
||||
import type { LocaleObject } from '#i18n'
|
||||
import { STORAGE_KEY_LANG } from '~/constants'
|
||||
|
||||
const { locale, t, setLocale } = useI18n()
|
||||
const { locales } = useI18n() as { locales: ComputedRef<LocaleObject[]> }
|
||||
useLocalStorage(STORAGE_KEY_LANG, locale)
|
||||
|
||||
const handleLocale = async (locale: string) => {
|
||||
await setLocale(locale)
|
||||
}
|
||||
</script>
|
||||
|
||||
<template>
|
||||
|
@ -24,7 +18,7 @@ const handleLocale = async (locale: string) => {
|
|||
v-for="item in locales"
|
||||
:key="item.code"
|
||||
:checked="item.code === locale"
|
||||
@click="handleLocale(item.code)"
|
||||
@click="setLocale(item.code)"
|
||||
>
|
||||
{{ item.name }}
|
||||
</CommonDropdownItem>
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue