fix: bug修复

This commit is contained in:
yinkang 2025-07-09 11:49:55 +08:00
parent 6543ac0607
commit 2d7f2492af
3 changed files with 46 additions and 6 deletions

View File

@ -1,5 +1,5 @@
<template> <template>
<div class="dropdown-menu"> <div class="dropdown-menu" ref="dropdownMenuRef">
<n-virtual-list <n-virtual-list
ref="virtualListRef" ref="virtualListRef"
style="max-height: 240px" style="max-height: 240px"
@ -20,7 +20,7 @@
</template> </template>
<script setup> <script setup>
import { ref, watch, defineProps, defineExpose } from 'vue' import { ref, watch, defineProps, defineExpose, onMounted, onUnmounted } from 'vue'
const props = defineProps({ const props = defineProps({
items: { items: {
@ -35,6 +35,40 @@ const props = defineProps({
const selectedIndex = ref(0) const selectedIndex = ref(0)
const virtualListRef = ref(null) 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( watch(
() => props.items, () => props.items,
@ -44,7 +78,8 @@ watch(
) )
const onKeyDown = ({ event }) => { const onKeyDown = ({ event }) => {
console.log('event',event) console.log('event', event)
if(!isViewport.value) return false
if (event.key === 'ArrowUp') { if (event.key === 'ArrowUp') {
upHandler() upHandler()
return true return true
@ -100,6 +135,7 @@ defineExpose({
overflow: auto; overflow: auto;
padding: 0.4rem; padding: 0.4rem;
position: relative; position: relative;
max-height: 200px; max-height: 200px;
width: 200px; width: 200px;
button { button {

View File

@ -61,6 +61,9 @@ const props = defineProps({
type: Boolean, type: Boolean,
default: false default: false
}, },
uid:{
type: Number
},
members: { members: {
default: () => [] default: () => []
} }
@ -288,7 +291,8 @@ const editor = useEditor({
if (text) { if (text) {
event.preventDefault() event.preventDefault()
const { state, dispatch } = view 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 return true // Handled
} }

View File

@ -75,7 +75,7 @@ const onSendMessage = (data = {}, callBack: any) => {
} }
// //
const onSendTextEvent = throttle((value: any) => { const onSendTextEvent = (value: any) => {
let { data, callBack } = value let { data, callBack } = value
let message = { let message = {
@ -93,7 +93,7 @@ const onSendTextEvent = throttle((value: any) => {
callBack(true) callBack(true)
}) })
}, 1000) }
// //
const onSendImageEvent = ({ data, callBack }) => { const onSendImageEvent = ({ data, callBack }) => {