处理@显示、链接跳转、免打扰数量统计等问题
Some checks are pending
Check / lint (push) Waiting to run
Check / typecheck (push) Waiting to run
Check / build (build, 18.x, ubuntu-latest) (push) Waiting to run
Check / build (build, 18.x, windows-latest) (push) Waiting to run
Check / build (build:app, 18.x, ubuntu-latest) (push) Waiting to run
Check / build (build:app, 18.x, windows-latest) (push) Waiting to run
Check / build (build:mp-weixin, 18.x, ubuntu-latest) (push) Waiting to run
Check / build (build:mp-weixin, 18.x, windows-latest) (push) Waiting to run

This commit is contained in:
wangyifeng 2025-03-26 14:30:20 +08:00
parent 3642d3e2fa
commit 1f4c5ba6df
6 changed files with 85 additions and 19 deletions

View File

@ -1,5 +1,9 @@
import request from '@/service/index.js'
import qs from 'qs'
import {
useTalkStore,
useDialogueStore
} from '@/store'
// 获取聊天列表服务接口
export const ServeGetTalkList = (data) => {
@ -40,22 +44,24 @@ export const ServeTopTalkList = (data) => {
// 清除聊天消息未读数服务接口
export const ServeClearTalkUnreadNum = (data, unReadNum) => {
console.log('=======chatApp==UnreadNum', unReadNum)
if (typeof plus !== 'undefined') {
let OAWebView = plus.webview.all()
OAWebView.forEach((webview) => {
if (webview.id === 'webviewId1') {
webview.evalJS(`updateUnreadMsgNumReduce('${unReadNum}')`)
}
})
} else {
document.addEventListener('plusready', () => {
if(!useTalkStore().items[useTalkStore().findTalkIndex(useDialogueStore().index_name)].is_disturb){
if (typeof plus !== 'undefined') {
let OAWebView = plus.webview.all()
OAWebView.forEach((webview) => {
if (webview.id === 'webviewId1') {
webview.evalJS(`updateUnreadMsgNumReduce('${unReadNum}')`)
}
})
})
} else {
document.addEventListener('plusready', () => {
let OAWebView = plus.webview.all()
OAWebView.forEach((webview) => {
if (webview.id === 'webviewId1') {
webview.evalJS(`updateUnreadMsgNumReduce('${unReadNum}')`)
}
})
})
}
}
return request({
url: '/api/v1/talk/unread/clear',

View File

@ -15,7 +15,7 @@ const float = props.data.float
const textContent = computed(() => {
let text = props.extra?.content || ''
text = textReplaceLink(text)
// text = textReplaceLink(text)
if (props.data.talk_type == 2) {
text = textReplaceMention(text, '#1890ff')
}

View File

@ -307,6 +307,19 @@ class Talk extends Base {
msg_text: this.getTalkText(),
updated_at: parseTime(new Date()),
})
//收到新消息时,同时判断是否有人@我
if (
this.resource.msg_type === 1 &&
this.resource?.extra?.mentions?.length > 0
) {
const findMention = this.resource?.extra?.mentions?.find(
(mention) => mention === this.getAccountId(),
)
//有人@我,则更新会话列表
if (findMention) {
useTalkStore().loadTalkList()
}
}
if (this.resource.msg_type == 1116) {
// 更新会话列表中的会话信息
const dialogue = useDialogueListStore().getDialogueList(

View File

@ -139,6 +139,9 @@ const photoActionsSelect = (index) => {
filter: 'image',
maximum: 9,
multiple: true,
onmaxed: () => {
plus.nativeUI.toast('最多只能选择9张图片')
},
},
)
}

View File

@ -568,6 +568,10 @@ const state = ref({
lastCursorIndex: undefined, //
mentionUserIds: [], //@ID
isInsertingMention: false, //mention
showMentionSelectTimer: null, //
lastMentionText: '', // @
lastMentionTriggered: false, // @
lastMentionPosition: -1, // @
})
uniOnload(async (options) => {
@ -595,10 +599,13 @@ uniOnload(async (options) => {
})
uniOnUnload(() => {
console.log('onUnload')
ServeClearTalkUnreadNum({
talk_type: Number(talkParams.type),
receiver_id: Number(talkParams.receiver_id),
},talkParams.unReadNum).then(() => {
ServeClearTalkUnreadNum(
{
talk_type: Number(talkParams.type),
receiver_id: Number(talkParams.receiver_id),
},
talkParams.unReadNum,
).then(() => {
talkStore.updateItem({
index_name: talkParams.index_name,
unread_num: 0,
@ -624,6 +631,8 @@ const handleHidePanel = () => {
//
const onEditorClick = () => {
handleHidePanel()
const quill = getQuill()
quill.focus()
}
const onSendMessage = (data = {}, callBack) => {
@ -889,9 +898,9 @@ const editorOption = {
if (range) {
state.value.lastCursorIndex = range.index
}
state.value.isShowMentionSelect = true
//
quill.blur()
// 使
showMentionSelectDebounced(quill)
},
mentionContainerClass: '',
},
@ -1600,7 +1609,42 @@ onUnmounted(() => {
if (avatarPressTimer) {
clearTimeout(avatarPressTimer)
}
//
if (state.value.showMentionSelectTimer) {
clearTimeout(state.value.showMentionSelectTimer)
}
})
//
const showMentionSelectDebounced = (quill) => {
const text = quill.getText()
//
console.log(
'lastMentionText',
state.value.lastMentionText,
state.value.lastMentionText.length,
)
console.log('text', text, text.length)
console.log(state.value.lastMentionTriggered)
if (text !== state.value.lastMentionText) {
state.value.lastMentionTriggered = false
}
if (text.length === 2) {
state.value.lastMentionText = text
state.value.lastMentionTriggered = true
state.value.isShowMentionSelect = true
}
//
if (state.value.lastMentionTriggered) {
return
}
//
state.value.lastMentionText = text
state.value.lastMentionTriggered = true
state.value.isShowMentionSelect = true
quill.blur()
}
</script>
<style scoped lang="less">
.dialog-page {

View File

@ -128,7 +128,7 @@ export const useDialogueStore = defineStore('dialogue', {
this.unreadNum = data?.unread_num || 0
this.members = []
if (data.talk_type == 2) {
if (data.talk_type == 2 && !data.is_dismiss && !data.is_quit) {
this.updateGroupMembers()
}
},