创建会议修正

This commit is contained in:
2025-12-27 19:23:33 +08:00
parent 50df8495c7
commit 750c112eac
12 changed files with 448 additions and 343 deletions

View File

@@ -66,7 +66,7 @@
</view>
<!-- 会议消息卡片 -->
<view class="message-content meeting-card-wrapper" v-if="msg.messageType === 'meet' && msg.contentExtra">
<MeetingCard :meeting="getMeetingData(msg.contentExtra)" @join="handleJoinMeeting" />
<MeetingCard :meetingId="msg.content" @join="handleJoinMeeting" />
<text class="message-time">{{ formatTime(msg.sendTime) }}</text>
</view>
<!-- 普通消息 -->
@@ -81,7 +81,7 @@
<view class="message-row self-row" v-else>
<!-- 会议消息卡片 -->
<view class="message-content meeting-card-wrapper" v-if="msg.messageType === 'meet' && msg.contentExtra">
<MeetingCard :meeting="getMeetingData(msg.contentExtra)" @join="handleJoinMeeting" />
<MeetingCard :meetingId="msg.content" @join="handleJoinMeeting" />
<text class="message-time">{{ formatTime(msg.sendTime) }}</text>
</view>
<!-- 普通消息 -->
@@ -410,11 +410,13 @@ function formatTime(time?: string): string {
}
// 获取会议数据将contentExtra转换为VideoMeetingVO
function getMeetingData(contentExtra: Record<string, any> | undefined): VideoMeetingVO {
if (!contentExtra) {
return {} as VideoMeetingVO
// 从消息extra中提取meetingId
function getMeetingId(contentExtra: Record<string, any> | undefined): string {
if (!contentExtra || !contentExtra.meetingId) {
console.warn('[chatRoom] contentExtra中没有meetingId:', contentExtra)
return ''
}
return contentExtra as VideoMeetingVO
return contentExtra.meetingId as string
}
// Markdown渲染函数返回富文本HTML
@@ -553,119 +555,20 @@ function handleWorkcaseAction() {
}
// 发起会议 - 跳转到会议创建页面
async function startMeeting() {
// 先检查是否有活跃会议
try {
const res = await workcaseChatAPI.getActiveMeeting(roomId.value)
if (res.success && res.data) {
// 已有活跃会议,直接加入
const meetingPageUrl = res.data.iframeUrl
const meetingId = res.data.meetingId
const meetingName = res.data.meetingName || '视频会议'
// 构建完整的会议URL包含域名和workcase路径
const protocol = window.location.protocol
const host = window.location.host
const fullPath = meetingPageUrl.startsWith('/workcase')
? meetingPageUrl
: '/workcase' + meetingPageUrl
// 附加roomId参数用于离开会议后返回聊天室
const fullMeetingUrl = `${protocol}//${host}${fullPath}&roomId=${roomId.value}`
// 小程序环境:显示提示,引导用户复制链接在浏览器打开
uni.showModal({
title: '视频会议',
content: '微信小程序暂不支持视频会议,请复制链接在浏览器中打开',
confirmText: '复制链接',
cancelText: '取消',
success: (res) => {
if (res.confirm) {
uni.setClipboardData({
data: fullMeetingUrl,
success: () => {
uni.showToast({
title: '链接已复制,请在浏览器中打开',
icon: 'none',
duration: 3000
})
}
})
}
}
})
return
}
} catch (e) {
console.log('[chatRoom] 无活跃会议')
}
// 没有活跃会议,创建新会议
try {
const createRes = await workcaseChatAPI.createMeeting({
roomId: roomId.value,
meetingName: roomName.value || '视频会议'
})
if (createRes.success && createRes.data) {
const meetingId = createRes.data.meetingId
// 开始会议
await workcaseChatAPI.startMeeting(meetingId)
// 加入会议获取会议页面URL
const joinRes = await workcaseChatAPI.joinMeeting(meetingId)
if (joinRes.success && joinRes.data && joinRes.data.iframeUrl) {
const meetingPageUrl = joinRes.data.iframeUrl
// 构建完整的会议URL包含域名和workcase路径
const protocol = window.location.protocol
const host = window.location.host
const fullPath = meetingPageUrl.startsWith('/workcase')
? meetingPageUrl
: '/workcase' + meetingPageUrl
// 附加roomId参数用于离开会议后返回聊天室
const fullMeetingUrl = `${protocol}//${host}${fullPath}&roomId=${roomId.value}`
// 小程序环境:显示提示,引导用户复制链接在浏览器打开
uni.showModal({
title: '会议已创建',
content: '微信小程序暂不支持视频会议,请复制链接在浏览器中打开',
confirmText: '复制链接',
cancelText: '取消',
success: (res) => {
if (res.confirm) {
uni.setClipboardData({
data: fullMeetingUrl,
success: () => {
uni.showToast({
title: '链接已复制,请在浏览器中打开',
icon: 'none',
duration: 3000
})
}
})
}
}
})
} else {
uni.showToast({
title: '获取会议链接失败',
icon: 'none'
})
}
} else {
function startMeeting() {
// 跳转到会议创建页面
const url = `/pages/meeting/meetingCreate/MeetingCreate?roomId=${roomId.value}${workcaseId.value ? '&workcaseId=' + workcaseId.value : ''}`
console.log('[chatRoom] 跳转会议创建页面:', url)
uni.navigateTo({
url: url,
fail: (err) => {
console.error('[chatRoom] 跳转会议创建页面失败:', err)
uni.showToast({
title: createRes.message || '创建会议失败',
title: '跳转失败',
icon: 'none'
})
}
} catch (error) {
console.error('[chatRoom] 创建会议失败:', error)
uni.showToast({
title: '创建会议失败',
icon: 'none'
})
}
})
}
// 加入会议从MeetingCard点击加入
@@ -793,24 +696,25 @@ function disconnectWebSocket() {
// 处理接收到的新消息
function handleNewMessage(message: ChatRoomMessageVO) {
console.log('[chatRoom] 收到新消息:', message)
// 避免重复添加自己发送的消息自己发送的消息已经通过sendMessage添加到列表
if (message.senderId === currentUserId.value) {
console.log('[chatRoom] 跳过自己发送的消息')
// 避免重复添加自己发送的普通消息自己发送的消息已经通过sendMessage添加到列表
// 但会议消息meet类型始终添加因为它是系统生成的通知
if (message.messageType !== 'meet' && message.senderId === currentUserId.value) {
console.log('[chatRoom] 跳过自己发送的普通消息')
return
}
// 检查消息是否已存在(避免重复)
const exists = messages.some(m => m.messageId === message.messageId)
if (exists) {
console.log('[chatRoom] 消息已存在,跳过')
return
}
// 添加新消息到列表
messages.push(message)
nextTick(() => scrollToBottom())
// 可以添加消息提示音或震动
// uni.vibrateShort()
}