处理聊天未读消息数量统计、应用角标、视频预览、切换账号清除缓存问题
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-29 17:15:19 +08:00
parent 99ffb6ec05
commit 6140c625e4
6 changed files with 139 additions and 35 deletions

View File

@ -1,10 +1,11 @@
<script setup> <script setup>
import { useStatus } from '@/store/status' import { useStatus } from '@/store/status'
import { useUserStore } from '@/store' import { useUserStore, useDialogueListStore } from '@/store'
import { useProvideUserModal } from '@/hooks' import { useProvideUserModal } from '@/hooks'
import {useAuth} from "@/store/auth"; import {useAuth} from "@/store/auth";
const {token} = useAuth() const {token} = useAuth()
import ws from '@/connect' import ws from '@/connect'
import {uniStorage} from "@/utils/uniStorage.js"
const { statusBarHeight } = useStatus() const { statusBarHeight } = useStatus()
const { uid, isShow } = useProvideUserModal() const { uid, isShow } = useProvideUserModal()
const userStore = useUserStore() const userStore = useUserStore()
@ -19,6 +20,10 @@ const handleWebview = () => {
// }) // })
console.log("webview", webview) console.log("webview", webview)
token.value = webview.token token.value = webview.token
if(webview?.doClearDialogueList){
useDialogueListStore().dialogueList.value = []
uniStorage.removeItem('dialogueList')
}
userStore.loadSetting() userStore.loadSetting()
ws.connect() ws.connect()
} }

View File

@ -77,10 +77,19 @@ const canplay = (e) => {
}; };
async function onPlay() { async function onPlay() {
videoContext.value = uni.createVideoContext(props.extra.url, instance);
videoContext.value.requestFullScreen({ direction: 2 });
videoContext.value.play()
open.value = true open.value = true
await nextTick()
videoContext.value = uni.createVideoContext(props.extra.url, instance)
setTimeout(() => {
//
videoContext.value.requestFullScreen({ direction: 2 })
//
setTimeout(() => {
videoContext.value.play()
}, 100)
}, 200)
} }
onMounted(() => { onMounted(() => {
videoRef.value = uni.createVideoContext(props.data.msg_id); videoRef.value = uni.createVideoContext(props.data.msg_id);
@ -132,11 +141,22 @@ onMounted(() => {
:percent="props.data.uploadCurrent"> :percent="props.data.uploadCurrent">
</tm-progress> --> </tm-progress> -->
</div> </div>
<div v-show="open">
<video :src="props.extra.url" controls @fullscreenchange="fullscreenchange" :id="props.extra.url">
</video>
</div>
</section> </section>
<teleport to="body">
<div v-show="open" class="video-container">
<video
:src="props.extra.url"
controls
@fullscreenchange="fullscreenchange"
:id="props.extra.url"
playsinline
webkit-playsinline
x5-playsinline
class="fullscreen-video"
></video>
</div>
</teleport>
</template> </template>
<style lang="less" scoped> <style lang="less" scoped>
.im-message-video { .im-message-video {
@ -206,4 +226,23 @@ onMounted(() => {
width: 80rpx !important; width: 80rpx !important;
height: 80rpx !important; height: 80rpx !important;
} }
.video-container {
position: fixed;
top: 0;
left: 0;
width: 100vw;
height: 100vh;
background: #000;
z-index: 9999;
display: flex;
align-items: center;
justify-content: center;
}
.fullscreen-video {
width: 100%;
height: 100%;
object-fit: contain;
}
</style> </style>

View File

@ -211,8 +211,8 @@ class Talk extends Base {
}).then(async ({ code, data }) => { }).then(async ({ code, data }) => {
if (code == 200) { if (code == 200) {
let item = formatTalkItem(data) let item = formatTalkItem(data)
item.unread_num = 1
if (!item?.is_disturb) { if (!item?.is_disturb) {
item.unread_num = 1
this.updateUnreadMsgNumAdd() this.updateUnreadMsgNumAdd()
} }
useTalkStore().addItem(item) useTalkStore().addItem(item)

View File

@ -17,7 +17,9 @@ import { ServeSeachQueryAll, ServeGetSessionId } from '@/api/search/index'
import { onMounted } from 'vue' import { onMounted } from 'vue'
import { handleSetWebviewStyle } from '@/utils/common' import { handleSetWebviewStyle } from '@/utils/common'
import { useDialogueStore } from '@/store' import { useDialogueStore, useTalkStore } from '@/store'
import { ServeCreateTalkList } from '@/api/chat/index.js'
import { formatTalkItem } from '@/utils/talk'
const dialogueStore = useDialogueStore() const dialogueStore = useDialogueStore()
@ -50,6 +52,18 @@ const clickSearchItem = async (
console.log(talk_type, receiver_id) console.log(talk_type, receiver_id)
const sessionId = await getSessionId(talk_type, receiver_id) const sessionId = await getSessionId(talk_type, receiver_id)
if (searchResultKey === 'user_infos') { if (searchResultKey === 'user_infos') {
if (useTalkStore().findTalkIndex(`${talk_type}_${receiver_id}`) === -1) {
ServeCreateTalkList({
talk_type,
receiver_id,
erp_user_id: result.erp_user_id,
}).then(async ({ code, data }) => {
if (code == 200) {
let item = formatTalkItem(data)
useTalkStore().addItem(item)
}
})
}
dialogueStore.setDialogue({ dialogueStore.setDialogue({
name: result.nickname, name: result.nickname,
talk_type: 1, talk_type: 1,
@ -65,7 +79,7 @@ const clickSearchItem = async (
receiver_id: result.group_id || result.id, receiver_id: result.group_id || result.id,
}) })
uni.navigateTo({ uni.navigateTo({
url: '/pages/dialog/index?sessionId=' + sessionId url: '/pages/dialog/index?sessionId=' + sessionId,
}) })
} else if (searchResultKey === 'general_infos') { } else if (searchResultKey === 'general_infos') {
uni.navigateTo({ uni.navigateTo({

View File

@ -25,7 +25,9 @@ import {
} from '@/api/search/index' } from '@/api/search/index'
import { reactive } from 'vue' import { reactive } from 'vue'
import { useDialogueStore } from '@/store' import { useDialogueStore, useTalkStore } from '@/store'
import { ServeCreateTalkList } from '@/api/chat/index.js'
import { formatTalkItem } from '@/utils/talk'
const dialogueStore = useDialogueStore() const dialogueStore = useDialogueStore()
@ -75,7 +77,13 @@ onLoad((options) => {
}) })
//id //id
const lastIdChange = (last_id, last_group_id, last_member_id, last_receiver_user_name, last_receiver_group_name) => { const lastIdChange = (
last_id,
last_group_id,
last_member_id,
last_receiver_user_name,
last_receiver_group_name,
) => {
let idChanges = { let idChanges = {
last_id, last_id,
last_group_id, last_group_id,
@ -108,6 +116,18 @@ const clickSearchItem = async (
console.log(talk_type, receiver_id) console.log(talk_type, receiver_id)
const sessionId = await getSessionId(talk_type, receiver_id) const sessionId = await getSessionId(talk_type, receiver_id)
if (state.searchResultKey === 'user_infos') { if (state.searchResultKey === 'user_infos') {
if (useTalkStore().findTalkIndex(`${talk_type}_${receiver_id}`) === -1) {
ServeCreateTalkList({
talk_type,
receiver_id,
erp_user_id: result.erp_user_id,
}).then(async ({ code, data }) => {
if (code == 200) {
let item = formatTalkItem(data)
useTalkStore().addItem(item)
}
})
}
dialogueStore.setDialogue({ dialogueStore.setDialogue({
name: result.nickname, name: result.nickname,
talk_type: 1, talk_type: 1,

View File

@ -168,7 +168,10 @@
/> />
</template> </template>
<template v-else-if="item?.msg_type === 5"> <template v-else-if="item?.msg_type === 5">
<div class="video-preview" @click="onPlay(item?.extra?.url)"> <div
class="video-preview"
@click="onPlay(item?.extra?.url)"
>
<tm-image <tm-image
:src="item?.extra?.cover" :src="item?.extra?.cover"
model="aspectFill" model="aspectFill"
@ -264,18 +267,20 @@
</div> </div>
</div> </div>
</ZPaging> </ZPaging>
<div v-show="open"> <teleport to="body">
<video <div v-show="open" class="video-container">
:src="currentVideoUrl" <video
controls :src="currentVideoUrl"
@fullscreenchange="fullscreenchange" controls
:id="currentVideoUrl" @fullscreenchange="fullscreenchange"
playsinline :id="currentVideoUrl"
webkit-playsinline playsinline
x5-playsinline webkit-playsinline
> x5-playsinline
</video> class="fullscreen-video"
</div> ></video>
</div>
</teleport>
</div> </div>
</div> </div>
</template> </template>
@ -285,7 +290,7 @@ import fileType_EXCEL from '@/static/image/search/fileType_EXCEL.png'
import fileType_WORD from '@/static/image/search/fileType_WORD.png' import fileType_WORD from '@/static/image/search/fileType_WORD.png'
import fileType_PDF from '@/static/image/search/fileType_PDF.png' import fileType_PDF from '@/static/image/search/fileType_PDF.png'
import fileType_Files from '@/static/image/search/fileType_Files.png' import fileType_Files from '@/static/image/search/fileType_Files.png'
import playCircle from "@/static/image/chatList/playCircle@2x.png" import playCircle from '@/static/image/chatList/playCircle@2x.png'
import { fileFormatSize, fileSuffix } from '@/utils/strings' import { fileFormatSize, fileSuffix } from '@/utils/strings'
import searchItem from '../components/searchItem.vue' import searchItem from '../components/searchItem.vue'
import customInput from '@/components/custom-input/custom-input.vue' import customInput from '@/components/custom-input/custom-input.vue'
@ -353,13 +358,15 @@ async function onPlay(url) {
// //
videoContext.value = uni.createVideoContext(url, getCurrentInstance()) videoContext.value = uni.createVideoContext(url, getCurrentInstance())
//
videoContext.value.requestFullScreen({ direction: 2 })
//
setTimeout(() => { setTimeout(() => {
videoContext.value.play() //
}, 100) videoContext.value.requestFullScreen({ direction: 2 })
//
setTimeout(() => {
videoContext.value.play()
}, 100)
}, 200)
} }
onLoad((options) => { onLoad((options) => {
@ -561,7 +568,7 @@ const cancelSearch = () => {
}) })
} else { } else {
uni.reLaunch({ uni.reLaunch({
url: '/pages/index/index' url: '/pages/index/index',
}) })
} }
} }
@ -904,7 +911,7 @@ body::v-deep .round-3 {
align-items: center; align-items: center;
justify-content: center; justify-content: center;
img{ img {
width: 80rpx !important; width: 80rpx !important;
height: 80rpx !important; height: 80rpx !important;
} }
@ -918,4 +925,23 @@ body::v-deep .round-3 {
} }
} }
} }
.video-container {
position: fixed;
top: 0;
left: 0;
width: 100vw;
height: 100vh;
background: #000;
z-index: 9999;
display: flex;
align-items: center;
justify-content: center;
}
.fullscreen-video {
width: 100%;
height: 100%;
object-fit: contain;
}
</style> </style>