feat: add Input component and integrate it into chatbot; enhance chatbot layout with new message input

This commit is contained in:
吳元皓 2025-05-13 22:38:15 +08:00
parent 5803207451
commit 784b45451e
3 changed files with 39 additions and 3 deletions

View File

@ -1,5 +1,6 @@
<script setup lang="ts"> <script setup lang="ts">
import { History, Plus } from "lucide-vue-next"; import { History, Plus, Send } from "lucide-vue-next";
import { Input } from "~/components/ui/input"
const { t } = useI18n(); const { t } = useI18n();
const cookie = useCookie("lastChatId"); const cookie = useCookie("lastChatId");
const lastChatId = cookie.value; const lastChatId = cookie.value;
@ -10,6 +11,7 @@ onMounted(() => {
}); });
</script> </script>
<template> <template>
<div class="flex flex-col h-full">
<div class="justify-center align-center text-center flex flex-col"> <div class="justify-center align-center text-center flex flex-col">
<div class="flex flex-row justify-between"> <div class="flex flex-row justify-between">
<div>Chat Name</div> <div>Chat Name</div>
@ -17,15 +19,24 @@ onMounted(() => {
<div <div
class="flex flex-row justify-center align-center text-center gap-2" class="flex flex-row justify-center align-center text-center gap-2"
> >
<button class="p-2 rounded-lg hover:bg-gray-300"> <button class="p-2 rounded-t-xl hover:bg-gray-300 transition-all duration-400">
<History class="h-4 w-4" /> <History class="h-4 w-4" />
</button> </button>
<button class="p-2 rounded-lg hover:bg-gray-300"> <button class="p-2 rounded-t-xl hover:bg-gray-300 transition-all duration-400">
<Plus class="h-4 w-4" /> <Plus class="h-4 w-4" />
</button> </button>
</div> </div>
</div> </div>
</div> </div>
<hr /> <hr />
<div ref="chatContainerRef" class="flex-1 overflow-y-auto p-4 space-y-4">
</div> </div>
<div class="text-black w-full flex flex-row space-x-2">
<Input class="flex-1 rounded-xl" placeholder="Type a message..."
/>
<button class="pl-2 pr-2 mr-1 ml-1 bg-black text-white rounded-full hover:bg-gray-700 hover:translate-y-[-4px] transition-all duration-300 disabled:cursor-not-allowed disabled:hover:translate-y-0 disabled:bg-color-500" disabled="true"><Send class="w-5 h-5"/></button>
</div>
</div>
</div>
</template> </template>

View File

@ -0,0 +1,24 @@
<script setup lang="ts">
import type { HTMLAttributes } from 'vue'
import { cn } from '@/lib/utils'
import { useVModel } from '@vueuse/core'
const props = defineProps<{
defaultValue?: string | number
modelValue?: string | number
class?: HTMLAttributes['class']
}>()
const emits = defineEmits<{
(e: 'update:modelValue', payload: string | number): void
}>()
const modelValue = useVModel(props, 'modelValue', emits, {
passive: true,
defaultValue: props.defaultValue,
})
</script>
<template>
<input v-model="modelValue" :class="cn('flex h-9 w-full rounded-md border border-input bg-transparent px-3 py-1 text-sm shadow-sm transition-colors file:border-0 file:bg-transparent file:text-sm file:font-medium placeholder:text-muted-foreground focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-ring disabled:cursor-not-allowed disabled:opacity-50', props.class)">
</template>

View File

@ -0,0 +1 @@
export { default as Input } from './Input.vue'