提交 c8f6a21b 编写于 作者: D DebugIsFalse

feature: 优化process组件

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