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

fix: 滚动问题

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