音视频通话功能完成(P2P)

已知问题:
文件无法发送
This commit is contained in:
2025-12-03 15:33:48 +08:00
parent be7bd1279a
commit 9db9b65ea3
15 changed files with 1544 additions and 704 deletions

View File

@@ -21,7 +21,7 @@
<div
class="relative flex items-center group cursor-pointer select-none"
@mousedown="handleRecordStart"
@touchstart.prevent="handleRecordStart"
@touchstart.passive="handleRecordStart"
@mouseup="handleRecordStop"
@touchend.prevent="handleRecordStop"
@mouseleave="handleRecordCancel"
@@ -69,6 +69,9 @@
<script setup lang="ts">
import { ref } from 'vue'
import { useToastStore } from '@/stores/toast'
const toastStore = useToastStore()
interface Props {
modelValue: string
@@ -144,7 +147,7 @@ async function handleRecordStart() {
stream.getTracks().forEach((t) => t.stop())
if (duration < 1000) {
alert('说话时间太短')
toastStore.warning('说话时间太短')
return
}
@@ -156,9 +159,9 @@ async function handleRecordStart() {
mediaRecorder.start()
recordStartTime = Date.now()
emit('record-start')
} catch (error) {
} catch (error: any) {
console.error('Failed to start recording:', error)
alert('无法访问麦克风')
toastStore.error(error.message || '无法访问麦克风')
}
}

View File

@@ -1,6 +1,6 @@
<template>
<img
:src="imageUrl"
:src="`http://127.0.0.1:12080${imageUrl}`"
class="rounded-lg max-w-full cursor-zoom-in hover:brightness-90 transition border border-white/10"
@click="previewImage"
/>
@@ -22,7 +22,7 @@ const imageUrl = computed(() => {
function previewImage() {
const w = window.open('')
if (w) {
w.document.write(`<img src="${imageUrl.value}" style="max-width:100%">`)
w.document.write(`<img src="http://127.0.0.1:12080${imageUrl.value}" style="max-width:100%">`)
}
}
</script>