Skip to content

fix: 【应用】问答页面用户提问时,只输入空格不能发送(#108) #121

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Apr 16, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 5 additions & 3 deletions ui/src/components/ai-chat/index.vue
Original file line number Diff line number Diff line change
Expand Up @@ -217,7 +217,7 @@ const chartOpenId = ref('')
const chatList = ref<any[]>([])

const isDisabledChart = computed(
() => !(inputValue.value && (props.appId || (props.data?.name && props.data?.model_id)))
() => !(inputValue.value.trim() && (props.appId || (props.data?.name && props.data?.model_id)))
)
const isMdArray = (val: string) => val.match(/^-\s.*/m)
const prologueList = computed(() => {
Expand Down Expand Up @@ -286,7 +286,9 @@ function sendChatHandle(event: any) {
// 如果没有按下组合键ctrl,则会阻止默认事件
event.preventDefault()
if (!isDisabledChart.value && !loading.value && !event.isComposing) {
chatMessage()
if (inputValue.value.trim()) {
chatMessage()
}
}
} else {
// 如果同时按下ctrl+回车键,则会换行
Expand Down Expand Up @@ -423,7 +425,7 @@ function chatMessage(chat?: any, problem?: string, re_chat?: boolean) {
if (!chat) {
chat = reactive({
id: randomId(),
problem_text: problem ? problem : inputValue.value,
problem_text: problem ? problem : inputValue.value.trim(),
answer_text: '',
buffer: [],
write_ed: false,
Expand Down