feat: 当左侧选项为空时,隐藏 + 号

This commit is contained in:
Wenjie Zhang 2025-10-15 13:29:33 +08:00
parent ec66a0b7a9
commit 5d8101a502

View File

@ -54,7 +54,7 @@
</template>
<script setup>
import { ref, computed, toRefs, onMounted, nextTick, watch, onBeforeUnmount } from 'vue';
import { ref, computed, onMounted, nextTick, watch, onBeforeUnmount, useSlots } from 'vue';
import {
SendOutlined,
ArrowUpOutlined,
@ -67,7 +67,6 @@ import {
const inputRef = ref(null);
const isSingleLine = ref(true);
const optionsExpanded = ref(false);
const hasOptionsLeft = ref(false);
const singleLineHeight = ref(0); // Add this
//
const debounceTimer = ref(null);
@ -107,6 +106,15 @@ const props = defineProps({
});
const emit = defineEmits(['update:modelValue', 'send', 'keydown']);
const slots = useSlots();
const hasOptionsLeft = computed(() => {
const slot = slots['options-left'];
if (!slot) {
return false;
}
const renderedNodes = slot();
return Boolean(renderedNodes && renderedNodes.length);
});
//
const iconComponents = {
@ -206,13 +214,6 @@ const focusInput = () => {
}
};
//
const checkOptionsLeft = () => {
// slot
// true使slot
hasOptionsLeft.value = true;
};
//
watch(inputValue, () => {
nextTick(() => {
@ -242,7 +243,6 @@ watch(inputValue, () => {
// Wait for component to mount before setting up onStartTyping
onMounted(() => {
// console.log('Component mounted');
checkOptionsLeft();
nextTick(() => {
if (inputRef.value) {
//
@ -457,4 +457,4 @@ onBeforeUnmount(() => {
padding: 0.625rem 0.875rem;
}
}
</style>
</style>