提交 6d5427f4 编写于 作者: D DebugIsFalse

scroll

上级 b46081fc
......@@ -41,13 +41,13 @@ const route = useRoute()
const { fetchRequest } = useFetchRequest()
const editIndex = ref(0)
const { y } = useWindowScroll({ behavior: 'smooth' })
let repoData = await fetchRequest('/v1/chat/repository', {
const { directions } = useScroll(window)
let repoData = await fetchRequest('/v1/chat/repository22', {
headers: {
'Content-Type': 'application/x-www-form-urlencoded'
}
})
repoData = repoData.data.map(item => {
}).catch(()=> {})
repoData = repoData && repoData.data.map(item => {
return {
label: item.name,
url: item.path,
......@@ -73,14 +73,12 @@ function handleUpdateQuery(query) {
}
// 是否停止自动滚动到底部
const isAutoToBottom = ref(true)
const handleScroll = (event, params) => {
// 在asking操作的时候生效
if (!asking.value || !isAutoToBottom.value) return
const top = window.scrollY;
if (top < y.value) {
isAutoToBottom.value = false
watch(() => {
console.log(`directions.top:`, directions.top)
if (directions.top) {
isAutoToBottom.value = true
}
}
})
const scrollToView = () => {
if (!isAutoToBottom.value) return
const $target = document.querySelector('#scrollElement')
......@@ -145,9 +143,9 @@ const handleFormFetchData = (fetchData) => {
if (Object.keys(message).length === 0) return
const { meta, choices } = message
const index = editIndex.value
setTimeout(() => {
if (isAutoToBottom.value) {
scrollToView()
})
}
// 处理报错信息
if (!meta) {
handleStopGenerate()
......@@ -245,10 +243,6 @@ const generateFetchData = (query) => {
}
onMounted(() => {
generateFetchData(state.query)
window.addEventListener('scroll', handleScroll)
})
onBeforeUnmount(()=> {
window.removeEventListener('scroll', handleScroll)
})
</script>
\ No newline at end of file
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册