提交 c8f6a21b 编写于 作者: D DebugIsFalse

feature: 优化process组件

上级 15a1c6e5
<template> <template>
<ISearchProcess :item="item" :collapse="collapse" />
<div class="text-xl flex items-center space-x-1" v-if="item.ansLoading !== undefined"> <div class="text-xl flex items-center space-x-1" v-if="item.ansLoading !== undefined">
<UIcon name="i-heroicons-chat-bubble-left-right-20-solid" /> <UIcon name="i-heroicons-chat-bubble-left-right-20-solid" />
<span>{{ item.ansLoading ? '回答中' : '回答' }}</span> <span>{{ item.ansLoading ? '回答中' : '回答' }}</span>
...@@ -38,10 +39,13 @@ const props = defineProps({ ...@@ -38,10 +39,13 @@ const props = defineProps({
index: { index: {
type: Number, type: Number,
default: 0 default: 0
},
collapse: {
type: Boolean,
default: true
} }
}) })
const emits = defineEmits(['regenerate']) const emits = defineEmits(['regenerate'])
function handleReGenerate () { function handleReGenerate () {
emits('regenerate', props.index) emits('regenerate', props.index)
} }
......
...@@ -66,6 +66,9 @@ function handleToggleCollapse () { ...@@ -66,6 +66,9 @@ function handleToggleCollapse () {
function handleCollapse (state) { function handleCollapse (state) {
openCollapse.value = state openCollapse.value = state
} }
watch(() => props.collapse, () => {
openCollapse.value = props.collapse
})
watch( watch(
() => props.item.ansLoading, () => props.item.ansLoading,
(value, oldValue) => { (value, oldValue) => {
......
...@@ -14,12 +14,12 @@ ...@@ -14,12 +14,12 @@
<div class="grid"> <div class="grid">
<ISearchTitle as="h2" :title="item.question" :id="index + 1" /> <ISearchTitle as="h2" :title="item.question" :id="index + 1" />
</div> </div>
<ISearchProcess ref="historyAskRefs" :item="item" :collapse="false" />
<ISearchContent <ISearchContent
:item="item" :item="item"
:asking="false" :asking="false"
:is-last-index="false" :is-last-index="false"
:index="index" :index="index"
:collapse="false"
/> />
<UDivider v-if="data.length !== index + 1 || askingData.question" class="pt-3 pb-2" /> <UDivider v-if="data.length !== index + 1 || askingData.question" class="pt-3 pb-2" />
</template> </template>
...@@ -27,10 +27,10 @@ ...@@ -27,10 +27,10 @@
<div class="grid"> <div class="grid">
<ISearchTitle as="h2" :title="askingData.question" :id="data.length + 1" /> <ISearchTitle as="h2" :title="askingData.question" :id="data.length + 1" />
</div> </div>
<ISearchProcess ref="askingRef" :item="askingData" :collapse="false" />
<ISearchContent <ISearchContent
:item="askingData" :item="askingData"
:asking="asking" :asking="asking"
:collapse="askingData.collapse"
:is-last-index="true" :is-last-index="true"
@regenerate="handleReGenerate" @regenerate="handleReGenerate"
/> />
...@@ -66,10 +66,8 @@ const state = reactive({ ...@@ -66,10 +66,8 @@ const state = reactive({
const historyStatus = ref(200) const historyStatus = ref(200)
const data = ref([]) const data = ref([])
const askingData = ref({ question: $setFirstRecordTitle.value, desLoading: true }) const askingData = ref({ question: $setFirstRecordTitle.value, desLoading: true, collapse: true })
const recommendQuestions = ref([]) const recommendQuestions = ref([])
const askingRef = ref(null)
const historyAskRefs = ref([])
let asking = ref(false) let asking = ref(false)
// 处理ai generate // 处理ai generate
let aiChatController = null // 用户取消操作方法 let aiChatController = null // 用户取消操作方法
...@@ -148,7 +146,7 @@ const handleReGenerate = () => { ...@@ -148,7 +146,7 @@ const handleReGenerate = () => {
desLoading: true desLoading: true
} }
nextTick(() => { nextTick(() => {
askingRef.value && askingRef.value.handleCollapse(true) askingData.value.collapse = true
}) })
generateFetchData(`根据上述回答,对问题"${question}"重新生成`) generateFetchData(`根据上述回答,对问题"${question}"重新生成`)
} }
...@@ -159,20 +157,13 @@ function baseGitUrl() { ...@@ -159,20 +157,13 @@ function baseGitUrl() {
return endWidthGit ? state.gitPath.slice(0, state.gitPath.length - 4) : state.gitPath return endWidthGit ? state.gitPath.slice(0, state.gitPath.length - 4) : state.gitPath
} }
const handleCloseHistoryAsk = () => {
historyAskRefs.value.forEach(item => {
if (item && item.handleCollapse) {
item.handleCollapse(false)
}
})
}
const createGenerateInitItem = (question) => { const createGenerateInitItem = (question) => {
if (askingData.value.question) { if (askingData.value.question) {
data.value.push(askingData.value) data.value.push(askingData.value)
} }
askingData.value = { question, desLoading: true } askingData.value = { question, desLoading: true }
nextTick(() => { nextTick(() => {
handleCloseHistoryAsk() askingData.value.collapse = true
}) })
} }
const handleContinueAsk = (question) => { const handleContinueAsk = (question) => {
...@@ -181,9 +172,6 @@ const handleContinueAsk = (question) => { ...@@ -181,9 +172,6 @@ const handleContinueAsk = (question) => {
// 清空相关文件数据 // 清空相关文件数据
recommendQuestions.value = [] recommendQuestions.value = []
createGenerateInitItem(question) createGenerateInitItem(question)
nextTick(() => {
askingRef.value && askingRef.value.handleCollapse(true)
})
generateFetchData(question) generateFetchData(question)
setTimeout(() => { setTimeout(() => {
scrollToView() scrollToView()
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册