im连接失败提示

This commit is contained in:
2026-02-26 16:29:11 +08:00
parent 35f08b0c99
commit e1e4c8f531
4 changed files with 48 additions and 9 deletions

View File

@@ -25,9 +25,10 @@ import Mine from './Mine.vue'
import { initPkGoEasy, goEasyLink, goEasyDisConnect } from '@/utils/pk-mini/goeasy'
import { getOtp } from '@/api/pk-mini'
import { getMainUserData } from '@/utils/pk-mini/storage'
import { ElMessage } from 'element-plus'
import { ElMessage, ElNotification } from 'element-plus'
const activeTab = ref('pk')
let reconnectNotification = null
const componentMap = {
pk: PkHall,
@@ -59,10 +60,32 @@ async function autoLinkIM() {
key: otp
}
await goEasyLink(data)
await goEasyLink({
...data,
onProgress: () => {
if (!reconnectNotification) {
reconnectNotification = ElNotification({
title: 'IM 重连中',
message: '聊天系统正在重新连接,请稍候...',
type: 'warning',
duration: 0
})
}
},
onSuccess: () => {
if (reconnectNotification) {
reconnectNotification.close()
reconnectNotification = null
}
}
})
console.log('PK Mini: IM 连接成功')
} catch (err) {
console.error('PK Mini: IM 连接失败', err)
if (reconnectNotification) {
reconnectNotification.close()
reconnectNotification = null
}
ElMessage.warning('PK工作台聊天系统连接失败')
}
}
@@ -77,6 +100,11 @@ onMounted(() => {
onUnmounted(() => {
// 断开 IM 连接
goEasyDisConnect().catch(() => {})
// 清理重连通知
if (reconnectNotification) {
reconnectNotification.close()
reconnectNotification = null
}
})
</script>