refactor: replace defineModels with defineModel

This commit is contained in:
三咲智子 Kevin Deng 2023-08-01 17:43:55 +08:00
parent e6172ad38b
commit d23f1d39eb
No known key found for this signature in database
GPG key ID: 69992F2250DFD93E
17 changed files with 35 additions and 56 deletions

View file

@ -1,9 +1,7 @@
<script setup lang="ts">
import Fuse from 'fuse.js'
let { modelValue } = $defineModels<{
modelValue: string
}>()
const modelValue = defineModel<string>({ required: true })
const { t } = useI18n()
const userSettings = useUserSettings()
@ -24,7 +22,7 @@ const languages = $computed(() =>
if (a === 'en')
return -1
return a === modelValue ? -1 : b === modelValue ? 1 : a.localeCompare(b)
return a === modelValue.value ? -1 : b === modelValue.value ? 1 : a.localeCompare(b)
}),
)
@ -41,7 +39,7 @@ const preferredLanguages = computed(() => {
)
function chooseLanguage(language: string) {
modelValue = language
modelValue.value = language
}
</script>

View file

@ -3,16 +3,16 @@ const { editing } = defineProps<{
editing?: boolean
}>()
let { modelValue } = $defineModels<{
modelValue: string
}>()
const modelValue = defineModel<string>({
required: true,
})
const currentVisibility = $computed(() =>
statusVisibilities.find(v => v.value === modelValue) || statusVisibilities[0],
statusVisibilities.find(v => v.value === modelValue.value) || statusVisibilities[0],
)
function chooseVisibility(visibility: string) {
modelValue = visibility
modelValue.value = visibility
}
</script>