Skip to content
This repository has been archived by the owner on Feb 10, 2025. It is now read-only.

feat: 修改 scrollToBottom 行为,切换 history 时自动聚焦输入框 #735

Merged
merged 4 commits into from
Mar 22, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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