feat: add InputGroup and verify shared field integration
This commit is contained in:
@@ -0,0 +1,99 @@
|
||||
<script setup lang="ts">
|
||||
import { onBeforeUnmount, ref } from "vue";
|
||||
import {
|
||||
Button,
|
||||
InputGroup,
|
||||
InputGroupPrefix,
|
||||
InputGroupSuffix,
|
||||
InputGroupTextArea,
|
||||
Spinner,
|
||||
TextField,
|
||||
} from "@heroui-vue/components";
|
||||
import {
|
||||
IconArrowUp,
|
||||
IconAt,
|
||||
IconMicrophone,
|
||||
IconPlugConnected,
|
||||
IconPlus,
|
||||
} from "@tabler/icons-vue";
|
||||
|
||||
const value = ref("");
|
||||
const isSubmitting = ref(false);
|
||||
let submitTimer: ReturnType<typeof setTimeout> | undefined;
|
||||
onBeforeUnmount(() => clearTimeout(submitTimer));
|
||||
|
||||
function handleSubmit() {
|
||||
if (!value.value.trim() || isSubmitting.value) return;
|
||||
isSubmitting.value = true;
|
||||
submitTimer = setTimeout(() => {
|
||||
isSubmitting.value = false;
|
||||
value.value = "";
|
||||
}, 1000);
|
||||
}
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<TextField
|
||||
aria-label="提示输入"
|
||||
class="flex w-sm flex-col sm:w-lg"
|
||||
full-width
|
||||
name="prompt"
|
||||
>
|
||||
<InputGroup class="flex flex-col gap-2 rounded-3xl py-2" full-width>
|
||||
<InputGroupPrefix class="px-3 py-0">
|
||||
<Button aria-label="添加上下文" size="sm" variant="outline">
|
||||
<IconAt aria-hidden="true" />
|
||||
添加上下文
|
||||
</Button>
|
||||
</InputGroupPrefix>
|
||||
<InputGroupTextArea
|
||||
v-model="value"
|
||||
class="w-full resize-none px-3.5 py-0"
|
||||
placeholder="分配任务或提问…"
|
||||
:rows="5"
|
||||
/>
|
||||
<InputGroupSuffix class="flex w-full items-center gap-1.5 px-3 py-0">
|
||||
<Button
|
||||
is-icon-only
|
||||
aria-label="附加文件"
|
||||
size="sm"
|
||||
title="添加文件等"
|
||||
variant="tertiary"
|
||||
>
|
||||
<IconPlus aria-hidden="true" />
|
||||
</Button>
|
||||
<Button
|
||||
is-icon-only
|
||||
aria-label="连接应用"
|
||||
size="sm"
|
||||
title="连接应用"
|
||||
variant="tertiary"
|
||||
>
|
||||
<IconPlugConnected aria-hidden="true" />
|
||||
</Button>
|
||||
<div class="ms-auto flex items-center gap-1.5">
|
||||
<Button
|
||||
is-icon-only
|
||||
aria-label="语音输入"
|
||||
size="sm"
|
||||
title="语音输入"
|
||||
variant="ghost"
|
||||
>
|
||||
<IconMicrophone aria-hidden="true" />
|
||||
</Button>
|
||||
<Button
|
||||
is-icon-only
|
||||
aria-label="发送提示"
|
||||
:is-disabled="!value.trim()"
|
||||
:is-pending="isSubmitting"
|
||||
title="发送"
|
||||
@click="handleSubmit"
|
||||
>
|
||||
<Spinner v-if="isSubmitting" color="current" size="sm" />
|
||||
<IconArrowUp v-else aria-hidden="true" />
|
||||
</Button>
|
||||
</div>
|
||||
</InputGroupSuffix>
|
||||
</InputGroup>
|
||||
</TextField>
|
||||
</template>
|
||||
Reference in New Issue
Block a user