Skip to content

Commit 814c3a2

Browse files
JS-anChanzhaoyu
andauthored
feat: 切换 history 时自动聚焦输入框 (#735)
* feat: 修改 scrollToBottom 行为(当滚动条在底部或发送问题时才会进入自动滚动,滚轮向上滚动会中止自动滚动,方便复制和查看之前的代码; 切换 history 时自动聚焦输入框,方便直接输入文字,不用再次去点击输入框;) * chore: 通过eslint检查 * perf: 清理重复功能 --------- Co-authored-by: Redon <790348264@qq.com>
1 parent d2a22a3 commit 814c3a2

File tree

1 file changed

+5
-0
lines changed

1 file changed

+5
-0
lines changed

src/views/chat/index.vue

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
<script setup lang='ts'>
2+
import type { Ref } from 'vue'
23
import { computed, onMounted, onUnmounted, ref } from 'vue'
34
import { useRoute } from 'vue-router'
45
import { storeToRefs } from 'pinia'
@@ -40,6 +41,7 @@ const conversationList = computed(() => dataSources.value.filter(item => (!item.
4041
4142
const prompt = ref<string>('')
4243
const loading = ref<boolean>(false)
44+
const inputRef = ref<Ref | null>(null)
4345
4446
// 添加PromptStore
4547
const promptStore = usePromptStore()
@@ -452,6 +454,8 @@ const footerClass = computed(() => {
452454
453455
onMounted(() => {
454456
scrollToBottom()
457+
if (inputRef.value)
458+
inputRef.value?.focus()
455459
})
456460
457461
onUnmounted(() => {
@@ -532,6 +536,7 @@ onUnmounted(() => {
532536
<NAutoComplete v-model:value="prompt" :options="searchOptions" :render-label="renderOption">
533537
<template #default="{ handleInput, handleBlur, handleFocus }">
534538
<NInput
539+
ref="inputRef"
535540
v-model:value="prompt"
536541
type="textarea"
537542
:placeholder="placeholder"

0 commit comments

Comments
 (0)