feat(RenderMinerU): 实现代码视图滚动同步

- 添加 handleScroll 方法处理滚动事件
- 在 created 钩子中注释掉设置滚动事件监听的代码
- 优化了代码视图滚动时的同步逻辑
This commit is contained in:
陈昱达
2025-04-21 17:09:16 +08:00
parent 77b097d0d9
commit cee557b14e
2 changed files with 29 additions and 1 deletions

View File

@@ -575,6 +575,31 @@ ${text}`
.catch(() => {
this.$message.error('重试操作失败')
})
},
// 处理滚动事件
handleScroll() {
let viewBody = this.$refs.viewBody
let viewCodes = this.$refs.viewBody.querySelectorAll('view-code')
if (this.tab === '1') {
viewBody = this.$refs.mdEditor
viewCodes = this.$refs.mdEditor.querySelectorAll('ebiz-code')
}
const viewBodyTop = viewBody.scrollTop
const viewBodyHeight = viewBody.clientHeight
let currentPage = this.page
for (let i = 0; i < viewCodes.length; i++) {
const viewCode = viewCodes[i]
const viewCodeTop = viewCode.offsetTop
if (viewCodeTop >= viewBodyTop && viewCodeTop < viewBodyTop + viewBodyHeight / 2) {
currentPage = i + 1
break
}
}
if (currentPage !== this.page) {
this.page = currentPage
this.sendMessageToIframe('setPage', currentPage)
}
}
},
created() {},
@@ -606,6 +631,9 @@ ${text}`
})
this.generateTableButtons()
//
// this.$refs.viewBody.onscroll = this.handleScroll
// this.$refs.mdEditor.onscroll = this.handleScroll
},
computed: {}
}

View File

@@ -52,7 +52,7 @@ export default {
name: 'create',
data() {
return {
visible: true,
visible: false,
active: 0,
documentId: '1363864715567140864'
}