Skip to content

Commit 5d8101a

Browse files
committed
feat: 当左侧选项为空时,隐藏 + 号
1 parent ec66a0b commit 5d8101a

File tree

1 file changed

+11
-11
lines changed

1 file changed

+11
-11
lines changed

web/src/components/MessageInputComponent.vue

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@
5454
</template>
5555

5656
<script setup>
57-
import { ref, computed, toRefs, onMounted, nextTick, watch, onBeforeUnmount } from 'vue';
57+
import { ref, computed, onMounted, nextTick, watch, onBeforeUnmount, useSlots } from 'vue';
5858
import {
5959
SendOutlined,
6060
ArrowUpOutlined,
@@ -67,7 +67,6 @@ import {
6767
const inputRef = ref(null);
6868
const isSingleLine = ref(true);
6969
const optionsExpanded = ref(false);
70-
const hasOptionsLeft = ref(false);
7170
const singleLineHeight = ref(0); // Add this
7271
// 用于防抖的定时器
7372
const debounceTimer = ref(null);
@@ -107,6 +106,15 @@ const props = defineProps({
107106
});
108107
109108
const emit = defineEmits(['update:modelValue', 'send', 'keydown']);
109+
const slots = useSlots();
110+
const hasOptionsLeft = computed(() => {
111+
const slot = slots['options-left'];
112+
if (!slot) {
113+
return false;
114+
}
115+
const renderedNodes = slot();
116+
return Boolean(renderedNodes && renderedNodes.length);
117+
});
110118
111119
// 图标映射
112120
const iconComponents = {
@@ -206,13 +214,6 @@ const focusInput = () => {
206214
}
207215
};
208216
209-
// 检查是否有左侧选项
210-
const checkOptionsLeft = () => {
211-
// 这里可以通过检查slot内容来判断是否有选项
212-
// 暂时设为true,实际使用时可以根据slot内容动态判断
213-
hasOptionsLeft.value = true;
214-
};
215-
216217
// 监听输入值变化
217218
watch(inputValue, () => {
218219
nextTick(() => {
@@ -242,7 +243,6 @@ watch(inputValue, () => {
242243
// Wait for component to mount before setting up onStartTyping
243244
onMounted(() => {
244245
// console.log('Component mounted');
245-
checkOptionsLeft();
246246
nextTick(() => {
247247
if (inputRef.value) {
248248
// 记录单行模式下的高度和宽度基准
@@ -457,4 +457,4 @@ onBeforeUnmount(() => {
457457
padding: 0.625rem 0.875rem;
458458
}
459459
}
460-
</style>
460+
</style>

0 commit comments

Comments
 (0)