feat: add chat quick question

This commit is contained in:
wangdan-fit2cloud 2024-12-24 17:23:47 +08:00
parent af3266b979
commit f1cca66012

View File

@ -189,7 +189,7 @@ import { MsgWarning } from '@/utils/message'
const route = useRoute() const route = useRoute()
const { const {
query: { mode } query: { mode, question }
} = route as any } = route as any
const quickInputRef = ref() const quickInputRef = ref()
const props = withDefaults( const props = withDefaults(
@ -483,11 +483,11 @@ const handleTimeChange = () => {
}, 1000) }, 1000)
} }
function sendChatHandle(event: any) { function sendChatHandle(event?: any) {
if (!event.ctrlKey) { if (!event?.ctrlKey) {
// ctrl // ctrl
event.preventDefault() event?.preventDefault()
if (!isDisabledChart.value && !props.loading && !event.isComposing) { if (!isDisabledChart.value && !props.loading && !event?.isComposing) {
if (inputValue.value.trim()) { if (inputValue.value.trim()) {
props.sendMessage(inputValue.value, { props.sendMessage(inputValue.value, {
image_list: uploadImageList.value, image_list: uploadImageList.value,
@ -530,6 +530,10 @@ function mouseleave() {
} }
onMounted(() => { onMounted(() => {
if (question) {
inputValue.value = decodeURIComponent(question.trim())
sendChatHandle()
}
setTimeout(() => { setTimeout(() => {
if (quickInputRef.value && mode === 'embed') { if (quickInputRef.value && mode === 'embed') {
quickInputRef.value.textarea.style.height = '0' quickInputRef.value.textarea.style.height = '0'