refactor: use Nuxt 4 directory structure

This commit is contained in:
AnotiaWang
2025-02-28 16:16:02 +08:00
parent 7a87ed5def
commit c45d75fad2
31 changed files with 33 additions and 28 deletions

View File

@ -0,0 +1,37 @@
<script setup lang="ts">
const { locale: globalLocale, availableLocales, t, setLocale } = useI18n()
export type Locale = (typeof globalLocale)['value']
export type AvailableLocales = Locale[]
const props = defineProps<{
/** Override display locale */
value?: Locale
/** If true, it will not change global locales */
private?: boolean
}>()
const emit = defineEmits<{
(e: 'update', value: Locale): void
}>()
const localeOptions = availableLocales.map((locale) => ({
value: locale,
label: t('language', {}, { locale }),
}))
function changeLocale(l: Locale) {
emit('update', l)
if (props.private) return
setLocale(l)
}
</script>
<template>
<USelect
icon="i-lucide-languages"
:model-value="value ?? globalLocale"
:items="localeOptions"
@update:model-value="changeLocale($event)"
/>
</template>