no message

This commit is contained in:
kuaifan 2024-01-08 16:29:08 +08:00
parent f42036c104
commit e06fd21a4b
3 changed files with 65 additions and 90 deletions

View File

@ -47,6 +47,7 @@
<!-- 桌面端表情漂浮 --> <!-- 桌面端表情漂浮 -->
<li> <li>
<EPopover <EPopover
ref="emoji"
v-if="!emojiBottom" v-if="!emojiBottom"
v-model="showEmoji" v-model="showEmoji"
:visibleArrow="false" :visibleArrow="false"
@ -77,6 +78,7 @@
<!-- 图片文件 --> <!-- 图片文件 -->
<li> <li>
<EPopover <EPopover
ref="more"
v-model="showMore" v-model="showMore"
:visibleArrow="false" :visibleArrow="false"
placement="top" placement="top"
@ -127,6 +129,7 @@
v-touchmouse="clickSend" v-touchmouse="clickSend"
v-longpress="{callback: onShowMenu, delay: 300}"> v-longpress="{callback: onShowMenu, delay: 300}">
<EPopover <EPopover
ref="menu"
v-model="showMenu" v-model="showMenu"
:visibleArrow="false" :visibleArrow="false"
trigger="manual" trigger="manual"
@ -295,9 +298,6 @@ export default {
emojiQuickKey: '', emojiQuickKey: '',
emojiQuickItems: [], emojiQuickItems: [],
wrapperObserver: null,
wrapperHeight: 0,
recordReady: false, recordReady: false,
recordRec: null, recordRec: null,
recordBlob: null, recordBlob: null,
@ -330,9 +330,6 @@ export default {
mounted() { mounted() {
this.init(); this.init();
// //
this.wrapperObserver = new ResizeObserver(this.onResizeEvent)
this.wrapperObserver.observe(this.$el);
//
this.recordInter = setInterval(_ => { this.recordInter = setInterval(_ => {
if (this.recordState === 'ing') { if (this.recordState === 'ing') {
// //
@ -364,10 +361,6 @@ export default {
if (this.recordRec) { if (this.recordRec) {
this.recordRec = null this.recordRec = null
} }
if (this.wrapperObserver) {
this.wrapperObserver.disconnect()
this.wrapperObserver = null
}
if (this.recordInter) { if (this.recordInter) {
clearInterval(this.recordInter) clearInterval(this.recordInter)
} }
@ -573,7 +566,6 @@ export default {
} else if (this.rangeIndex > 0) { } else if (this.rangeIndex > 0) {
this.quill.setSelection(this.rangeIndex) this.quill.setSelection(this.rangeIndex)
} }
this.$emit('on-emoji-visible-change', val)
}, },
emojiQuickShow(val) { emojiQuickShow(val) {
@ -625,10 +617,6 @@ export default {
this.$emit('on-record-state', state) this.$emit('on-record-state', state)
}, },
wrapperHeight(newVal, oldVal) {
this.$emit('on-height-change', {newVal, oldVal})
},
fullInput(val) { fullInput(val) {
this.quill?.enable(!val) this.quill?.enable(!val)
} }
@ -819,14 +807,6 @@ export default {
} }
}, },
onResizeEvent(entries) {
entries.some(({target, contentRect}) => {
if (target === this.$el) {
this.wrapperHeight = contentRect.height;
}
})
},
quillMention() { quillMention() {
return { return {
allowedChars: /^\S*$/, allowedChars: /^\S*$/,
@ -1660,6 +1640,22 @@ export default {
let value = (content + '').replace(/^(<p>\s*<\/p>)+|(<p>\s*<\/p>)+$/gi, '') let value = (content + '').replace(/^(<p>\s*<\/p>)+|(<p>\s*<\/p>)+$/gi, '')
return value.replace(/^(<p><br\/*><\/p>)+|(<p><br\/*><\/p>)+$/gi, '') return value.replace(/^(<p><br\/*><\/p>)+|(<p><br\/*><\/p>)+$/gi, '')
}, },
updateTools() {
if (this.showEmoji) {
this.$refs.emoji?.updatePopper()
}
if (this.showMore) {
this.$refs.more?.updatePopper()
}
if (this.showMenu) {
this.$refs.menu?.updatePopper()
}
const mention = this.quill?.getModule("mention")
if (mention.isOpen) {
mention.setMentionContainerPosition()
}
}
} }
} }
</script> </script>

View File

@ -153,7 +153,7 @@
</p> </p>
</div> </div>
<div class="dialog-top-message-btn"> <div class="dialog-top-message-btn">
<Loading v-if="topViewPosLoad" type="pure"/> <Loading v-if="topPosLoad" type="pure"/>
<i v-else class="taskfont">&#xee15;</i> <i v-else class="taskfont">&#xee15;</i>
<i class="taskfont" @click.stop="onCancelTop(topMsg)">&#xe6e5;</i> <i class="taskfont" @click.stop="onCancelTop(topMsg)">&#xe6e5;</i>
</div> </div>
@ -250,16 +250,14 @@
:dialog-id="dialogId" :dialog-id="dialogId"
:emoji-bottom="windowPortrait" :emoji-bottom="windowPortrait"
:maxlength="200000" :maxlength="200000"
:placeholder="$L('输入消息...')"
@on-focus="onEventFocus" @on-focus="onEventFocus"
@on-blur="onEventBlur" @on-blur="onEventBlur"
@on-more="onEventMore" @on-more="onEventMore"
@on-file="sendFileMsg" @on-file="sendFileMsg"
@on-send="sendMsg" @on-send="sendMsg"
@on-record="sendRecord" @on-record="sendRecord"
@on-record-state="onRecordState" @on-record-state="onRecordState"/>
@on-emoji-visible-change="onEventEmojiVisibleChange"
@on-height-change="onHeightChange"
:placeholder="$L('输入消息...')"/>
</div> </div>
<!--长按右键--> <!--长按右键-->
@ -670,7 +668,9 @@ export default {
msgNew: 0, msgNew: 0,
msgType: '', msgType: '',
loadIng: 0, loadIng: 0,
isFocus: false,
focusLazy: false,
focusTimer: null,
allMsgs: [], allMsgs: [],
tempMsgs: [], tempMsgs: [],
@ -725,6 +725,7 @@ export default {
scrollOffset: 0, scrollOffset: 0,
scrollTail: 0, scrollTail: 0,
scrollerHeight: 0,
preventMoreLoad: false, preventMoreLoad: false,
preventToBottom: false, preventToBottom: false,
@ -763,6 +764,7 @@ export default {
observers: [], observers: [],
unreadMsgId: 0, // id unreadMsgId: 0, // id
topPosLoad: false, //
positionLoad: 0, // positionLoad: 0, //
positionShow: false, // positionShow: false, //
renderMsgNum: 0, // renderMsgNum: 0, //
@ -771,8 +773,7 @@ export default {
listPreparedStatus: false, // listPreparedStatus: false, //
selectedTextStatus: false, // selectedTextStatus: false, //
scrollToBottomAndRefresh: false, // scrollToBottomAndRefresh: false, //
androidKeyboardVisible: false, // Android
topViewPosLoad: false, //
} }
}, },
@ -991,9 +992,9 @@ export default {
return []; return [];
}, },
footerPaddingBottom({keyboardType, keyboardHeight, safeAreaBottom, windowScrollY, isMessenger, isFocus}) { footerPaddingBottom({keyboardType, keyboardHeight, safeAreaBottom, windowScrollY, isMessenger, focusLazy}) {
if (windowScrollY === 0 if (windowScrollY === 0
&& isFocus && focusLazy
&& isMessenger && isMessenger
&& keyboardType === "show" && keyboardType === "show"
&& keyboardHeight > 0 && keyboardHeight > 0
@ -1335,19 +1336,13 @@ export default {
const tmpList = newList.filter(item => item.id && item.id > lastId) const tmpList = newList.filter(item => item.id && item.id > lastId)
this.msgNew += tmpList.length this.msgNew += tmpList.length
} else { } else {
if (!this.preventToBottom) { !this.preventToBottom && this.$nextTick(this.onToBottom)
this.$nextTick(this.onToBottom)
}
} }
}, },
windowScrollY(val) { windowScrollY(val) {
if ($A.isIos() && !this.$slots.head) { if ($A.isIos() && !this.$slots.head) {
const {tail} = this.scrollInfo();
this.$refs.nav.style.marginTop = `${val}px` this.$refs.nav.style.marginTop = `${val}px`
if (tail <= 55) {
requestAnimationFrame(this.onToBottom)
}
} }
}, },
@ -1360,16 +1355,8 @@ export default {
} }
}, },
windowHeight(current, before) { windowHeight() {
if (current < before this.androidKeyboardVisible = $A.isAndroid() && $A.eeuiAppKeyboardStatus()
&& $A.isEEUiApp
&& $A.isAndroid()
&& this.isFocus) {
const {tail} = this.scrollInfo();
if (tail <= 55 + (before - current)) {
requestAnimationFrame(this.onToBottom)
}
}
}, },
dialogDrag(val) { dialogDrag(val) {
@ -1386,7 +1373,10 @@ export default {
footerPaddingBottom(val) { footerPaddingBottom(val) {
this.$refs.footer.style.paddingBottom = `${val}px`; this.$refs.footer.style.paddingBottom = `${val}px`;
requestAnimationFrame(this.onFooterResize) requestAnimationFrame(_ => {
this.$refs.input.updateTools()
this.onFooterResize()
})
}, },
readLoadNum() { readLoadNum() {
@ -1820,10 +1810,10 @@ export default {
}, },
chatDragOver(show, e) { chatDragOver(show, e) {
let random = (this.__dialogDrag = $A.randomString(8)); let random = (this.__dialog_drag = $A.randomString(8));
if (!show) { if (!show) {
setTimeout(() => { setTimeout(() => {
if (random === this.__dialogDrag) { if (random === this.__dialog_drag) {
this.dialogDrag = show; this.dialogDrag = show;
} }
}, 150); }, 150);
@ -1977,12 +1967,13 @@ export default {
}, },
onEventFocus() { onEventFocus() {
this.isFocus = true this.focusTimer && clearTimeout(this.focusTimer)
this.focusLazy = true
this.$emit("on-focus") this.$emit("on-focus")
}, },
onEventBlur() { onEventBlur() {
this.isFocus = false this.focusTimer = setTimeout(_ => this.focusLazy = false, 10)
this.$emit("on-blur") this.$emit("on-blur")
}, },
@ -2063,29 +2054,12 @@ export default {
}); });
}, },
onEventEmojiVisibleChange(val) {
if (val && this.windowPortrait) {
this.onToBottom();
}
},
onHeightChange({newVal, oldVal}) {
this.onFooterResize();
const diff = newVal - oldVal;
if (diff !== 0) {
const {offset, tail} = this.scrollInfo()
if (tail > 0) {
this.onToOffset(offset + diff)
}
}
},
onResizeEvent(entries) { onResizeEvent(entries) {
entries.some(({target}) => { entries.some(({target, contentRect}) => {
if (target === this.$refs.footer) { if (target === this.$refs.footer) {
this.onFooterResize() this.onFooterResize()
} else if (target === this.$refs.scroller?.$el) { } else if (target === this.$refs.scroller?.$el) {
this.onScrollerResize() this.onScrollerResize(contentRect)
} }
}) })
}, },
@ -2101,14 +2075,17 @@ export default {
} }
}, },
onScrollerResize() { onScrollerResize({height}) {
if (!this.$refs.scroller) { if (this.scrollerHeight > 0) {
return const diff = this.scrollerHeight - height;
if (diff !== 0) {
const {offset, tail} = this.scrollInfo()
if (tail > 0) {
this.onToOffset(offset + diff)
} }
const {tail} = this.scrollInfo();
if (tail <= 55) {
requestAnimationFrame(this.onToBottom)
} }
}
this.scrollerHeight = height;
}, },
onActive() { onActive() {
@ -2149,13 +2126,13 @@ export default {
return false return false
} }
if (recovery) { if (recovery) {
if (this.__markOffset === undefined) { if (this.__mark_offset === undefined) {
return false return false
} }
this.onToOffset(scroller.getScrollSize() - scroller.getClientSize() - this.__markOffset) this.onToOffset(scroller.getScrollSize() - scroller.getClientSize() - this.__mark_offset)
this.__markOffset = undefined this.__mark_offset = undefined
} else { } else {
this.__markOffset = scroller.getScrollSize() - scroller.getClientSize() - scroller.getOffset() this.__mark_offset = scroller.getScrollSize() - scroller.getClientSize() - scroller.getOffset()
} }
return true return true
}, },
@ -2251,9 +2228,7 @@ export default {
this.renderMsgNum = 0 this.renderMsgNum = 0
this.onFooterResize() this.onFooterResize()
!this.onMarkOffset(true) && this.onToBottom() !this.onMarkOffset(true) && this.onToBottom()
} } else if (this.renderMsgSizes.has(id)
//
if (this.renderMsgSizes.has(id)
&& size > this.renderMsgSizes.get(id) && size > this.renderMsgSizes.get(id)
&& size - this.renderMsgSizes.get(id) === this.scrollInfo().tail) { && size - this.renderMsgSizes.get(id) === this.scrollInfo().tail) {
this.onToBottom() this.onToBottom()
@ -3424,9 +3399,9 @@ export default {
if (!this.topMsg) { if (!this.topMsg) {
return return
} }
this.topViewPosLoad = true this.topPosLoad = true
this.onPositionId(this.topMsg.id).finally(_ => { this.onPositionId(this.topMsg.id).finally(_ => {
this.topViewPosLoad = false this.topPosLoad = false
}) })
}, },

View File

@ -1615,6 +1615,10 @@
right: unset; right: unset;
transform: unset; transform: unset;
border: none; border: none;
box-shadow: none;
display: flex;
justify-content: center;
align-items: center;
} }
} }