提交 d6c835ce 编写于 作者: View Design's avatar View Design

Update Ask.vue

上级 5874c1ba
<template> <template>
<div class="flex w-full"> <div class="flex w-full">
<UCard :ui="{ body: { padding: '', base: 'flex items-center pl-4 pr-1 py-1 gap-2' }, base: 'w-full', rounded: 'rounded-full' }"> <UCard
<UInput class="has-[:focus]:ring-2 has-[:focus]:ring-green-500 dark:has-[:focus]:ring-green-400"
:ui="cardUI"
>
<UTextarea
ref="queryInput"
class="flex-grow" class="flex-grow"
name="queryInput" name="queryInput"
:rows="1"
:maxrows="10"
autoresize
v-model="continueQuestion" v-model="continueQuestion"
placeholder="提出后续问题" :placeholder="'提出后续问题(' + metaSymbol + 'L)'"
size="xl" size="xl"
:padded="false" :padded="false"
variant="none" variant="none"
/> />
<div class="flex"> <UButton
v-if="continueQuestion"
:ui="{ rounded: 'rounded-full' }"
color="gray"
variant="ghost"
leading-icon="i-heroicons-x-mark-20-solid"
@click="handleClearQuestion"
/>
<div class="flex flex-shrink-0 gap-2">
<UButton <UButton
v-if="!asking" v-if="!asking"
:ui="{ rounded: 'rounded-full' }" :ui="{ rounded: 'rounded-full' }"
...@@ -34,22 +49,43 @@ ...@@ -34,22 +49,43 @@
</div> </div>
</template> </template>
<script setup> <script setup>
const { metaSymbol } = useShortcuts()
const props = defineProps({ const props = defineProps({
asking: { asking: {
type: Boolean, type: Boolean,
default: false default: false
} }
}) })
const emits = defineEmits(['ask', 'stop'])
const cardUI = {
body: {
padding: '',
base: 'flex items-end has-[textarea[rows="1"]]:items-center pl-4 pr-1 py-1 gap-2'
},
base: 'w-full',
rounded: 'rounded has-[textarea[rows="1"]]:rounded-full'
}
defineShortcuts({ defineShortcuts({
meta_enter: { meta_enter: {
usingInput: 'queryInput', usingInput: 'queryInput',
handler: () => { handler: () => {
handleAsk() handleAsk()
} }
},
meta_l: {
handler: () => {
handleFocus()
}
} }
}) })
const emits = defineEmits(['ask', 'stop']) function handleFocus () {
queryInput.value.textarea.focus()
}
const continueQuestion = ref('') const continueQuestion = ref('')
function handleClearQuestion () {
continueQuestion.value = ''
handleFocus()
}
function handleStop () { function handleStop () {
emits('stop') emits('stop')
} }
...@@ -58,4 +94,5 @@ function handleAsk () { ...@@ -58,4 +94,5 @@ function handleAsk () {
emits('ask', continueQuestion.value) emits('ask', continueQuestion.value)
continueQuestion.value = '' continueQuestion.value = ''
} }
const queryInput = ref(null)
</script> </script>
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册