Fix some chatUI stuff.

This commit is contained in:
吳元皓 2025-05-15 11:10:49 +08:00
parent 94fbf1551d
commit 62ecea8aa3
2 changed files with 20 additions and 19 deletions

View File

@ -1,7 +0,0 @@
<script lang="ts" setup>
const route = useRoute();
const provider = route.params.provider;
const slug = route.params.slug;
</script>
<template></template>

View File

@ -3,14 +3,27 @@ import { History, Plus, Send } from "lucide-vue-next";
import { Input } from "~/components/ui/input"; 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 cookieChatId = cookie.value;
const message = ref(); const chatId = ref();
const inputMessage = ref();
const messages = ref([]); const messages = ref([]);
onMounted(() => { onMounted(async () => {
console.log(lastChatId); console.log(cookieChatId);
if (lastChatId) { if (cookieChatId) {
} else {
const { data: checkUserChatId } = await useFetch(
"/api/ai/chat/actions/findUserChatId",
);
cookieChatId.value = checkUserChatId.value;
} }
}); });
onMounted(async () => {
const {
data: getData,
pending,
error,
} = useFetch(`/api/ai/chat/${chatId.value}`);
});
</script> </script>
<template> <template>
<div class="flex flex-col h-full"> <div class="flex flex-col h-full">
@ -48,16 +61,11 @@ onMounted(() => {
<Input <Input
class="flex-1 rounded-xl" class="flex-1 rounded-xl"
placeholder="Type a message..." placeholder="Type a message..."
v-ref="message" v-model="inputMessage"
/> />
<button <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" 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=" :disabled="!inputMessage?.trim()"
() => {
if (!message) return false;
else return true;
}
"
> >
<Send class="w-5 h-5" /> <Send class="w-5 h-5" />
</button> </button>