chore: version 2.8.0 (#140)

* fix: 用户输入换行符号被忽略的问题[#137]

* feat: 输入框添加换行提示,移动端`Enter` 判定换行而不是提交[#135]

* feat: 调整标签

* chore: version 2.8.0
This commit is contained in:
Redon
2023-02-27 11:14:32 +08:00
committed by GitHub
parent 3e9db49aad
commit 89712aada7
9 changed files with 57 additions and 9 deletions

View File

@@ -48,8 +48,8 @@ const text = computed(() => {
</template>
<template v-else>
<div class="leading-relaxed break-all">
<div v-if="!inversion" class="markdown-body" v-html="text" />
<div v-else v-text="text" />
<pre v-if="!inversion" class="markdown-body" v-html="text" />
<div v-else class="whitespace-pre-wrap" v-text="text" />
</div>
</template>
</div>

View File

@@ -266,9 +266,11 @@ function handleClear() {
}
function handleEnter(event: KeyboardEvent) {
if (event.key === 'Enter' && !event.shiftKey) {
event.preventDefault()
handleSubmit()
if (!isMobile.value) {
if (event.key === 'Enter' && !event.shiftKey) {
event.preventDefault()
handleSubmit()
}
}
}
@@ -279,6 +281,12 @@ function handleStop() {
}
}
const placeholder = computed(() => {
if (isMobile.value)
return 'Ask me anything...'
return 'Ask me anything... (Shift + Enter = line break)'
})
const buttonDisabled = computed(() => {
return loading.value || !prompt.value || prompt.value.trim() === ''
})
@@ -358,7 +366,7 @@ onUnmounted(() => {
v-model:value="prompt"
type="textarea"
:autosize="{ minRows: 1, maxRows: 2 }"
placeholder="Ask me anything..."
:placeholder="placeholder"
@keypress="handleEnter"
/>
<NButton type="primary" :disabled="buttonDisabled" @click="handleSubmit">