fix: bug修复
This commit is contained in:
parent
6543ac0607
commit
2d7f2492af
@ -1,5 +1,5 @@
|
||||
<template>
|
||||
<div class="dropdown-menu">
|
||||
<div class="dropdown-menu" ref="dropdownMenuRef">
|
||||
<n-virtual-list
|
||||
ref="virtualListRef"
|
||||
style="max-height: 240px"
|
||||
@ -20,7 +20,7 @@
|
||||
</template>
|
||||
|
||||
<script setup>
|
||||
import { ref, watch, defineProps, defineExpose } from 'vue'
|
||||
import { ref, watch, defineProps, defineExpose, onMounted, onUnmounted } from 'vue'
|
||||
|
||||
const props = defineProps({
|
||||
items: {
|
||||
@ -35,6 +35,40 @@ const props = defineProps({
|
||||
|
||||
const selectedIndex = ref(0)
|
||||
const virtualListRef = ref(null)
|
||||
const dropdownMenuRef = ref(null)
|
||||
|
||||
let observer = null
|
||||
|
||||
let isViewport = ref(true)
|
||||
const handleIntersection = (entries, observer) => {
|
||||
entries.forEach(entry => {
|
||||
if (entry.isIntersecting) {
|
||||
isViewport.value = true
|
||||
// 在这里处理元素可见的逻辑
|
||||
} else {
|
||||
isViewport.value = false
|
||||
// 在这里处理元素不可见的逻辑
|
||||
}
|
||||
})
|
||||
}
|
||||
onMounted(() => {
|
||||
observer = new IntersectionObserver(handleIntersection, {
|
||||
root: null, // null 值表示视口
|
||||
rootMargin: '0px',
|
||||
threshold: 0.1 // 元素至少有 10% 可见时触发回调
|
||||
})
|
||||
|
||||
if (dropdownMenuRef.value) {
|
||||
observer.observe(dropdownMenuRef.value)
|
||||
}
|
||||
})
|
||||
|
||||
onUnmounted(() => {
|
||||
if (observer && dropdownMenuRef.value) {
|
||||
observer.unobserve(dropdownMenuRef.value)
|
||||
observer.disconnect()
|
||||
}
|
||||
})
|
||||
|
||||
watch(
|
||||
() => props.items,
|
||||
@ -44,7 +78,8 @@ watch(
|
||||
)
|
||||
|
||||
const onKeyDown = ({ event }) => {
|
||||
console.log('event',event)
|
||||
console.log('event', event)
|
||||
if(!isViewport.value) return false
|
||||
if (event.key === 'ArrowUp') {
|
||||
upHandler()
|
||||
return true
|
||||
@ -100,6 +135,7 @@ defineExpose({
|
||||
overflow: auto;
|
||||
padding: 0.4rem;
|
||||
position: relative;
|
||||
|
||||
max-height: 200px;
|
||||
width: 200px;
|
||||
button {
|
||||
|
@ -61,6 +61,9 @@ const props = defineProps({
|
||||
type: Boolean,
|
||||
default: false
|
||||
},
|
||||
uid:{
|
||||
type: Number
|
||||
},
|
||||
members: {
|
||||
default: () => []
|
||||
}
|
||||
@ -288,7 +291,8 @@ const editor = useEditor({
|
||||
if (text) {
|
||||
event.preventDefault()
|
||||
const { state, dispatch } = view
|
||||
dispatch(state.tr.insertText(text))
|
||||
// dispatch(state.tr.insertContent(text).replace(/\n/g, '<br>'))
|
||||
editor.value.commands.insertContent(text.replace(/\r/g, '').replace(/\n/g, '<br>'))
|
||||
return true // Handled
|
||||
}
|
||||
|
||||
|
@ -75,7 +75,7 @@ const onSendMessage = (data = {}, callBack: any) => {
|
||||
}
|
||||
|
||||
// 发送文本消息
|
||||
const onSendTextEvent = throttle((value: any) => {
|
||||
const onSendTextEvent = (value: any) => {
|
||||
let { data, callBack } = value
|
||||
|
||||
let message = {
|
||||
@ -93,7 +93,7 @@ const onSendTextEvent = throttle((value: any) => {
|
||||
|
||||
callBack(true)
|
||||
})
|
||||
}, 1000)
|
||||
}
|
||||
|
||||
// 发送图片消息
|
||||
const onSendImageEvent = ({ data, callBack }) => {
|
||||
|
Loading…
Reference in New Issue
Block a user