修改@功能问题;新增IOS版本号判断使用哪个输入框;处理聊天记录加载问题
This commit is contained in:
parent
bbb5dd99fc
commit
df1cc68b59
@ -337,13 +337,17 @@
|
||||
</div>
|
||||
</div>
|
||||
<div v-if="state.isOpenEmojiPanel" class="mt-[50rpx]">
|
||||
<emojiPanel @on-select="(data) => {
|
||||
if (!state.canUseQuillEditor) {
|
||||
onTextAreaEmoticon(data)
|
||||
} else {
|
||||
onEmoticonEvent(data)
|
||||
}
|
||||
}" />
|
||||
<emojiPanel
|
||||
@on-select="
|
||||
(data) => {
|
||||
if (!state.canUseQuillEditor) {
|
||||
onTextAreaEmoticon(data)
|
||||
} else {
|
||||
onEmoticonEvent(data)
|
||||
}
|
||||
}
|
||||
"
|
||||
/>
|
||||
</div>
|
||||
<div v-if="state.isOpenFilePanel" class="mt-[16rpx]">
|
||||
<filePanel
|
||||
@ -753,19 +757,23 @@ const onTextAreaChange = (value) => {
|
||||
// 更新mentionUserIds数组,确保与输入框中的@内容一致
|
||||
const atPattern = /@([^@\s]+)(?:\s|$)/g
|
||||
const matches = Array.from(value.matchAll(atPattern))
|
||||
const mentionedUsers = matches.map(match => match[1].trim().toLowerCase())
|
||||
const mentionedUsers = matches.map((match) => match[1].trim().toLowerCase())
|
||||
|
||||
// 获取当前对话中的所有成员信息
|
||||
const members = dialogueStore.members || []
|
||||
|
||||
// 根据@的用户名找到对应的user_id
|
||||
const newMentionUserIds = mentionedUsers.map(username => {
|
||||
if (username === '所有人') {
|
||||
return 0 // 如果是@所有人,返回0
|
||||
}
|
||||
const member = members.find(m => m.nickname.trim().toLowerCase() === username)
|
||||
return member ? member.id : null
|
||||
}).filter(id => id !== null)
|
||||
const newMentionUserIds = mentionedUsers
|
||||
.map((username) => {
|
||||
if (username === '所有人') {
|
||||
return 0 // 如果是@所有人,返回0
|
||||
}
|
||||
const member = members.find(
|
||||
(m) => m.nickname.trim().toLowerCase() === username,
|
||||
)
|
||||
return member ? member.id : null
|
||||
})
|
||||
.filter((id) => id !== null)
|
||||
|
||||
// 只有在输入框中有@内容时才更新mentionUserIds
|
||||
if (value.includes('@')) {
|
||||
@ -778,9 +786,9 @@ const onTextAreaChange = (value) => {
|
||||
// 处理输入框输入事件
|
||||
const onTextAreaInput = (value) => {
|
||||
console.log(value, 'value')
|
||||
if(value.length > 0){
|
||||
if(value[value.length - 1] === '@'){
|
||||
if(talkParams.type === 1){
|
||||
if (value.length > 0) {
|
||||
if (value[value.length - 1] === '@') {
|
||||
if (talkParams.type === 1) {
|
||||
return
|
||||
}
|
||||
state.value.isShowMentionSelect = true
|
||||
@ -965,8 +973,46 @@ const onEmoticonEvent = (data) => {
|
||||
emit('editor-event', fn)
|
||||
}
|
||||
}
|
||||
|
||||
let calcDelta = false
|
||||
const onEditorChange = () => {
|
||||
if(calcDelta){
|
||||
calcDelta = false
|
||||
return
|
||||
}
|
||||
// 以下逻辑是 光标与@之间存在其他内容时 不触发选人弹窗
|
||||
const qtext = getQuill().getText()
|
||||
let selectIdx = getQuill().getSelection().index
|
||||
const textBeforeCursor = qtext.substring(0, selectIdx)
|
||||
if (textBeforeCursor[0]?.charCodeAt(0) === 10) {
|
||||
const delta = getQuill().getContents()
|
||||
const ops = delta.ops || []
|
||||
if (ops[0].insert === '\n') {
|
||||
ops.splice(0, 1)
|
||||
getQuill().setContents(delta)
|
||||
getQuill().setSelection(getQuill().getText().length, 0)
|
||||
}
|
||||
// for (let i = 0; i < ops.length; i++) {
|
||||
// if (ops[i].insert === '\n') {
|
||||
// console.error('有空格')
|
||||
// ops.splice(i, 1)
|
||||
// calcDelta = true
|
||||
// }
|
||||
// }
|
||||
// getQuill().setContents(delta)
|
||||
// getQuill().setSelection(getQuill().getText().length, 0)
|
||||
}
|
||||
let endWithAt = false
|
||||
if (
|
||||
textBeforeCursor[textBeforeCursor.length - 1] === '@' ||
|
||||
textBeforeCursor[textBeforeCursor.length - 2]?.charCodeAt(0) === 64
|
||||
) {
|
||||
endWithAt = true
|
||||
}
|
||||
if (endWithAt) {
|
||||
state.value.cursorMention = true
|
||||
} else {
|
||||
state.value.cursorMention = false
|
||||
}
|
||||
if (getQuill().getText() !== state.value.lastMentionText) {
|
||||
state.value.lastMentionTriggered = false
|
||||
}
|
||||
@ -1436,6 +1482,11 @@ const clearMultiSelect = () => {
|
||||
|
||||
const initData = async () => {
|
||||
const dialogueList = getDialogueList(talkParams.index_name)
|
||||
let doLocalPaging = false
|
||||
if(dialogueList?.records?.length > 0){
|
||||
doLocalPaging = true
|
||||
}
|
||||
console.error('dialogueList', dialogueList)
|
||||
|
||||
let objT = {
|
||||
uid: talkParams.uid,
|
||||
@ -1446,7 +1497,9 @@ const initData = async () => {
|
||||
no_limit: dialogueList ? 1 : 0,
|
||||
}
|
||||
await onLoad({ ...objT })
|
||||
zpagingRef.value?.setLocalPaging(records.value)
|
||||
if(doLocalPaging){
|
||||
zpagingRef.value?.setLocalPaging(dialogueList.records)
|
||||
}
|
||||
}
|
||||
|
||||
//点击跳转到聊天设置页面
|
||||
@ -1505,9 +1558,9 @@ const getSelectResult = (mentionSelect) => {
|
||||
|
||||
//处理要提醒人的消息样式
|
||||
const getMentionSelectLists = (mentionSelectList) => {
|
||||
if(!state.value.canUseQuillEditor){
|
||||
if(mentionSelectList.length > 0){
|
||||
mentionSelectList.forEach(item => {
|
||||
if (!state.value.canUseQuillEditor) {
|
||||
if (mentionSelectList.length > 0) {
|
||||
mentionSelectList.forEach((item) => {
|
||||
onTextAreaMention(item)
|
||||
})
|
||||
}
|
||||
@ -1763,6 +1816,13 @@ const handleAvatarTouchEnd = () => {
|
||||
}
|
||||
|
||||
onMounted(async () => {
|
||||
if (uni.getSystemInfoSync().osName === 'ios') {
|
||||
let versions = uni.getSystemInfoSync().osVersion.split('.')
|
||||
if (Number(versions[0]) < 17) {
|
||||
console.error('ios版本低于17')
|
||||
state.value.canUseQuillEditor = false
|
||||
}
|
||||
}
|
||||
if (typeof plus !== 'undefined') {
|
||||
const webview = plus.webview.currentWebview()
|
||||
webview.setStyle({
|
||||
@ -1818,23 +1878,9 @@ onUnmounted(() => {
|
||||
// 修改防抖函数的实现
|
||||
const showMentionSelectDebounced = (quill) => {
|
||||
const text = quill.getText()
|
||||
|
||||
// 以下逻辑是 光标与@之间存在其他内容时 不触发选人弹窗
|
||||
const selection = quill.getSelection()
|
||||
if (selection) {
|
||||
state.lastSelection = selection.index
|
||||
if (
|
||||
text[selection.index - 1].charCodeAt(0) !== 64 &&
|
||||
text[selection.index - 1].charCodeAt(0) !== 32 &&
|
||||
text[selection.index - 1].charCodeAt(0) !== 10
|
||||
) {
|
||||
uni.showToast({
|
||||
title: text[selection.index - 1],
|
||||
icon: 'none',
|
||||
})
|
||||
state.value.lastMentionTriggered = false
|
||||
return
|
||||
}
|
||||
// 光标不在@后第一位时,不触发选人弹窗
|
||||
if (!state.value.cursorMention) {
|
||||
return
|
||||
}
|
||||
// 以下逻辑是 记录触发@时,用户的输入框内容,下次一样内容得@不会再次触发
|
||||
if (text !== state.value.lastMentionText) {
|
||||
@ -1870,14 +1916,23 @@ const onTextAreaMention = (user) => {
|
||||
if (talkParams.type === 1) {
|
||||
return
|
||||
}
|
||||
if(state.value.textAreaValue.length > 0){
|
||||
if(state.value.textAreaValue[state.value.textAreaValue.length - 1] === '@'){
|
||||
if (state.value.textAreaValue.length > 0) {
|
||||
if (
|
||||
state.value.textAreaValue[state.value.textAreaValue.length - 1] === '@'
|
||||
) {
|
||||
state.value.textAreaValue = state.value.textAreaValue.slice(0, -1)
|
||||
}
|
||||
}
|
||||
state.value.textAreaValue += `@${user.nickname} `
|
||||
state.value.mentionUserIds.push(user.user_id)
|
||||
if(state.value.isShowMentionSelect){
|
||||
|
||||
// 先创建新数组,再赋值
|
||||
const newMentionUserIds = state.value.mentionUserIds
|
||||
? [...state.value.mentionUserIds]
|
||||
: []
|
||||
newMentionUserIds.push(user.nickname === '所有人' ? 0 : user.id)
|
||||
state.value.mentionUserIds = newMentionUserIds
|
||||
|
||||
if (state.value.isShowMentionSelect) {
|
||||
state.value.isShowMentionSelect = false
|
||||
}
|
||||
}
|
||||
|
@ -23,7 +23,7 @@ class WsSocket {
|
||||
lockReconnect: false,
|
||||
setTimeout: null, // 计时器对象
|
||||
time: 3000, // 重连间隔时间
|
||||
number: 10000000 // 重连次数
|
||||
number: 20 // 重连次数
|
||||
}
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user