提交 32241acd 编写于 作者: D DebugIsFalse

fix: 滚动问题

上级 2a429a6b
......@@ -34,7 +34,7 @@
<USkeleton class="h-4" />
<USkeleton class="h-4 w-2/3" />
</template>
<div class="text-xs pl-5" v-else>找到 {{ sourceCount }} 条来源</div>
<div class="text-xs pl-5" v-else>找到 {{ item.source && item.source.length || 0 }} 条来源</div>
</template>
<div class="text-base flex items-center gap-1" v-if="item.ansLoading !== undefined">
<UIcon name="i-heroicons-pencil-square" />
......@@ -70,10 +70,6 @@ const props = defineProps({
type: Object,
default: (() => {})
},
sourceCount: {
type: Number,
default: 0
},
asking: {
type: Boolean,
default: false
......@@ -127,4 +123,5 @@ function handleShare () {
title: '链接已复制到剪贴板'
})
}
defineExpose({ handleCollapse })
</script>
\ No newline at end of file
......@@ -15,17 +15,20 @@
</div>
<ISearchContent
:item="item"
:source-count="sourceCount"
:asking="asking"
:is-last-index="data.length - 1 === index"
:asking="false"
:is-last-index="false"
:index="index"
/>
<UDivider v-if="index !== data.length - 1" class="pt-3 pb-2" />
<UDivider class="pt-3 pb-2" />
</template>
<div class="grid" v-if="data.length > 0">
<h2 class="text-3xl" :id="data.length + 1">{{ askingData.question }}</h2>
</div>
<ISearchContent
:item="askingData"
:source-count="sourceCount"
:asking="asking"
ref="askingRef"
:is-last-index="true"
@regenerate="handleReGenerate"
/>
<ISearchRecommendQuestion
......@@ -107,42 +110,40 @@ const handleReGenerate = () => {
const data = ref([])
const askingData = ref({ question: state.query, desLoading: true })
const recommendQuestions = ref([])
const askingRef = ref(null)
// git url
const baseGitUrl = computed(() => {
const endWidthGit = state.gitPath.endsWith('.git')
const baseUrl = endWidthGit ? state.gitPath.slice(0, state.gitPath.length - 4) : state.gitPath
return baseUrl
})
// 正在运行的网络来源
const sourceCount = computed(() => {
const { source } = askingData.value;
if (!source) {
return 0
}
return source.length
})
let asking = ref(false)
// 处理ai generate
let aiChatController = null // 用户取消操作方法
const markedEnd = '[DONE]'
const createGenerateInitItem = (question) => {
data.value.push(askingData.value)
askingData.value = { question, desLoading: true }
}
const handleContinueAsk = (question) => {
if (asking.value) return
asking.value = true
askingRef.value.handleCollapse(true);
createGenerateInitItem(question)
generateFetchData(question)
setTimeout(() => {
scrollToView()
isAutoToBottom.value = true
})
}
// 处理ai generate
let aiChatController = null // 用户取消操作方法
const markedEnd = '[DONE]'
const createGenerateInitItem = (question) => {
// todo 唯一key
data.value.push(askingData.value)
asking.value = { question, desLoading: true }
}
const resetAnsLoading = () => {
Object.assign(askingData.value, { ansLoading: false, showActions: true })
}
const resetAutoBottom = () => {
nextTick(() => {
isAutoToBottom.value = true;
})
}
const handleFormFetchData = (fetchData) => {
let message = {}
try {
......@@ -158,21 +159,14 @@ const handleFormFetchData = (fetchData) => {
handleStopGenerate()
}
if (meta.type === 'answer') {
Object.assign(askingData.value, {
ansLoading: true,
desLoading: false,
searchLoading: false,
article: message.choices[0].message.content
})
Object.assign(askingData.value, { ansLoading: true, desLoading: false, searchLoading: false, article: message.choices[0].message.content })
return
}
if (meta.type !== 'log') return
if (meta.action === 'rephrase_question') {
Object.assign(askingData.value, { description: choices[0].message.content, desLoading: true })
nextTick(() => {
isAutoToBottom.value = true
})
resetAutoBottom()
return
}
if (meta.action === 'search_file') {
......@@ -186,9 +180,7 @@ const handleFormFetchData = (fetchData) => {
}
})
Object.assign(askingData.value, { desLoading: true, source, searchLoading: true, desLoading: false })
nextTick(() => {
isAutoToBottom.value = true
})
resetAutoBottom()
}
}
const handleMessage = (event) => {
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册