|
|
@ -1,5 +1,5 @@
|
|
|
|
<script setup lang='ts'>
|
|
|
|
<script setup lang='ts'>
|
|
|
|
import { computed, nextTick, ref } from 'vue'
|
|
|
|
import { computed, nextTick, ref, watch } from 'vue'
|
|
|
|
import { NButton, NInput, useMessage } from 'naive-ui'
|
|
|
|
import { NButton, NInput, useMessage } from 'naive-ui'
|
|
|
|
import { Message } from './components'
|
|
|
|
import { Message } from './components'
|
|
|
|
import { Layout } from './layout'
|
|
|
|
import { Layout } from './layout'
|
|
|
@ -7,6 +7,7 @@ import { useChat } from './hooks/useChat'
|
|
|
|
import { fetchChatAPI } from '@/api'
|
|
|
|
import { fetchChatAPI } from '@/api'
|
|
|
|
import { HoverButton, SvgIcon } from '@/components/common'
|
|
|
|
import { HoverButton, SvgIcon } from '@/components/common'
|
|
|
|
import { useHistoryStore } from '@/store'
|
|
|
|
import { useHistoryStore } from '@/store'
|
|
|
|
|
|
|
|
import { isNumber } from '@/utils/is'
|
|
|
|
|
|
|
|
|
|
|
|
const ms = useMessage()
|
|
|
|
const ms = useMessage()
|
|
|
|
|
|
|
|
|
|
|
@ -19,6 +20,8 @@ const { addChat, clearChat } = useChat()
|
|
|
|
const prompt = ref('')
|
|
|
|
const prompt = ref('')
|
|
|
|
const loading = ref(false)
|
|
|
|
const loading = ref(false)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
const currentActive = computed(() => historyStore.active)
|
|
|
|
|
|
|
|
|
|
|
|
const list = computed<Chat.Chat[]>(() => historyStore.getCurrentChat)
|
|
|
|
const list = computed<Chat.Chat[]>(() => historyStore.getCurrentChat)
|
|
|
|
const chatList = computed<Chat.Chat[]>(() => list.value.filter(item => (!item.reversal && !item.error)))
|
|
|
|
const chatList = computed<Chat.Chat[]>(() => list.value.filter(item => (!item.reversal && !item.error)))
|
|
|
|
|
|
|
|
|
|
|
@ -63,14 +66,26 @@ function handleEnter(event: KeyboardEvent) {
|
|
|
|
function addMessage(
|
|
|
|
function addMessage(
|
|
|
|
message: string,
|
|
|
|
message: string,
|
|
|
|
args?: { reversal?: boolean; error?: boolean; options?: Chat.ChatOptions },
|
|
|
|
args?: { reversal?: boolean; error?: boolean; options?: Chat.ChatOptions },
|
|
|
|
|
|
|
|
uuid?: number | null,
|
|
|
|
) {
|
|
|
|
) {
|
|
|
|
addChat(message, args)
|
|
|
|
addChat(message, args, uuid)
|
|
|
|
nextTick(() => scrollRef.value && (scrollRef.value.scrollTop = scrollRef.value.scrollHeight))
|
|
|
|
nextTick(() => scrollRef.value && (scrollRef.value.scrollTop = scrollRef.value.scrollHeight))
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
function handleClear() {
|
|
|
|
function handleClear() {
|
|
|
|
clearChat()
|
|
|
|
clearChat()
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
watch(
|
|
|
|
|
|
|
|
currentActive,
|
|
|
|
|
|
|
|
(active: number | null) => {
|
|
|
|
|
|
|
|
if (isNumber(active)) {
|
|
|
|
|
|
|
|
loading.value = false
|
|
|
|
|
|
|
|
nextTick(() => scrollRef.value && (scrollRef.value.scrollTop = scrollRef.value.scrollHeight))
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
},
|
|
|
|
|
|
|
|
{ immediate: true },
|
|
|
|
|
|
|
|
)
|
|
|
|
</script>
|
|
|
|
</script>
|
|
|
|
|
|
|
|
|
|
|
|
<template>
|
|
|
|
<template>
|
|
|
|