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

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

...@@ -166,7 +166,19 @@ const state = reactive({ ...@@ -166,7 +166,19 @@ const state = reactive({
branch: repoItem.branch, branch: repoItem.branch,
gitPath: repoItem.url gitPath: repoItem.url
}) })
// 是否停止自动滚动到底部
const isAutoToBottom = ref(true);
let markedWindowScrollTop = 0;
const handleScroll = () => {
const top = window.scrollY;
if (top < markedWindowScrollTop) {
isAutoToBottom.value = false;
} else {
markedWindowScrollTop = top
}
}
const scrollToView = () => { const scrollToView = () => {
if (!isAutoToBottom.value) return;
const $target = document.querySelector('#scrollElement') const $target = document.querySelector('#scrollElement')
const height = $target.clientHeight const height = $target.clientHeight
y.value = height; y.value = height;
...@@ -216,7 +228,7 @@ defineShortcuts({ ...@@ -216,7 +228,7 @@ defineShortcuts({
enter: { enter: {
usingInput: 'queryInput', usingInput: 'queryInput',
handler: () => { handler: () => {
handleContinueAsk(continueQuestion) handleContinueAsk(continueQuestion.value)
} }
} }
}) })
...@@ -226,6 +238,7 @@ const handleClearInput = () => { ...@@ -226,6 +238,7 @@ const handleClearInput = () => {
} }
const handleContinueAsk = (question) => { const handleContinueAsk = (question) => {
if (asking.value) return if (asking.value) return
isAutoToBottom.value = true
asking.value = true asking.value = true
editIndex.value = data.value.length editIndex.value = data.value.length
createGenerateInitItem(question) createGenerateInitItem(question)
...@@ -366,6 +379,10 @@ const generateFetchData = (query) => { ...@@ -366,6 +379,10 @@ 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.
先完成此消息的编辑!
想要评论请 注册