feat: 当左侧选项为空时,隐藏 + 号
This commit is contained in:
parent
ec66a0b7a9
commit
5d8101a502
@ -54,7 +54,7 @@
|
|||||||
</template>
|
</template>
|
||||||
|
|
||||||
<script setup>
|
<script setup>
|
||||||
import { ref, computed, toRefs, onMounted, nextTick, watch, onBeforeUnmount } from 'vue';
|
import { ref, computed, onMounted, nextTick, watch, onBeforeUnmount, useSlots } from 'vue';
|
||||||
import {
|
import {
|
||||||
SendOutlined,
|
SendOutlined,
|
||||||
ArrowUpOutlined,
|
ArrowUpOutlined,
|
||||||
@ -67,7 +67,6 @@ import {
|
|||||||
const inputRef = ref(null);
|
const inputRef = ref(null);
|
||||||
const isSingleLine = ref(true);
|
const isSingleLine = ref(true);
|
||||||
const optionsExpanded = ref(false);
|
const optionsExpanded = ref(false);
|
||||||
const hasOptionsLeft = ref(false);
|
|
||||||
const singleLineHeight = ref(0); // Add this
|
const singleLineHeight = ref(0); // Add this
|
||||||
// 用于防抖的定时器
|
// 用于防抖的定时器
|
||||||
const debounceTimer = ref(null);
|
const debounceTimer = ref(null);
|
||||||
@ -107,6 +106,15 @@ const props = defineProps({
|
|||||||
});
|
});
|
||||||
|
|
||||||
const emit = defineEmits(['update:modelValue', 'send', 'keydown']);
|
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 = {
|
const iconComponents = {
|
||||||
@ -206,13 +214,6 @@ const focusInput = () => {
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
// 检查是否有左侧选项
|
|
||||||
const checkOptionsLeft = () => {
|
|
||||||
// 这里可以通过检查slot内容来判断是否有选项
|
|
||||||
// 暂时设为true,实际使用时可以根据slot内容动态判断
|
|
||||||
hasOptionsLeft.value = true;
|
|
||||||
};
|
|
||||||
|
|
||||||
// 监听输入值变化
|
// 监听输入值变化
|
||||||
watch(inputValue, () => {
|
watch(inputValue, () => {
|
||||||
nextTick(() => {
|
nextTick(() => {
|
||||||
@ -242,7 +243,6 @@ watch(inputValue, () => {
|
|||||||
// Wait for component to mount before setting up onStartTyping
|
// Wait for component to mount before setting up onStartTyping
|
||||||
onMounted(() => {
|
onMounted(() => {
|
||||||
// console.log('Component mounted');
|
// console.log('Component mounted');
|
||||||
checkOptionsLeft();
|
|
||||||
nextTick(() => {
|
nextTick(() => {
|
||||||
if (inputRef.value) {
|
if (inputRef.value) {
|
||||||
// 记录单行模式下的高度和宽度基准
|
// 记录单行模式下的高度和宽度基准
|
||||||
@ -457,4 +457,4 @@ onBeforeUnmount(() => {
|
|||||||
padding: 0.625rem 0.875rem;
|
padding: 0.625rem 0.875rem;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
</style>
|
</style>
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user