|
@@ -41,7 +41,7 @@
|
|
|
|
|
|
<!-- 图片消息 -->
|
|
<!-- 图片消息 -->
|
|
<div
|
|
<div
|
|
- class="content"
|
|
|
|
|
|
+ class="img-message"
|
|
v-else-if="item.contentType === MSG_TYPE.IMAGE"
|
|
v-else-if="item.contentType === MSG_TYPE.IMAGE"
|
|
>
|
|
>
|
|
<van-image
|
|
<van-image
|
|
@@ -166,6 +166,12 @@
|
|
</div>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
|
|
+ <!-- 语音 -->
|
|
|
|
+ <VoiceCallModal
|
|
|
|
+ v-if="showVoiceCall"
|
|
|
|
+ :user="currentUser"
|
|
|
|
+ @hangup="handleHangup"
|
|
|
|
+ />
|
|
</div>
|
|
</div>
|
|
</template>
|
|
</template>
|
|
|
|
|
|
@@ -181,6 +187,7 @@ import messageAudio from "@/views/im/components/messageAudio/index.vue";
|
|
import { showToast,showImagePreview } from 'vant';
|
|
import { showToast,showImagePreview } from 'vant';
|
|
import {useWebRTCStore} from "@/stores/modules/webrtcStore";
|
|
import {useWebRTCStore} from "@/stores/modules/webrtcStore";
|
|
import * as Constant from "@/common/constant/Constant";
|
|
import * as Constant from "@/common/constant/Constant";
|
|
|
|
+import VoiceCallModal from '@/views/im/components/VoiceCallModal/index.vue';
|
|
|
|
|
|
const IM_PATH = import.meta.env.VITE_IM_PATH_FIlE;
|
|
const IM_PATH = import.meta.env.VITE_IM_PATH_FIlE;
|
|
// 路由 & store
|
|
// 路由 & store
|
|
@@ -201,6 +208,13 @@ const appBoxHeight = ref(210);
|
|
const chatListRef = ref(null);
|
|
const chatListRef = ref(null);
|
|
const emojiRef = ref(null);
|
|
const emojiRef = ref(null);
|
|
const toolsRef = ref(null);
|
|
const toolsRef = ref(null);
|
|
|
|
+const showVoiceCall = ref(false);
|
|
|
|
+
|
|
|
|
+// 示例用户
|
|
|
|
+const currentUser = ref({
|
|
|
|
+ avatar: 'https://example.com/avatar.jpg',
|
|
|
|
+ nickname: '张三'
|
|
|
|
+});
|
|
|
|
|
|
const isSender = (toUsername) => {
|
|
const isSender = (toUsername) => {
|
|
return walletStore.account === toUsername;
|
|
return walletStore.account === toUsername;
|
|
@@ -403,6 +417,7 @@ const beforeRead = (file) => {
|
|
|
|
|
|
// 开启语音电话
|
|
// 开启语音电话
|
|
const startAudioOnline = async () => {
|
|
const startAudioOnline = async () => {
|
|
|
|
+ showVoiceCall.value = true;
|
|
// 初始化webrtc连接
|
|
// 初始化webrtc连接
|
|
rtcStore.initConnection(MESSAGE_TYPE_USER, {
|
|
rtcStore.initConnection(MESSAGE_TYPE_USER, {
|
|
fromUsername: walletStore.username,
|
|
fromUsername: walletStore.username,
|
|
@@ -438,6 +453,10 @@ const startAudioOnline = async () => {
|
|
// const webRTCStore.createOffer()
|
|
// const webRTCStore.createOffer()
|
|
};
|
|
};
|
|
|
|
|
|
|
|
+const handleHangup = () => {
|
|
|
|
+ showVoiceCall.value = false;
|
|
|
|
+};
|
|
|
|
+
|
|
// 时间格式化
|
|
// 时间格式化
|
|
const formatTime = (timestamp) => {
|
|
const formatTime = (timestamp) => {
|
|
const date = new Date(timestamp);
|
|
const date = new Date(timestamp);
|