diff --git a/src/components/chat/chat.vue b/src/components/chat/chat.vue index dbef5eb..7d78aee 100644 --- a/src/components/chat/chat.vue +++ b/src/components/chat/chat.vue @@ -16,22 +16,39 @@
- +
-

content

-
+ >
-
- +
+ + + + + + + + +
@@ -42,6 +59,11 @@ import { useMessage } from "naive-ui"; import { useUserStore } from "../../stores/user"; import { InputHTMLAttributes, onMounted, ref } from "vue"; +import { + SendOutline, + MicOutline, + DocumentAttachOutline, +} from "@vicons/ionicons5"; const message = useMessage(); const userStore = useUserStore(); @@ -49,28 +71,70 @@ const userStore = useUserStore(); const inputMessage = ref(""); const inputContainer: any = ref(null); const inputText: InputHTMLAttributes | null = ref(null); +const actionContainer: any = ref(null); +const isPlaceholderVisible = ref(true); +const triggerTimes = ref(0); +const showSendBtn = ref(false) +const content = ref("") function updateInputHeight() { - if (!inputText?.value || !inputContainer.value) { + if (!inputText?.value || !inputContainer.value || !actionContainer.value) { return; } const input = inputText.value; const container = inputContainer.value; + const action = actionContainer.value; + + content.value = input.innerText; + const trimContent = input.innerText.trim(); + + const isEmpty = trimContent === ""; + isPlaceholderVisible.value = isEmpty; + if (isEmpty || trimContent.length < 30) { + triggerTimes.value = 0; + } + + if (trimContent.length > 30) { + triggerTimes.value = 10; + } // 获取元素实际占用高度 const height = input.scrollHeight; const lines = input.innerText.split("\n").length; - if (lines > 2 || height > 50) { + if (lines > 3 || height > 50) { + triggerTimes.value += 1; + } else { + triggerTimes.value -= 1; + } + + if (triggerTimes.value > 8) { container.classList.add("rounded-lg"); container.classList.remove("rounded-full"); - container.classList.add("p-4") + container.classList.remove("max-w-2xl"); + container.classList.remove("w-2xl"); + container.classList.add("flex-col"); + action.classList.add("w-full"); + action.classList.add("text-right"); + action.classList.add("pt-4"); + action.classList.add("pb-0"); + action.classList.add("mt-2"); + showSendBtn.value = true } else { container.classList.remove("rounded-lg"); container.classList.add("rounded-full"); - container.classList.remove("p-4") + container.classList.remove("flex-col"); + container.classList.add("w-2xl"); + container.classList.add("max-w-2xl"); + + action.classList.remove("w-full"); + action.classList.remove("text-right"); + action.classList.remove("pt-4"); + action.classList.remove("pt-0"); + action.classList.remove("mt-2"); + showSendBtn.value = false } } @@ -80,22 +144,42 @@ onMounted(() => {