提交 fb9cb3ba 编写于 作者: View Design's avatar View Design

Merge branch 'main' of gitcode.com:git_bot/ai-fe

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