refactor(front): simplify InputGroupField and KvInputGroupField components by removing unused state and streamlining item addition and update logic

This commit is contained in:
keven1024
2026-05-01 11:55:23 +08:00
parent b023876e0f
commit 1e446a0240
2 changed files with 21 additions and 68 deletions

View File

@@ -7,7 +7,6 @@ const props = defineProps<{
rules?: RuleExpression<string[]>
}>()
const { value, setValue, errorMessage } = useField<string[]>(props.name, props?.rules)
const addInput = ref('')
</script>
<template>
@@ -29,22 +28,9 @@ const addInput = ref('')
<LucideTrash class="size-4" />
</Button>
</div>
<div class="flex flex-row gap-2 items-center">
<Input v-model="addInput" :aria-invalid="!!errorMessage || undefined" v-bind="$attrs" />
<Button
size="icon"
@click="
() => {
const nextValue = addInput.trim()
if (!nextValue) {
return
}
setValue([...(value || []), nextValue])
addInput = ''
}
"
><LucidePlus class="size-4"
/></Button>
</div>
<Button class="self-start" size="sm" @click="() => setValue([...(value || []), ''])">
<LucidePlus class="size-4" />
添加
</Button>
</div>
</template>