perf: 输入空值不允许发送
This commit is contained in:
@ -30,7 +30,8 @@ export default {
|
||||
const senderRef = ref(null);
|
||||
const localSearchValue = ref(props.modelValue);
|
||||
|
||||
// 监听外部value变化
|
||||
const isEmptyValue = computed(() => !localSearchValue.value.trim());
|
||||
|
||||
watch(
|
||||
() => props.modelValue,
|
||||
(newValue) => {
|
||||
@ -39,6 +40,10 @@ export default {
|
||||
);
|
||||
|
||||
const handleSubmit = () => {
|
||||
if (isEmptyValue.value) {
|
||||
return;
|
||||
}
|
||||
|
||||
emit('submit', localSearchValue.value);
|
||||
// localSearchValue.value = ''
|
||||
};
|
||||
@ -65,7 +70,7 @@ export default {
|
||||
<div
|
||||
onClick={handleSubmit}
|
||||
class={`submit-btn w-32px h-32px p-6px flex justify-center items-center rounded-50% cursor-pointer ${
|
||||
!localSearchValue.value ? 'opacity-50' : ''
|
||||
isEmptyValue.value ? 'opacity-50' : ''
|
||||
}`}
|
||||
>
|
||||
<icon-arrow-right size={20} class="color-#FFFFFF" />
|
||||
@ -83,7 +88,7 @@ export default {
|
||||
<Sender
|
||||
v-model:value={localSearchValue.value}
|
||||
ref={senderRef}
|
||||
onChange={(value: string) => emit('update:modelValue', value)}
|
||||
onChange={(value: string) => emit('update:modelValue', value.trim())}
|
||||
onSubmit={handleSubmit}
|
||||
class="h-full w-full mb-24px"
|
||||
placeholder={props.placeholder}
|
||||
|
||||
@ -42,7 +42,7 @@ export default {
|
||||
conversationList.value.push({
|
||||
role: QUESTION_ROLE,
|
||||
content: message,
|
||||
});
|
||||
});
|
||||
|
||||
initSse({ message });
|
||||
};
|
||||
@ -84,7 +84,6 @@ export default {
|
||||
agent_id: chatStore.agentInfo.agent_id,
|
||||
}),
|
||||
});
|
||||
|
||||
} catch (error) {
|
||||
console.error('Failed to initialize SSE:', error);
|
||||
antdMessage.error('初始化连接失败');
|
||||
@ -128,7 +127,7 @@ export default {
|
||||
role: QUESTION_ROLE,
|
||||
content: message,
|
||||
});
|
||||
|
||||
|
||||
initSse(newVal);
|
||||
}
|
||||
},
|
||||
|
||||
Reference in New Issue
Block a user