Skip to content

Commit

Permalink
feat: 切换 history 时自动聚焦输入框 (#735)
Browse files Browse the repository at this point in the history
* feat: 修改 scrollToBottom 行为(当滚动条在底部或发送问题时才会进入自动滚动,滚轮向上滚动会中止自动滚动,方便复制和查看之前的代码; 切换 history 时自动聚焦输入框,方便直接输入文字,不用再次去点击输入框;)

* chore: 通过eslint检查

* perf: 清理重复功能

---------

Co-authored-by: Redon <[email protected]>
  • Loading branch information
JS-an and Chanzhaoyu authored Mar 22, 2023
1 parent d2a22a3 commit 814c3a2
Showing 1 changed file with 5 additions and 0 deletions.
5 changes: 5 additions & 0 deletions src/views/chat/index.vue
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
<script setup lang='ts'>
import type { Ref } from 'vue'
import { computed, onMounted, onUnmounted, ref } from 'vue'
import { useRoute } from 'vue-router'
import { storeToRefs } from 'pinia'
Expand Down Expand Up @@ -40,6 +41,7 @@ const conversationList = computed(() => dataSources.value.filter(item => (!item.
const prompt = ref<string>('')
const loading = ref<boolean>(false)
const inputRef = ref<Ref | null>(null)
// 添加PromptStore
const promptStore = usePromptStore()
Expand Down Expand Up @@ -452,6 +454,8 @@ const footerClass = computed(() => {
onMounted(() => {
scrollToBottom()
if (inputRef.value)
inputRef.value?.focus()
})
onUnmounted(() => {
Expand Down Expand Up @@ -532,6 +536,7 @@ onUnmounted(() => {
<NAutoComplete v-model:value="prompt" :options="searchOptions" :render-label="renderOption">
<template #default="{ handleInput, handleBlur, handleFocus }">
<NInput
ref="inputRef"
v-model:value="prompt"
type="textarea"
:placeholder="placeholder"
Expand Down

0 comments on commit 814c3a2

Please sign in to comment.