Compare commits
8 Commits
eb0106d296
...
本地音视频合并
| Author | SHA1 | Date | |
|---|---|---|---|
| 83cf098c5f | |||
| d74a0c8121 | |||
| e6dfb28ef2 | |||
| ad93ef342b | |||
| 40fd7f7e08 | |||
| bbe7e71274 | |||
| 254d9337bf | |||
| cc734790ef |
3
.gitignore
vendored
@@ -43,6 +43,9 @@ node_modules/
|
|||||||
|
|
||||||
# Coverage
|
# Coverage
|
||||||
coverage/
|
coverage/
|
||||||
|
recordings/
|
||||||
|
!client/public/recordings/
|
||||||
|
!client/public/recordings/**
|
||||||
*.lcov
|
*.lcov
|
||||||
.nyc_output
|
.nyc_output
|
||||||
|
|
||||||
|
|||||||
12
.vscode/tasks.json
vendored
@@ -1,12 +0,0 @@
|
|||||||
{
|
|
||||||
"version": "2.0.0",
|
|
||||||
"tasks": [
|
|
||||||
{
|
|
||||||
"type": "npm",
|
|
||||||
"script": "dev_secure",
|
|
||||||
"problemMatcher": [],
|
|
||||||
"label": "npm: dev_secure",
|
|
||||||
"detail": "ts-node ./src/index.ts -p 8080 -m private -s -k ./server.key -c ./server.crt"
|
|
||||||
}
|
|
||||||
]
|
|
||||||
}
|
|
||||||
@@ -1,8 +1,8 @@
|
|||||||
/* eslint-disable no-undef */
|
/* eslint-disable no-undef */
|
||||||
import fetch from 'node-fetch';
|
import fetch from 'node-fetch';
|
||||||
import { TextEncoder, TextDecoder } from 'util';
|
import { TextEncoder, TextDecoder } from 'util';
|
||||||
import { PeerConnectionMock, SessionDescriptionMock, IceCandidateMock } from './test/peerconnectionmock';
|
import { PeerConnectionMock, SessionDescriptionMock, IceCandidateMock } from './test/mocks/peerconnectionmock.js';
|
||||||
import ResizeObserverMock from './test/resizeobservermock';
|
import ResizeObserverMock from './test/helpers/resizeobservermock.js';
|
||||||
|
|
||||||
// note: If set testEnvironment `jest-environment-jsdom`, below classes are not defined.
|
// note: If set testEnvironment `jest-environment-jsdom`, below classes are not defined.
|
||||||
|
|
||||||
|
|||||||
|
Before Width: | Height: | Size: 19 KiB After Width: | Height: | Size: 19 KiB |
|
Before Width: | Height: | Size: 472 KiB After Width: | Height: | Size: 472 KiB |
|
Before Width: | Height: | Size: 15 KiB After Width: | Height: | Size: 15 KiB |
|
Before Width: | Height: | Size: 19 KiB After Width: | Height: | Size: 19 KiB |
|
Before Width: | Height: | Size: 18 KiB After Width: | Height: | Size: 18 KiB |
|
Before Width: | Height: | Size: 15 KiB After Width: | Height: | Size: 15 KiB |
|
Before Width: | Height: | Size: 15 KiB After Width: | Height: | Size: 15 KiB |
|
Before Width: | Height: | Size: 14 KiB After Width: | Height: | Size: 14 KiB |
|
Before Width: | Height: | Size: 22 KiB After Width: | Height: | Size: 22 KiB |
|
Before Width: | Height: | Size: 19 KiB After Width: | Height: | Size: 19 KiB |
|
Before Width: | Height: | Size: 21 KiB After Width: | Height: | Size: 21 KiB |
|
Before Width: | Height: | Size: 21 KiB After Width: | Height: | Size: 21 KiB |
|
Before Width: | Height: | Size: 20 KiB After Width: | Height: | Size: 20 KiB |
|
Before Width: | Height: | Size: 21 KiB After Width: | Height: | Size: 21 KiB |
|
Before Width: | Height: | Size: 21 KiB After Width: | Height: | Size: 21 KiB |
|
Before Width: | Height: | Size: 18 KiB After Width: | Height: | Size: 18 KiB |
|
Before Width: | Height: | Size: 20 KiB After Width: | Height: | Size: 20 KiB |
|
Before Width: | Height: | Size: 18 KiB After Width: | Height: | Size: 18 KiB |
|
Before Width: | Height: | Size: 20 KiB After Width: | Height: | Size: 20 KiB |
|
Before Width: | Height: | Size: 20 KiB After Width: | Height: | Size: 20 KiB |
|
Before Width: | Height: | Size: 18 KiB After Width: | Height: | Size: 18 KiB |
|
Before Width: | Height: | Size: 17 KiB After Width: | Height: | Size: 17 KiB |
|
Before Width: | Height: | Size: 15 KiB After Width: | Height: | Size: 15 KiB |
|
Before Width: | Height: | Size: 18 KiB After Width: | Height: | Size: 18 KiB |
|
Before Width: | Height: | Size: 13 KiB After Width: | Height: | Size: 13 KiB |
|
Before Width: | Height: | Size: 166 KiB After Width: | Height: | Size: 166 KiB |
|
Before Width: | Height: | Size: 152 KiB After Width: | Height: | Size: 152 KiB |
|
Before Width: | Height: | Size: 274 KiB After Width: | Height: | Size: 274 KiB |
|
Before Width: | Height: | Size: 19 KiB After Width: | Height: | Size: 19 KiB |
|
After Width: | Height: | Size: 13 KiB |
BIN
client/public/assets/uploads/avatars/user_XPMwGa7W.png
Normal file
|
After Width: | Height: | Size: 19 KiB |
@@ -1,13 +1,13 @@
|
|||||||
import { createLogger } from './logger.js';
|
import { createLogger } from '../../shared/logger.js';
|
||||||
|
|
||||||
const logger = createLogger('chat');
|
const logger = createLogger('chat');
|
||||||
/**
|
/**
|
||||||
* 消息模块
|
* 消息模块
|
||||||
* 处理聊天消息的发送、接收和显示
|
* 处理聊天消息的发送、接收和显示
|
||||||
*/
|
*/
|
||||||
import { showNotification, generateId } from './utils.js';
|
import { showNotification, generateId } from '../../shared/utils.js';
|
||||||
import store from './store.js';
|
import store from '../store.js';
|
||||||
import { mockMessages } from './models.js';
|
import { mockMessages } from '../models.js';
|
||||||
|
|
||||||
const MAX_IMAGE_SIZE = 5 * 1024 * 1024; // 5MB
|
const MAX_IMAGE_SIZE = 5 * 1024 * 1024; // 5MB
|
||||||
|
|
||||||
77
client/public/call/chat/renderer-chat.js
Normal file
@@ -0,0 +1,77 @@
|
|||||||
|
import { createTextElement, textValue } from '../../shared/dom.js';
|
||||||
|
|
||||||
|
export function createMessageElement(message, formatTimestamp) {
|
||||||
|
const messageDiv = document.createElement('div');
|
||||||
|
let messageClass = 'chat-bubble';
|
||||||
|
|
||||||
|
if (message.type === 'system') {
|
||||||
|
messageClass += ' message-system';
|
||||||
|
} else if (message.isSelf) {
|
||||||
|
messageClass += ' message-self';
|
||||||
|
} else {
|
||||||
|
messageClass += ' message-other';
|
||||||
|
}
|
||||||
|
|
||||||
|
messageDiv.className = messageClass;
|
||||||
|
messageDiv.dataset.messageId = message.id;
|
||||||
|
|
||||||
|
const header = document.createElement('div');
|
||||||
|
header.className = 'message-header';
|
||||||
|
|
||||||
|
const avatar = document.createElement('img');
|
||||||
|
avatar.className = 'message-avatar';
|
||||||
|
avatar.src = textValue(message.senderAvatar);
|
||||||
|
avatar.alt = textValue(message.senderName, '\u7528\u6237');
|
||||||
|
header.appendChild(avatar);
|
||||||
|
|
||||||
|
const headerText = document.createElement('div');
|
||||||
|
headerText.appendChild(createTextElement('span', 'message-sender', message.senderName));
|
||||||
|
headerText.appendChild(createTextElement('span', 'message-time', formatTimestamp(message.timestamp)));
|
||||||
|
header.appendChild(headerText);
|
||||||
|
|
||||||
|
const content = document.createElement('div');
|
||||||
|
content.className = 'message-content';
|
||||||
|
const rawContent = textValue(message.content);
|
||||||
|
|
||||||
|
if (message.type === 'file' && rawContent.startsWith('data:image/')) {
|
||||||
|
const imageContainer = document.createElement('div');
|
||||||
|
imageContainer.className = 'message-image-container';
|
||||||
|
|
||||||
|
const image = document.createElement('img');
|
||||||
|
image.src = rawContent;
|
||||||
|
image.className = 'message-image';
|
||||||
|
image.alt = textValue(message.fileName, '\u56fe\u7247');
|
||||||
|
imageContainer.appendChild(image);
|
||||||
|
|
||||||
|
if (message.fileName) {
|
||||||
|
imageContainer.appendChild(createTextElement('div', 'message-image-name', message.fileName));
|
||||||
|
}
|
||||||
|
|
||||||
|
content.appendChild(imageContainer);
|
||||||
|
} else {
|
||||||
|
content.appendChild(createTextElement('div', 'message-text', rawContent));
|
||||||
|
}
|
||||||
|
|
||||||
|
messageDiv.appendChild(header);
|
||||||
|
messageDiv.appendChild(content);
|
||||||
|
|
||||||
|
return messageDiv;
|
||||||
|
}
|
||||||
|
|
||||||
|
export function renderChatMessagesInto(container, messages, formatTimestamp) {
|
||||||
|
if (!container) return;
|
||||||
|
|
||||||
|
container.innerHTML = '';
|
||||||
|
|
||||||
|
const startTimeElement = document.createElement('div');
|
||||||
|
startTimeElement.className = 'text-center text-xs text-gray-500 my-4';
|
||||||
|
const startTime = messages[0]?.timestamp || new Date().toISOString();
|
||||||
|
startTimeElement.textContent = `\u901a\u8bdd\u5f00\u59cb ${formatTimestamp(startTime)}`;
|
||||||
|
container.appendChild(startTimeElement);
|
||||||
|
|
||||||
|
messages.forEach(message => {
|
||||||
|
container.appendChild(createMessageElement(message, formatTimestamp));
|
||||||
|
});
|
||||||
|
|
||||||
|
container.scrollTop = container.scrollHeight;
|
||||||
|
}
|
||||||
@@ -1,13 +1,13 @@
|
|||||||
import { showNotification } from './utils.js';
|
import { showNotification } from '../shared/utils.js';
|
||||||
import store from './store.js';
|
import store from './store.js';
|
||||||
import {
|
import {
|
||||||
fetchConnectionDirectory,
|
fetchConnectionDirectory,
|
||||||
fetchOnlineUsers,
|
fetchOnlineUsers,
|
||||||
renderConnectionIds,
|
renderConnectionIds,
|
||||||
renderOnlineUsers
|
renderOnlineUsers
|
||||||
} from './connect-directory.js';
|
} from './signaling/connect-directory.js';
|
||||||
import { createProfileSettingsController } from './profile-settings.js';
|
import { createProfileSettingsController } from './controllers/profile-settings.js';
|
||||||
import { createLogger } from './logger.js';
|
import { createLogger } from '../shared/logger.js';
|
||||||
|
|
||||||
const logger = createLogger('connectview');
|
const logger = createLogger('connectview');
|
||||||
|
|
||||||
@@ -21,15 +21,13 @@ export function createCallViewController({ store, chatMessage, notify }) {
|
|||||||
toggleVideo();
|
toggleVideo();
|
||||||
}
|
}
|
||||||
|
|
||||||
function toggleRecording() {
|
async function toggleRecording() {
|
||||||
const state = store.getState();
|
try {
|
||||||
const currentState = state.session.localUser.mediaState.recording || false;
|
const result = await store.toggleRecording();
|
||||||
store.updateLocalMedia('recording', !currentState);
|
notify(result.message);
|
||||||
|
}
|
||||||
if (!currentState) {
|
catch (error) {
|
||||||
notify('\u5f00\u59cb\u5f55\u5236');
|
notify(error.message || '\u5f55\u5236\u5931\u8d25');
|
||||||
} else {
|
|
||||||
notify('\u505c\u6b62\u5f55\u5236');
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1,4 +1,4 @@
|
|||||||
import { createLogger } from './logger.js';
|
import { createLogger } from '../../shared/logger.js';
|
||||||
|
|
||||||
const logger = createLogger('invite');
|
const logger = createLogger('invite');
|
||||||
const DEFAULT_CALLER_NAME = '\u9080\u8bf7\u65b9';
|
const DEFAULT_CALLER_NAME = '\u9080\u8bf7\u65b9';
|
||||||
@@ -1,4 +1,4 @@
|
|||||||
import { createLogger } from './logger.js';
|
import { createLogger } from '../../shared/logger.js';
|
||||||
|
|
||||||
const logger = createLogger('profile');
|
const logger = createLogger('profile');
|
||||||
const DEFAULT_AVATAR = '/images/p1.png';
|
const DEFAULT_AVATAR = '/images/p1.png';
|
||||||
@@ -7,7 +7,7 @@
|
|||||||
<title>VideoCall - 一对一视频通话</title>
|
<title>VideoCall - 一对一视频通话</title>
|
||||||
<script src="https://cdn.tailwindcss.com"></script>
|
<script src="https://cdn.tailwindcss.com"></script>
|
||||||
<link href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/6.4.0/css/all.min.css" rel="stylesheet">
|
<link href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/6.4.0/css/all.min.css" rel="stylesheet">
|
||||||
<link rel="stylesheet" href="css/style.css">
|
<link rel="stylesheet" href="/styles/style.css">
|
||||||
</head>
|
</head>
|
||||||
|
|
||||||
<body class="h-screen w-screen flex flex-col text-white bg-grid relative">
|
<body class="h-screen w-screen flex flex-col text-white bg-grid relative">
|
||||||
@@ -726,8 +726,8 @@
|
|||||||
</div>
|
</div>
|
||||||
|
|
||||||
<!-- 引入模块化JavaScript文件 -->
|
<!-- 引入模块化JavaScript文件 -->
|
||||||
<script type="module" src="connectview.js"></script>
|
<script type="module" src="/call/connectview.js"></script>
|
||||||
<script type="module" src="main.js"></script>
|
<script type="module" src="/call/main.js"></script>
|
||||||
|
|
||||||
|
|
||||||
</body>
|
</body>
|
||||||
@@ -1,15 +1,15 @@
|
|||||||
import store from './store.js';
|
import store from './store.js';
|
||||||
import UIRenderer from './renderer.js';
|
import UIRenderer from './renderers/renderer.js';
|
||||||
import { showNotification, randomMeetingId } from './utils.js';
|
import { showNotification, randomMeetingId } from '../shared/utils.js';
|
||||||
import chatMessage from './chatmessage.js';
|
import chatMessage from './chat/chatmessage.js';
|
||||||
import { createCallViewController } from './call-view-controller.js';
|
import { createCallViewController } from './controllers/call-view-controller.js';
|
||||||
import {
|
import {
|
||||||
bindConnectViewEvents,
|
bindConnectViewEvents,
|
||||||
initWebSocket,
|
initWebSocket,
|
||||||
loadUserSettings
|
loadUserSettings
|
||||||
} from './connectview.js';
|
} from './connectview.js';
|
||||||
import { createInviteController } from './invite-controller.js';
|
import { createInviteController } from './controllers/invite-controller.js';
|
||||||
import { createLogger } from './logger.js';
|
import { createLogger } from '../shared/logger.js';
|
||||||
|
|
||||||
const logger = createLogger('main');
|
const logger = createLogger('main');
|
||||||
|
|
||||||
336
client/public/call/media/meeting-recorder.js
Normal file
@@ -0,0 +1,336 @@
|
|||||||
|
const DEFAULT_WIDTH = 1280;
|
||||||
|
const DEFAULT_HEIGHT = 720;
|
||||||
|
const DEFAULT_FPS = 30;
|
||||||
|
const MIME_TYPE_CANDIDATES = [
|
||||||
|
{ mimeType: 'video/mp4;codecs=avc1.42E01E,mp4a.40.2', extension: 'mp4' },
|
||||||
|
{ mimeType: 'video/mp4', extension: 'mp4' },
|
||||||
|
{ mimeType: 'video/webm;codecs=vp9,opus', extension: 'webm' },
|
||||||
|
{ mimeType: 'video/webm;codecs=vp8,opus', extension: 'webm' },
|
||||||
|
{ mimeType: 'video/webm', extension: 'webm' }
|
||||||
|
];
|
||||||
|
|
||||||
|
function getSupportedFormat(mediaRecorderCtor) {
|
||||||
|
if (!mediaRecorderCtor || typeof mediaRecorderCtor.isTypeSupported !== 'function') {
|
||||||
|
return {
|
||||||
|
mimeType: '',
|
||||||
|
extension: 'webm'
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
return MIME_TYPE_CANDIDATES.find(format => mediaRecorderCtor.isTypeSupported(format.mimeType)) || {
|
||||||
|
mimeType: '',
|
||||||
|
extension: 'webm'
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
function isElementVisible(element) {
|
||||||
|
if (!element || element.classList.contains('hidden')) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
const rect = element.getBoundingClientRect();
|
||||||
|
return rect.width > 0 && rect.height > 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
function drawVideoCover(context, video, x, y, width, height) {
|
||||||
|
const videoWidth = video.videoWidth || width;
|
||||||
|
const videoHeight = video.videoHeight || height;
|
||||||
|
const sourceRatio = videoWidth / videoHeight;
|
||||||
|
const targetRatio = width / height;
|
||||||
|
let sourceX = 0;
|
||||||
|
let sourceY = 0;
|
||||||
|
let sourceWidth = videoWidth;
|
||||||
|
let sourceHeight = videoHeight;
|
||||||
|
|
||||||
|
if (sourceRatio > targetRatio) {
|
||||||
|
sourceWidth = videoHeight * targetRatio;
|
||||||
|
sourceX = (videoWidth - sourceWidth) / 2;
|
||||||
|
} else {
|
||||||
|
sourceHeight = videoWidth / targetRatio;
|
||||||
|
sourceY = (videoHeight - sourceHeight) / 2;
|
||||||
|
}
|
||||||
|
|
||||||
|
context.drawImage(video, sourceX, sourceY, sourceWidth, sourceHeight, x, y, width, height);
|
||||||
|
}
|
||||||
|
|
||||||
|
function drawEmptyFrame(context, canvas) {
|
||||||
|
context.fillStyle = '#111827';
|
||||||
|
context.fillRect(0, 0, canvas.width, canvas.height);
|
||||||
|
context.fillStyle = '#9ca3af';
|
||||||
|
context.font = '24px sans-serif';
|
||||||
|
context.textAlign = 'center';
|
||||||
|
context.textBaseline = 'middle';
|
||||||
|
context.fillText('等待会议画面...', canvas.width / 2, canvas.height / 2);
|
||||||
|
}
|
||||||
|
|
||||||
|
function drawGrid(context, videos, canvas) {
|
||||||
|
const columns = Math.ceil(Math.sqrt(videos.length));
|
||||||
|
const rows = Math.ceil(videos.length / columns);
|
||||||
|
const gap = 8;
|
||||||
|
const tileWidth = (canvas.width - gap * (columns - 1)) / columns;
|
||||||
|
const tileHeight = (canvas.height - gap * (rows - 1)) / rows;
|
||||||
|
|
||||||
|
videos.forEach((video, index) => {
|
||||||
|
const column = index % columns;
|
||||||
|
const row = Math.floor(index / columns);
|
||||||
|
const x = column * (tileWidth + gap);
|
||||||
|
const y = row * (tileHeight + gap);
|
||||||
|
drawVideoCover(context, video, x, y, tileWidth, tileHeight);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
function drawLocalPreview(context, localVideo, canvas) {
|
||||||
|
const previewWidth = Math.floor(canvas.width * 0.22);
|
||||||
|
const previewHeight = Math.floor(previewWidth * 9 / 16);
|
||||||
|
const margin = 24;
|
||||||
|
const x = canvas.width - previewWidth - margin;
|
||||||
|
const y = canvas.height - previewHeight - margin;
|
||||||
|
|
||||||
|
context.fillStyle = 'rgba(0, 0, 0, 0.4)';
|
||||||
|
context.fillRect(x - 4, y - 4, previewWidth + 8, previewHeight + 8);
|
||||||
|
drawVideoCover(context, localVideo, x, y, previewWidth, previewHeight);
|
||||||
|
}
|
||||||
|
|
||||||
|
function collectStreams({ localStream, remoteStream, remoteStreams } = {}) {
|
||||||
|
return [
|
||||||
|
localStream,
|
||||||
|
remoteStream,
|
||||||
|
...Object.values(remoteStreams || {})
|
||||||
|
].filter(Boolean);
|
||||||
|
}
|
||||||
|
|
||||||
|
function collectLiveAudioTracks(streams) {
|
||||||
|
return streams.flatMap(stream => stream.getAudioTracks())
|
||||||
|
.filter(track => track.readyState !== 'ended');
|
||||||
|
}
|
||||||
|
|
||||||
|
export class MeetingRecorder {
|
||||||
|
constructor({
|
||||||
|
documentRef = document,
|
||||||
|
windowRef = window,
|
||||||
|
width = DEFAULT_WIDTH,
|
||||||
|
height = DEFAULT_HEIGHT,
|
||||||
|
fps = DEFAULT_FPS
|
||||||
|
} = {}) {
|
||||||
|
this.document = documentRef;
|
||||||
|
this.window = windowRef;
|
||||||
|
this.width = width;
|
||||||
|
this.height = height;
|
||||||
|
this.fps = fps;
|
||||||
|
this.mediaRecorder = null;
|
||||||
|
this.chunks = [];
|
||||||
|
this.animationFrameId = null;
|
||||||
|
this.audioContext = null;
|
||||||
|
this.audioSources = [];
|
||||||
|
this.recordingStream = null;
|
||||||
|
this.connectionId = '';
|
||||||
|
}
|
||||||
|
|
||||||
|
isSupported() {
|
||||||
|
return Boolean(
|
||||||
|
this.window.MediaRecorder &&
|
||||||
|
this.document.createElement('canvas').captureStream
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
isRecording() {
|
||||||
|
return Boolean(this.mediaRecorder && this.mediaRecorder.state !== 'inactive');
|
||||||
|
}
|
||||||
|
|
||||||
|
async start({ localStream, remoteStream, remoteStreams, connectionId } = {}) {
|
||||||
|
if (this.isRecording()) {
|
||||||
|
throw new Error('会议正在录制中');
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!this.isSupported()) {
|
||||||
|
throw new Error('当前浏览器不支持会议录制');
|
||||||
|
}
|
||||||
|
|
||||||
|
const canvas = this.document.createElement('canvas');
|
||||||
|
canvas.width = this.width;
|
||||||
|
canvas.height = this.height;
|
||||||
|
const context = canvas.getContext('2d');
|
||||||
|
|
||||||
|
if (!context) {
|
||||||
|
throw new Error('无法创建录制画布');
|
||||||
|
}
|
||||||
|
|
||||||
|
this.connectionId = connectionId || '';
|
||||||
|
this.chunks = [];
|
||||||
|
this.canvas = canvas;
|
||||||
|
this.context = context;
|
||||||
|
|
||||||
|
const canvasStream = canvas.captureStream(this.fps);
|
||||||
|
const streams = collectStreams({ localStream, remoteStream, remoteStreams });
|
||||||
|
const audioTrack = this.createMixedAudioTrack(streams);
|
||||||
|
const tracks = [
|
||||||
|
...canvasStream.getVideoTracks(),
|
||||||
|
...(audioTrack ? [audioTrack] : [])
|
||||||
|
];
|
||||||
|
|
||||||
|
this.recordingStream = new this.window.MediaStream(tracks);
|
||||||
|
try {
|
||||||
|
this.startDrawing();
|
||||||
|
this.startMediaRecorder(this.recordingStream);
|
||||||
|
}
|
||||||
|
catch (error) {
|
||||||
|
this.cleanup();
|
||||||
|
throw error;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
stop() {
|
||||||
|
if (!this.isRecording()) {
|
||||||
|
return Promise.resolve(null);
|
||||||
|
}
|
||||||
|
|
||||||
|
return new Promise((resolve, reject) => {
|
||||||
|
this.pendingStop = { resolve, reject };
|
||||||
|
this.mediaRecorder.stop();
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
createMixedAudioTrack(streams) {
|
||||||
|
const audioTracks = collectLiveAudioTracks(streams);
|
||||||
|
|
||||||
|
if (audioTracks.length === 0) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
const AudioContextCtor = this.window.AudioContext || this.window.webkitAudioContext;
|
||||||
|
if (!AudioContextCtor) {
|
||||||
|
return audioTracks[0].clone ? audioTracks[0].clone() : audioTracks[0];
|
||||||
|
}
|
||||||
|
|
||||||
|
this.audioContext = new AudioContextCtor();
|
||||||
|
const destination = this.audioContext.createMediaStreamDestination();
|
||||||
|
|
||||||
|
audioTracks.forEach(track => {
|
||||||
|
const sourceStream = new this.window.MediaStream([track]);
|
||||||
|
const source = this.audioContext.createMediaStreamSource(sourceStream);
|
||||||
|
source.connect(destination);
|
||||||
|
this.audioSources.push(source);
|
||||||
|
});
|
||||||
|
|
||||||
|
return destination.stream.getAudioTracks()[0] || null;
|
||||||
|
}
|
||||||
|
|
||||||
|
startMediaRecorder(stream) {
|
||||||
|
const MediaRecorderCtor = this.window.MediaRecorder;
|
||||||
|
const format = getSupportedFormat(MediaRecorderCtor);
|
||||||
|
const options = format.mimeType ? { mimeType: format.mimeType } : {};
|
||||||
|
this.fileExtension = format.extension;
|
||||||
|
|
||||||
|
this.mediaRecorder = new MediaRecorderCtor(stream, options);
|
||||||
|
this.mediaRecorder.ondataavailable = (event) => {
|
||||||
|
if (event.data && event.data.size > 0) {
|
||||||
|
this.chunks.push(event.data);
|
||||||
|
}
|
||||||
|
};
|
||||||
|
this.mediaRecorder.onerror = (event) => {
|
||||||
|
if (this.pendingStop) {
|
||||||
|
this.pendingStop.reject(event.error || new Error('录制失败'));
|
||||||
|
this.pendingStop = null;
|
||||||
|
}
|
||||||
|
this.cleanup();
|
||||||
|
};
|
||||||
|
this.mediaRecorder.onstop = () => {
|
||||||
|
const blob = new Blob(this.chunks, { type: this.mediaRecorder.mimeType || 'video/webm' });
|
||||||
|
const filename = this.buildFilename();
|
||||||
|
const mimeType = blob.type || this.mediaRecorder.mimeType || 'video/webm';
|
||||||
|
this.cleanup();
|
||||||
|
if (this.pendingStop) {
|
||||||
|
this.pendingStop.resolve({ blob, filename, mimeType });
|
||||||
|
this.pendingStop = null;
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
this.mediaRecorder.start(1000);
|
||||||
|
}
|
||||||
|
|
||||||
|
startDrawing() {
|
||||||
|
const draw = () => {
|
||||||
|
this.drawFrame();
|
||||||
|
this.animationFrameId = this.window.requestAnimationFrame(draw);
|
||||||
|
};
|
||||||
|
|
||||||
|
draw();
|
||||||
|
}
|
||||||
|
|
||||||
|
drawFrame() {
|
||||||
|
const context = this.context;
|
||||||
|
const canvas = this.canvas;
|
||||||
|
const videos = this.getRecordableVideos();
|
||||||
|
const localVideo = videos.find(video => video.id === 'localVideo');
|
||||||
|
const remoteVideos = videos.filter(video => video !== localVideo);
|
||||||
|
|
||||||
|
context.fillStyle = '#020617';
|
||||||
|
context.fillRect(0, 0, canvas.width, canvas.height);
|
||||||
|
|
||||||
|
if (remoteVideos.length > 0) {
|
||||||
|
drawGrid(context, remoteVideos, canvas);
|
||||||
|
if (localVideo) {
|
||||||
|
drawLocalPreview(context, localVideo, canvas);
|
||||||
|
}
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (localVideo) {
|
||||||
|
drawVideoCover(context, localVideo, 0, 0, canvas.width, canvas.height);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
drawEmptyFrame(context, canvas);
|
||||||
|
}
|
||||||
|
|
||||||
|
getRecordableVideos() {
|
||||||
|
return Array.from(this.document.querySelectorAll('#participantGrid video, #remoteVideo, #localVideo'))
|
||||||
|
.filter(video => video.srcObject && isElementVisible(video) && video.readyState >= 2);
|
||||||
|
}
|
||||||
|
|
||||||
|
download(blob, filename = this.buildFilename()) {
|
||||||
|
const url = this.window.URL.createObjectURL(blob);
|
||||||
|
const link = this.document.createElement('a');
|
||||||
|
link.href = url;
|
||||||
|
link.download = filename;
|
||||||
|
link.style.display = 'none';
|
||||||
|
this.document.body.appendChild(link);
|
||||||
|
link.click();
|
||||||
|
link.remove();
|
||||||
|
|
||||||
|
this.window.setTimeout(() => {
|
||||||
|
this.window.URL.revokeObjectURL(url);
|
||||||
|
}, 1000);
|
||||||
|
|
||||||
|
return filename;
|
||||||
|
}
|
||||||
|
|
||||||
|
buildFilename() {
|
||||||
|
const datePart = new Date().toISOString().replace(/[:.]/g, '-');
|
||||||
|
const meetingPart = this.connectionId ? `-${this.connectionId}` : '';
|
||||||
|
return `meeting-recording${meetingPart}-${datePart}.${this.fileExtension || 'webm'}`;
|
||||||
|
}
|
||||||
|
|
||||||
|
cleanup() {
|
||||||
|
if (this.animationFrameId) {
|
||||||
|
this.window.cancelAnimationFrame(this.animationFrameId);
|
||||||
|
this.animationFrameId = null;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (this.recordingStream) {
|
||||||
|
this.recordingStream.getTracks().forEach(track => track.stop());
|
||||||
|
this.recordingStream = null;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (this.audioContext) {
|
||||||
|
this.audioContext.close();
|
||||||
|
this.audioContext = null;
|
||||||
|
}
|
||||||
|
|
||||||
|
this.audioSources = [];
|
||||||
|
this.mediaRecorder = null;
|
||||||
|
this.canvas = null;
|
||||||
|
this.context = null;
|
||||||
|
this.chunks = [];
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -1,5 +1,5 @@
|
|||||||
import { createParticipantTile, getParticipantTile } from './renderer-participant-grid.js';
|
import { createParticipantTile, getParticipantTile } from '../participants/renderer-participant-grid.js';
|
||||||
import { createLogger } from './logger.js';
|
import { createLogger } from '../../shared/logger.js';
|
||||||
|
|
||||||
const logger = createLogger('renderer-media');
|
const logger = createLogger('renderer-media');
|
||||||
|
|
||||||
@@ -1,3 +1,5 @@
|
|||||||
|
import { createIconElement, createTextElement, textValue } from '../../shared/dom.js';
|
||||||
|
|
||||||
function createParticipantPlaceholder() {
|
function createParticipantPlaceholder() {
|
||||||
const placeholder = document.createElement('div');
|
const placeholder = document.createElement('div');
|
||||||
placeholder.className = 'participant-video-placeholder absolute inset-0 flex items-center justify-center bg-gradient-to-br from-indigo-900/80 to-purple-900/80 hidden';
|
placeholder.className = 'participant-video-placeholder absolute inset-0 flex items-center justify-center bg-gradient-to-br from-indigo-900/80 to-purple-900/80 hidden';
|
||||||
@@ -15,32 +17,39 @@ function createParticipantPlaceholder() {
|
|||||||
export function createParticipantTile(connectionId, displayName) {
|
export function createParticipantTile(connectionId, displayName) {
|
||||||
const tile = document.createElement('div');
|
const tile = document.createElement('div');
|
||||||
tile.className = 'relative bg-black/60 rounded-xl overflow-hidden flex items-center justify-center';
|
tile.className = 'relative bg-black/60 rounded-xl overflow-hidden flex items-center justify-center';
|
||||||
tile.dataset.participantId = connectionId;
|
tile.dataset.participantId = textValue(connectionId);
|
||||||
|
|
||||||
const video = document.createElement('video');
|
const video = document.createElement('video');
|
||||||
video.className = 'w-full h-full object-contain';
|
video.className = 'w-full h-full object-contain';
|
||||||
video.autoplay = true;
|
video.autoplay = true;
|
||||||
video.playsinline = true;
|
video.playsinline = true;
|
||||||
video.muted = false;
|
video.muted = false;
|
||||||
video.id = `participantVideo_${connectionId}`;
|
video.id = `participantVideo_${textValue(connectionId)}`;
|
||||||
tile.appendChild(video);
|
tile.appendChild(video);
|
||||||
tile.appendChild(createParticipantPlaceholder());
|
tile.appendChild(createParticipantPlaceholder());
|
||||||
|
|
||||||
const label = document.createElement('div');
|
const label = document.createElement('div');
|
||||||
label.className = 'absolute bottom-3 left-3 glass px-3 py-1 rounded-full text-xs flex items-center gap-2';
|
label.className = 'absolute bottom-3 left-3 glass px-3 py-1 rounded-full text-xs flex items-center gap-2';
|
||||||
label.innerHTML = `<i class="fas fa-user text-purple-400"></i><span>${displayName || '\u53c2\u4e0e\u8005'}</span>`;
|
label.appendChild(createIconElement('fas fa-user text-purple-400'));
|
||||||
|
label.appendChild(createTextElement('span', '', displayName, '\u53c2\u4e0e\u8005'));
|
||||||
tile.appendChild(label);
|
tile.appendChild(label);
|
||||||
|
|
||||||
const liveTag = document.createElement('div');
|
const liveTag = document.createElement('div');
|
||||||
liveTag.className = 'absolute top-3 right-3 bg-green-500/80 px-2 py-0.5 rounded-full text-xs flex items-center gap-1';
|
liveTag.className = 'absolute top-3 right-3 bg-green-500/80 px-2 py-0.5 rounded-full text-xs flex items-center gap-1';
|
||||||
liveTag.innerHTML = `<span class="w-1.5 h-1.5 bg-white rounded-full animate-pulse"></span><span>\u5728\u7ebf</span>`;
|
const pulse = document.createElement('span');
|
||||||
|
pulse.className = 'w-1.5 h-1.5 bg-white rounded-full animate-pulse';
|
||||||
|
liveTag.appendChild(pulse);
|
||||||
|
liveTag.appendChild(createTextElement('span', '', '\u5728\u7ebf'));
|
||||||
tile.appendChild(liveTag);
|
tile.appendChild(liveTag);
|
||||||
|
|
||||||
return tile;
|
return tile;
|
||||||
}
|
}
|
||||||
|
|
||||||
export function getParticipantTile(grid, participantId) {
|
export function getParticipantTile(grid, participantId) {
|
||||||
return grid?.querySelector(`[data-participant-id="${participantId}"]`) || null;
|
if (!grid) return null;
|
||||||
|
const expectedId = textValue(participantId);
|
||||||
|
return Array.from(grid.querySelectorAll('[data-participant-id]'))
|
||||||
|
.find(tile => tile.dataset.participantId === expectedId) || null;
|
||||||
}
|
}
|
||||||
|
|
||||||
export function updateParticipantTilePlaceholder(grid, participantId, showPlaceholder) {
|
export function updateParticipantTilePlaceholder(grid, participantId, showPlaceholder) {
|
||||||
@@ -1,3 +1,5 @@
|
|||||||
|
import { createIconElement, createTextElement, textValue } from '../../shared/dom.js';
|
||||||
|
|
||||||
const DEFAULT_NETWORK_QUALITY = {
|
const DEFAULT_NETWORK_QUALITY = {
|
||||||
label: '\u672a\u77e5',
|
label: '\u672a\u77e5',
|
||||||
statusIconClass: 'fas fa-question-circle text-gray-400',
|
statusIconClass: 'fas fa-question-circle text-gray-400',
|
||||||
@@ -50,18 +52,18 @@ const NETWORK_QUALITY_DISPLAY = {
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
function getRoleTagMarkup(user, role) {
|
function getRoleTagMeta(user, role) {
|
||||||
if (role === 'local') {
|
if (role === 'local') {
|
||||||
return user.isHost
|
return user.isHost
|
||||||
? '<span class="text-xs bg-indigo-500 px-1.5 rounded ml-1">\u4e3b\u6301\u4eba</span>'
|
? { className: 'text-xs bg-indigo-500 px-1.5 rounded ml-1', label: '\u4e3b\u6301\u4eba' }
|
||||||
: '<span class="text-xs bg-purple-500 px-1.5 rounded ml-1">\u53c2\u4e0e\u8005</span>';
|
: { className: 'text-xs bg-purple-500 px-1.5 rounded ml-1', label: '\u53c2\u4e0e\u8005' };
|
||||||
}
|
}
|
||||||
|
|
||||||
if (role === 'participant') {
|
if (role === 'participant') {
|
||||||
return '<span class="text-xs bg-purple-500 px-1.5 rounded ml-1">\u53c2\u4e0e\u8005</span>';
|
return { className: 'text-xs bg-purple-500 px-1.5 rounded ml-1', label: '\u53c2\u4e0e\u8005' };
|
||||||
}
|
}
|
||||||
|
|
||||||
return '<span class="text-xs bg-indigo-500 px-1.5 rounded ml-1">\u4e3b\u6301\u4eba</span>';
|
return { className: 'text-xs bg-indigo-500 px-1.5 rounded ml-1', label: '\u4e3b\u6301\u4eba' };
|
||||||
}
|
}
|
||||||
|
|
||||||
function getDatasetUserId(role, id) {
|
function getDatasetUserId(role, id) {
|
||||||
@@ -79,34 +81,55 @@ function getDatasetUserId(role, id) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
function getAvatarMarkup(user, role) {
|
function createAvatarImage(user) {
|
||||||
if (role === 'local') {
|
const image = document.createElement('img');
|
||||||
return `<img src="${user.avatar}" class="w-10 h-10 rounded-full object-cover">`;
|
image.src = textValue(user.avatar);
|
||||||
}
|
image.alt = textValue(user.name, '\u7528\u6237');
|
||||||
|
image.className = 'w-10 h-10 rounded-full object-cover';
|
||||||
return `
|
return image;
|
||||||
<div class="relative">
|
|
||||||
<img src="${user.avatar}" class="w-10 h-10 rounded-full object-cover">
|
|
||||||
<div class="absolute -bottom-1 -right-1 w-3 h-3 bg-green-500 rounded-full border-2 border-slate-900"></div>
|
|
||||||
</div>
|
|
||||||
`;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
function getRightMarkup(mediaState, role, muteIconMarkup) {
|
function createAvatarElement(user, role) {
|
||||||
if (role !== 'participant') {
|
if (role === 'local') {
|
||||||
return muteIconMarkup;
|
return createAvatarImage(user);
|
||||||
}
|
}
|
||||||
|
|
||||||
const speakingMarkup = (mediaState.isSpeaking && mediaState.audio)
|
const wrapper = document.createElement('div');
|
||||||
? '<div class="audio-wave w-6"><span></span><span></span><span></span><span></span><span></span></div>'
|
wrapper.className = 'relative';
|
||||||
: '';
|
wrapper.appendChild(createAvatarImage(user));
|
||||||
|
|
||||||
return `
|
const statusDot = document.createElement('div');
|
||||||
<div class="flex items-center gap-2">
|
statusDot.className = 'absolute -bottom-1 -right-1 w-3 h-3 bg-green-500 rounded-full border-2 border-slate-900';
|
||||||
${muteIconMarkup}
|
wrapper.appendChild(statusDot);
|
||||||
${speakingMarkup}
|
|
||||||
</div>
|
return wrapper;
|
||||||
`;
|
}
|
||||||
|
|
||||||
|
function createAudioWaveElement() {
|
||||||
|
const wave = document.createElement('div');
|
||||||
|
wave.className = 'audio-wave w-6';
|
||||||
|
for (let i = 0; i < 5; i += 1) {
|
||||||
|
wave.appendChild(document.createElement('span'));
|
||||||
|
}
|
||||||
|
return wave;
|
||||||
|
}
|
||||||
|
|
||||||
|
function createRightElement(mediaState, role, muteIcon) {
|
||||||
|
if (role !== 'participant') {
|
||||||
|
return muteIcon;
|
||||||
|
}
|
||||||
|
|
||||||
|
const right = document.createElement('div');
|
||||||
|
right.className = 'flex items-center gap-2';
|
||||||
|
|
||||||
|
if (muteIcon) {
|
||||||
|
right.appendChild(muteIcon);
|
||||||
|
}
|
||||||
|
if (mediaState.isSpeaking && mediaState.audio) {
|
||||||
|
right.appendChild(createAudioWaveElement());
|
||||||
|
}
|
||||||
|
|
||||||
|
return right.childNodes.length > 0 ? right : null;
|
||||||
}
|
}
|
||||||
|
|
||||||
export function getCallTitle(connectionId) {
|
export function getCallTitle(connectionId) {
|
||||||
@@ -163,27 +186,40 @@ export function buildUserCountLabel(userCount) {
|
|||||||
export function createUserEntryElement({ user, role, id }) {
|
export function createUserEntryElement({ user, role, id }) {
|
||||||
const entry = document.createElement('div');
|
const entry = document.createElement('div');
|
||||||
const mediaMeta = getMediaStatusMeta(user.mediaState);
|
const mediaMeta = getMediaStatusMeta(user.mediaState);
|
||||||
const muteIconMarkup = mediaMeta.showMuteIcon
|
const muteIcon = mediaMeta.showMuteIcon
|
||||||
? `<i class="${mediaMeta.muteIconClass}"></i>`
|
? createIconElement(mediaMeta.muteIconClass)
|
||||||
: '';
|
: '';
|
||||||
const baseClass = 'flex items-center gap-3 p-2 rounded-lg';
|
const baseClass = 'flex items-center gap-3 p-2 rounded-lg';
|
||||||
const dataFieldAttr = role === 'local' ? ' data-field="localUser.mediaStatus"' : '';
|
|
||||||
|
|
||||||
entry.className = role === 'local'
|
entry.className = role === 'local'
|
||||||
? `${baseClass} hover:bg-white/5`
|
? `${baseClass} hover:bg-white/5`
|
||||||
: `${baseClass} bg-white/5`;
|
: `${baseClass} bg-white/5`;
|
||||||
entry.dataset.userId = getDatasetUserId(role, id);
|
entry.dataset.userId = getDatasetUserId(role, id);
|
||||||
entry.innerHTML = `
|
|
||||||
${getAvatarMarkup(user, role)}
|
entry.appendChild(createAvatarElement(user, role));
|
||||||
<div class="flex-1">
|
|
||||||
<div class="text-sm font-medium">
|
const details = document.createElement('div');
|
||||||
${user.name}
|
details.className = 'flex-1';
|
||||||
${getRoleTagMarkup(user, role)}
|
|
||||||
</div>
|
const nameRow = document.createElement('div');
|
||||||
<div class="${mediaMeta.className}"${dataFieldAttr}>${mediaMeta.text}</div>
|
nameRow.className = 'text-sm font-medium';
|
||||||
</div>
|
nameRow.appendChild(document.createTextNode(textValue(user.name)));
|
||||||
${getRightMarkup(user.mediaState, role, muteIconMarkup)}
|
const roleTag = getRoleTagMeta(user, role);
|
||||||
`;
|
nameRow.appendChild(createTextElement('span', roleTag.className, roleTag.label));
|
||||||
|
details.appendChild(nameRow);
|
||||||
|
|
||||||
|
const mediaStatus = createTextElement('div', mediaMeta.className, mediaMeta.text);
|
||||||
|
if (role === 'local') {
|
||||||
|
mediaStatus.dataset.field = 'localUser.mediaStatus';
|
||||||
|
}
|
||||||
|
details.appendChild(mediaStatus);
|
||||||
|
|
||||||
|
entry.appendChild(details);
|
||||||
|
|
||||||
|
const right = createRightElement(user.mediaState, role, muteIcon || null);
|
||||||
|
if (right) {
|
||||||
|
entry.appendChild(right);
|
||||||
|
}
|
||||||
|
|
||||||
return entry;
|
return entry;
|
||||||
}
|
}
|
||||||
@@ -1,7 +1,7 @@
|
|||||||
import { formatTime, formatTimestamp, toggleElement, toggleButtonState } from './utils.js';
|
import { formatTime, formatTimestamp, toggleElement, toggleButtonState } from '../../shared/utils.js';
|
||||||
import { mockCallSession } from './models.js';
|
import { mockCallSession } from '../models.js';
|
||||||
import chatMessage from './chatmessage.js';
|
import chatMessage from '../chat/chatmessage.js';
|
||||||
import store from './store.js';
|
import store from '../store.js';
|
||||||
import {
|
import {
|
||||||
buildUserCountLabel,
|
buildUserCountLabel,
|
||||||
createUserEntryElement,
|
createUserEntryElement,
|
||||||
@@ -10,11 +10,11 @@ import {
|
|||||||
getNetworkQualityDisplay,
|
getNetworkQualityDisplay,
|
||||||
getRemoteVideoPlaceholderText
|
getRemoteVideoPlaceholderText
|
||||||
} from './renderer-ui.js';
|
} from './renderer-ui.js';
|
||||||
import { renderChatMessagesInto } from './renderer-chat.js';
|
import { renderChatMessagesInto } from '../chat/renderer-chat.js';
|
||||||
import {
|
import {
|
||||||
updateParticipantTileName as syncParticipantTileName,
|
updateParticipantTileName as syncParticipantTileName,
|
||||||
updateParticipantTilePlaceholder
|
updateParticipantTilePlaceholder
|
||||||
} from './renderer-participant-grid.js';
|
} from '../participants/renderer-participant-grid.js';
|
||||||
import {
|
import {
|
||||||
adjustVideoSize,
|
adjustVideoSize,
|
||||||
clearParticipantGrid,
|
clearParticipantGrid,
|
||||||
@@ -22,8 +22,8 @@ import {
|
|||||||
removeParticipantTile,
|
removeParticipantTile,
|
||||||
renderParticipantStreamMedia,
|
renderParticipantStreamMedia,
|
||||||
renderSingleRemoteStreamMedia
|
renderSingleRemoteStreamMedia
|
||||||
} from './renderer-media.js';
|
} from '../media/renderer-media.js';
|
||||||
import { createLogger } from './logger.js';
|
import { createLogger } from '../../shared/logger.js';
|
||||||
|
|
||||||
const logger = createLogger('renderer');
|
const logger = createLogger('renderer');
|
||||||
|
|
||||||
@@ -513,7 +513,7 @@ class UIRenderer {
|
|||||||
renderCallEnded() {
|
renderCallEnded() {
|
||||||
logger.debug('Call ended');
|
logger.debug('Call ended');
|
||||||
clearParticipantGrid(this.elements.participantGrid);
|
clearParticipantGrid(this.elements.participantGrid);
|
||||||
window.location.href = './endcall/endcall.html';
|
window.location.href = '/endcall/';
|
||||||
}
|
}
|
||||||
|
|
||||||
renderParticipantLeft(connectionId) {
|
renderParticipantLeft(connectionId) {
|
||||||
@@ -1,3 +1,5 @@
|
|||||||
|
import { createTextElement, textValue } from '../../shared/dom.js';
|
||||||
|
|
||||||
const EMPTY_CONNECTION_IDS_HTML = '<p class="text-gray-500 text-sm">\u6682\u65e0\u53ef\u7528\u7684\u8fde\u63a5ID</p>';
|
const EMPTY_CONNECTION_IDS_HTML = '<p class="text-gray-500 text-sm">\u6682\u65e0\u53ef\u7528\u7684\u8fde\u63a5ID</p>';
|
||||||
const EMPTY_USERS_HTML = '<p class="text-gray-500 text-sm">\u6682\u65e0\u5728\u7ebf\u7528\u6237</p>';
|
const EMPTY_USERS_HTML = '<p class="text-gray-500 text-sm">\u6682\u65e0\u5728\u7ebf\u7528\u6237</p>';
|
||||||
const HALL_LABEL = '\u5927\u5385\uff08\u672a\u52a0\u5165\u623f\u95f4\uff09';
|
const HALL_LABEL = '\u5927\u5385\uff08\u672a\u52a0\u5165\u623f\u95f4\uff09';
|
||||||
@@ -10,13 +12,14 @@ const SELECT_LABEL = '\u9009\u62e9';
|
|||||||
const USER_COUNT_SUFFIX = '\u4eba';
|
const USER_COUNT_SUFFIX = '\u4eba';
|
||||||
const ONLINE_USERS_SUMMARY_SUFFIX = ' \u4e2aWebSocket\u7528\u6237\u5728\u7ebf';
|
const ONLINE_USERS_SUMMARY_SUFFIX = ' \u4e2aWebSocket\u7528\u6237\u5728\u7ebf';
|
||||||
|
|
||||||
function escapeHtml(value) {
|
function getRoleTagClass(role) {
|
||||||
return String(value || '')
|
if (role === 'host') {
|
||||||
.replace(/&/g, '&')
|
return 'text-xs px-2 py-1 rounded-full bg-indigo-500/20 text-indigo-300';
|
||||||
.replace(/</g, '<')
|
}
|
||||||
.replace(/>/g, '>')
|
if (role === 'participant') {
|
||||||
.replace(/"/g, '"')
|
return 'text-xs px-2 py-1 rounded-full bg-white/10 text-gray-300';
|
||||||
.replace(/'/g, ''');
|
}
|
||||||
|
return 'text-xs px-2 py-1 rounded-full bg-emerald-500/20 text-emerald-300';
|
||||||
}
|
}
|
||||||
|
|
||||||
export async function fetchOnlineUsers() {
|
export async function fetchOnlineUsers() {
|
||||||
@@ -115,10 +118,8 @@ export function renderOnlineUsers({ users, currentUserId, onlineUsersList, users
|
|||||||
|
|
||||||
const roomTitle = document.createElement('div');
|
const roomTitle = document.createElement('div');
|
||||||
roomTitle.className = 'flex items-center justify-between mb-2';
|
roomTitle.className = 'flex items-center justify-between mb-2';
|
||||||
roomTitle.innerHTML = `
|
roomTitle.appendChild(createTextElement('span', 'text-sm font-medium text-white', groupName));
|
||||||
<span class="text-sm font-medium text-white">${escapeHtml(groupName)}</span>
|
roomTitle.appendChild(createTextElement('span', 'text-xs text-gray-400', `${roomUsers.length} ${USER_COUNT_SUFFIX}`));
|
||||||
<span class="text-xs text-gray-400">${roomUsers.length} ${USER_COUNT_SUFFIX}</span>
|
|
||||||
`;
|
|
||||||
section.appendChild(roomTitle);
|
section.appendChild(roomTitle);
|
||||||
|
|
||||||
const roomList = document.createElement('div');
|
const roomList = document.createElement('div');
|
||||||
@@ -135,19 +136,31 @@ export function renderOnlineUsers({ users, currentUserId, onlineUsersList, users
|
|||||||
|
|
||||||
const userItem = document.createElement('div');
|
const userItem = document.createElement('div');
|
||||||
userItem.className = 'flex items-center justify-between rounded-lg bg-black/20 px-3 py-2';
|
userItem.className = 'flex items-center justify-between rounded-lg bg-black/20 px-3 py-2';
|
||||||
userItem.innerHTML = `
|
|
||||||
<div class="flex items-center gap-3 min-w-0">
|
const profile = document.createElement('div');
|
||||||
<img src="${escapeHtml(avatar)}" alt="${escapeHtml(userName)}" class="w-8 h-8 rounded-full object-cover">
|
profile.className = 'flex items-center gap-3 min-w-0';
|
||||||
<div class="min-w-0">
|
|
||||||
<div class="text-sm text-white truncate">${escapeHtml(userName)}</div>
|
const avatarImage = document.createElement('img');
|
||||||
<div class="text-xs text-gray-400 truncate">${escapeHtml(identity)}</div>
|
avatarImage.src = textValue(avatar);
|
||||||
</div>
|
avatarImage.alt = textValue(userName);
|
||||||
</div>
|
avatarImage.className = 'w-8 h-8 rounded-full object-cover';
|
||||||
<div class="flex items-center gap-2">
|
profile.appendChild(avatarImage);
|
||||||
<span class="text-xs px-2 py-1 rounded-full ${user.role === 'host' ? 'bg-indigo-500/20 text-indigo-300' : (user.role === 'participant' ? 'bg-white/10 text-gray-300' : 'bg-emerald-500/20 text-emerald-300')}">${roleLabel}</span>
|
|
||||||
${isSelf ? `<span class="text-xs text-gray-500">${SELF_LABEL}</span>` : ''}
|
const info = document.createElement('div');
|
||||||
</div>
|
info.className = 'min-w-0';
|
||||||
`;
|
info.appendChild(createTextElement('div', 'text-sm text-white truncate', userName));
|
||||||
|
info.appendChild(createTextElement('div', 'text-xs text-gray-400 truncate', identity));
|
||||||
|
profile.appendChild(info);
|
||||||
|
|
||||||
|
const status = document.createElement('div');
|
||||||
|
status.className = 'flex items-center gap-2';
|
||||||
|
status.appendChild(createTextElement('span', getRoleTagClass(user.role), roleLabel));
|
||||||
|
if (isSelf) {
|
||||||
|
status.appendChild(createTextElement('span', 'text-xs text-gray-500', SELF_LABEL));
|
||||||
|
}
|
||||||
|
|
||||||
|
userItem.appendChild(profile);
|
||||||
|
userItem.appendChild(status);
|
||||||
roomList.appendChild(userItem);
|
roomList.appendChild(userItem);
|
||||||
});
|
});
|
||||||
|
|
||||||
@@ -1,5 +1,5 @@
|
|||||||
import { Signaling, WebSocketSignaling } from "../../module/signaling.js";
|
import { Signaling, WebSocketSignaling } from '/module/core/signaling.js';
|
||||||
import { createLogger } from './logger.js';
|
import { createLogger } from '../../shared/logger.js';
|
||||||
|
|
||||||
const logger = createLogger('signaling');
|
const logger = createLogger('signaling');
|
||||||
|
|
||||||
@@ -91,7 +91,16 @@ export function buildSocketUserInfoPayload(userInfo, localUser) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
export function sendSocketUserInfo(signaling, payload) {
|
export function sendSocketUserInfo(signaling, payload) {
|
||||||
if (!signaling || typeof signaling.sendMessage !== 'function') {
|
if (!signaling) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (typeof signaling.sendUserInfo === 'function') {
|
||||||
|
signaling.sendUserInfo(payload);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (typeof signaling.sendMessage !== 'function') {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1,14 +1,15 @@
|
|||||||
import { mockCallSession } from './models.js';
|
import { mockCallSession } from './models.js';
|
||||||
import { RenderStreaming } from "../../module/renderstreaming.js";
|
import { RenderStreaming } from '/module/core/renderstreaming.js';
|
||||||
import { getServerConfig, getRTCConfiguration } from "../js/config.js";
|
import { getServerConfig, getRTCConfiguration } from '../render-streaming/config.js';
|
||||||
import { showNotification, generateId } from './utils.js';
|
import { showNotification, generateId } from '../shared/utils.js';
|
||||||
import chatMessage from './chatmessage.js';
|
import chatMessage from './chat/chatmessage.js';
|
||||||
import { DEFAULT_PARTICIPANT_AVATAR, DEFAULT_PARTICIPANT_NAME, buildParticipantsSyncData, omitParticipant, removeParticipant, upsertParticipant } from './participants.js';
|
import { DEFAULT_PARTICIPANT_AVATAR, DEFAULT_PARTICIPANT_NAME, buildParticipantsSyncData, omitParticipant, removeParticipant, upsertParticipant } from './participants/participants.js';
|
||||||
import { AUDIO_CONFIG, VAD_CONFIG, VIDEO_ONLY_CONSTRAINT, buildVideoConstraints, getAdaptiveVideoBitrate, getResolutionLabel, getTargetResolutionBitrate } from './media-config.js';
|
import { AUDIO_CONFIG, VAD_CONFIG, VIDEO_ONLY_CONSTRAINT, buildVideoConstraints, getAdaptiveVideoBitrate, getResolutionLabel, getTargetResolutionBitrate } from './media/media-config.js';
|
||||||
import { buildStatsLogPayload, createAudioAnalyser, getAudioLevel } from './media-monitoring.js';
|
import { buildStatsLogPayload, createAudioAnalyser, getAudioLevel } from './media/media-monitoring.js';
|
||||||
import { bindInviteSocketEvents, buildSocketUserInfoPayload, createSignalingInstance, ensureSignalingStarted, getActiveSignalingInstance, sendInviteSignal, sendSocketUserInfo } from './signaling-session.js';
|
import { bindInviteSocketEvents, buildSocketUserInfoPayload, createSignalingInstance, ensureSignalingStarted, getActiveSignalingInstance, sendInviteSignal, sendSocketUserInfo } from './signaling/signaling-session.js';
|
||||||
import { getNetworkQualityFromSummary, summarizeInboundStats } from './webrtc-stats.js';
|
import { getNetworkQualityFromSummary, summarizeInboundStats } from './media/webrtc-stats.js';
|
||||||
import { createLogger } from './logger.js';
|
import { createLogger } from '../shared/logger.js';
|
||||||
|
import { MeetingRecorder } from './media/meeting-recorder.js';
|
||||||
|
|
||||||
const logger = createLogger('store');
|
const logger = createLogger('store');
|
||||||
class CallStateManager {
|
class CallStateManager {
|
||||||
@@ -27,6 +28,7 @@ class CallStateManager {
|
|||||||
this.listeners = [];
|
this.listeners = [];
|
||||||
this.socketEventHandlers = {};
|
this.socketEventHandlers = {};
|
||||||
this._inviteEventSignaling = null;
|
this._inviteEventSignaling = null;
|
||||||
|
this.meetingRecorder = new MeetingRecorder();
|
||||||
}
|
}
|
||||||
subscribe(callback) {
|
subscribe(callback) {
|
||||||
this.listeners.push(callback);
|
this.listeners.push(callback);
|
||||||
@@ -107,6 +109,123 @@ class CallStateManager {
|
|||||||
await this._updateLocalMediaRefactored(mediaType, value);
|
await this._updateLocalMediaRefactored(mediaType, value);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
async toggleRecording() {
|
||||||
|
const isRecording = this.state.session.localUser.mediaState.recording || false;
|
||||||
|
|
||||||
|
if (isRecording) {
|
||||||
|
return this.stopRecording();
|
||||||
|
}
|
||||||
|
|
||||||
|
return this.startRecording();
|
||||||
|
}
|
||||||
|
async startRecording() {
|
||||||
|
if (this.state.session.status !== 'ongoing') {
|
||||||
|
throw new Error('会议连接成功后才能开始录制');
|
||||||
|
}
|
||||||
|
|
||||||
|
await this.meetingRecorder.start({
|
||||||
|
localStream: this.state.localStream,
|
||||||
|
remoteStream: this.state.remoteStream,
|
||||||
|
remoteStreams: this.state.remoteStreams,
|
||||||
|
connectionId: this.connectionId
|
||||||
|
});
|
||||||
|
await this._updateLocalMediaRefactored('recording', true);
|
||||||
|
|
||||||
|
return {
|
||||||
|
recording: true,
|
||||||
|
message: '开始录制会议'
|
||||||
|
};
|
||||||
|
}
|
||||||
|
async stopRecording() {
|
||||||
|
const result = await this.meetingRecorder.stop();
|
||||||
|
await this._updateLocalMediaRefactored('recording', false);
|
||||||
|
if (!result) {
|
||||||
|
return {
|
||||||
|
recording: false,
|
||||||
|
message: '停止录制会议'
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
try {
|
||||||
|
const uploadResult = await this.uploadRecording(result);
|
||||||
|
return {
|
||||||
|
recording: false,
|
||||||
|
message: uploadResult?.url ? `录制已上传到服务器:${uploadResult.url}` : `录制已上传:${result.filename}`
|
||||||
|
};
|
||||||
|
}
|
||||||
|
catch (error) {
|
||||||
|
logger.error('Recording upload failed:', error);
|
||||||
|
this.meetingRecorder.download(result.blob, result.filename);
|
||||||
|
return {
|
||||||
|
recording: false,
|
||||||
|
message: `上传失败,已下载到本地:${result.filename}`
|
||||||
|
};
|
||||||
|
}
|
||||||
|
}
|
||||||
|
async uploadRecording({ blob, filename }) {
|
||||||
|
const formData = new FormData();
|
||||||
|
const people = this.buildRecordingPeopleMetadata();
|
||||||
|
formData.append('meetingId', this.connectionId || this.state.session.id || 'unknown');
|
||||||
|
formData.append('userId', this.state.session.localUser.id || '');
|
||||||
|
formData.append('filename', filename);
|
||||||
|
if (people.host) {
|
||||||
|
formData.append('host', JSON.stringify(people.host));
|
||||||
|
}
|
||||||
|
formData.append('participants', JSON.stringify(people.participants));
|
||||||
|
formData.append('recording', blob, filename);
|
||||||
|
|
||||||
|
const response = await fetch('/api/recordings', {
|
||||||
|
method: 'POST',
|
||||||
|
body: formData
|
||||||
|
});
|
||||||
|
|
||||||
|
const responseBody = await response.json().catch(() => ({}));
|
||||||
|
if (!response.ok || responseBody.success === false) {
|
||||||
|
throw new Error(responseBody.message || 'Recording upload failed');
|
||||||
|
}
|
||||||
|
|
||||||
|
return responseBody;
|
||||||
|
}
|
||||||
|
buildRecordingPeopleMetadata() {
|
||||||
|
const localUser = this.state.session.localUser || {};
|
||||||
|
const remoteUser = this.state.session.remoteUser || {};
|
||||||
|
const members = Object.entries(this.state.participants || {}).map(([participantId, participant]) => (
|
||||||
|
this._buildRecordingPerson(participant, participant.role || 'participant', participantId)
|
||||||
|
));
|
||||||
|
const remoteHost = members.find(member => member.role === 'host');
|
||||||
|
const localPerson = this._buildRecordingPerson(
|
||||||
|
localUser,
|
||||||
|
this.role === 'host' || localUser.isHost ? 'host' : 'participant',
|
||||||
|
this.selfParticipantId || (this.role === 'host' ? 'host' : 'local')
|
||||||
|
);
|
||||||
|
|
||||||
|
if (localPerson.role === 'host') {
|
||||||
|
return {
|
||||||
|
host: localPerson,
|
||||||
|
participants: members.filter(member => member.role !== 'host')
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
return {
|
||||||
|
host: remoteHost || this._buildRecordingPerson(remoteUser, 'host', 'host'),
|
||||||
|
participants: [
|
||||||
|
localPerson,
|
||||||
|
...members.filter(member => member.role !== 'host' && member.participantId !== localPerson.participantId)
|
||||||
|
]
|
||||||
|
};
|
||||||
|
}
|
||||||
|
_buildRecordingPerson(user = {}, role = 'participant', participantId = '') {
|
||||||
|
return {
|
||||||
|
participantId,
|
||||||
|
userId: user.id || user.userId || '',
|
||||||
|
id: user.id || user.userId || '',
|
||||||
|
name: user.name || '',
|
||||||
|
avatar: user.avatar || '',
|
||||||
|
role,
|
||||||
|
status: user.status || '',
|
||||||
|
mediaState: user.mediaState ? { ...user.mediaState } : undefined
|
||||||
|
};
|
||||||
|
}
|
||||||
async _updateLocalMediaRefactored(mediaType, value) {
|
async _updateLocalMediaRefactored(mediaType, value) {
|
||||||
if (mediaType === 'video' && value) {
|
if (mediaType === 'video' && value) {
|
||||||
await this._enableLocalVideo();
|
await this._enableLocalVideo();
|
||||||
@@ -423,6 +542,14 @@ class CallStateManager {
|
|||||||
this.startActivityDetection(this.state.remoteStream, { isLocal: false });
|
this.startActivityDetection(this.state.remoteStream, { isLocal: false });
|
||||||
}
|
}
|
||||||
async hangUp() {
|
async hangUp() {
|
||||||
|
if (this.meetingRecorder?.isRecording()) {
|
||||||
|
try {
|
||||||
|
await this.stopRecording();
|
||||||
|
}
|
||||||
|
catch (error) {
|
||||||
|
logger.error('Error stopping recording before hangUp:', error);
|
||||||
|
}
|
||||||
|
}
|
||||||
this.clearStatsMessage();
|
this.clearStatsMessage();
|
||||||
this.stopNetworkQualityDetection();
|
this.stopNetworkQualityDetection();
|
||||||
if (this.durationInterval) {
|
if (this.durationInterval) {
|
||||||
@@ -1,4 +1,4 @@
|
|||||||
import { createLogger } from '../logger.js';
|
import { createLogger } from '../shared/logger.js';
|
||||||
|
|
||||||
const logger = createLogger('legacy-connect');
|
const logger = createLogger('legacy-connect');
|
||||||
/**
|
/**
|
||||||
@@ -6,7 +6,7 @@ const logger = createLogger('legacy-connect');
|
|||||||
* 处理初始连接、创建通话和加入通话的功能
|
* 处理初始连接、创建通话和加入通话的功能
|
||||||
*/
|
*/
|
||||||
|
|
||||||
import { showNotification, randomMeetingId } from '../utils.js';
|
import { showNotification, randomMeetingId } from '../shared/utils.js';
|
||||||
|
|
||||||
const MAX_AVATAR_SIZE = 2 * 1024 * 1024; // 2MB
|
const MAX_AVATAR_SIZE = 2 * 1024 * 1024; // 2MB
|
||||||
|
|
||||||
@@ -20,7 +20,7 @@ function joinCall() {
|
|||||||
localStorage.setItem('connectionId', connectionId);
|
localStorage.setItem('connectionId', connectionId);
|
||||||
|
|
||||||
// 跳转到通话界面
|
// 跳转到通话界面
|
||||||
window.location.href = '../index.html';
|
window.location.href = '/';
|
||||||
} else {
|
} else {
|
||||||
showNotification('请输入连接ID', 'error');
|
showNotification('请输入连接ID', 'error');
|
||||||
}
|
}
|
||||||
@@ -39,7 +39,7 @@ function createCall() {
|
|||||||
localStorage.setItem('connectionId', connectionId);
|
localStorage.setItem('connectionId', connectionId);
|
||||||
|
|
||||||
// 跳转到通话界面
|
// 跳转到通话界面
|
||||||
window.location.href = '../index.html';
|
window.location.href = '/';
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -6,7 +6,7 @@
|
|||||||
<title>VideoCall - 重定向</title>
|
<title>VideoCall - 重定向</title>
|
||||||
<script>
|
<script>
|
||||||
// 重定向到SPA入口页面(index.html)
|
// 重定向到SPA入口页面(index.html)
|
||||||
window.location.href = '../index.html';
|
window.location.href = '/';
|
||||||
</script>
|
</script>
|
||||||
</head>
|
</head>
|
||||||
<body>
|
<body>
|
||||||
@@ -1,255 +0,0 @@
|
|||||||
@import url('https://fonts.googleapis.com/css2?family=Inter:wght@300;400;500;600;700&display=swap');
|
|
||||||
|
|
||||||
body {
|
|
||||||
font-family: 'Inter', sans-serif;
|
|
||||||
background: #0f172a;
|
|
||||||
overflow: hidden;
|
|
||||||
}
|
|
||||||
|
|
||||||
.bg-grid {
|
|
||||||
background-image:
|
|
||||||
linear-gradient(rgba(99, 102, 241, 0.1) 1px, transparent 1px),
|
|
||||||
linear-gradient(90deg, rgba(99, 102, 241, 0.1) 1px, transparent 1px);
|
|
||||||
background-size: 40px 40px;
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
@keyframes gridMove {
|
|
||||||
0% { transform: translate(0, 0); }
|
|
||||||
100% { transform: translate(20px, 20px); }
|
|
||||||
}
|
|
||||||
|
|
||||||
.glass {
|
|
||||||
background: rgba(30, 41, 59, 0.7);
|
|
||||||
backdrop-filter: blur(12px);
|
|
||||||
-webkit-backdrop-filter: blur(12px);
|
|
||||||
border: 1px solid rgba(255, 255, 255, 0.1);
|
|
||||||
}
|
|
||||||
|
|
||||||
.glass-strong {
|
|
||||||
background: rgba(15, 23, 42, 0.9);
|
|
||||||
backdrop-filter: blur(20px);
|
|
||||||
-webkit-backdrop-filter: blur(20px);
|
|
||||||
}
|
|
||||||
|
|
||||||
.control-btn {
|
|
||||||
transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
|
|
||||||
}
|
|
||||||
|
|
||||||
.control-btn:hover {
|
|
||||||
transform: translateY(-2px);
|
|
||||||
box-shadow: 0 10px 25px -5px rgba(0, 0, 0, 0.3);
|
|
||||||
}
|
|
||||||
|
|
||||||
.end-call-pulse {
|
|
||||||
animation: pulse-red 2s infinite;
|
|
||||||
}
|
|
||||||
|
|
||||||
@keyframes pulse-red {
|
|
||||||
0%, 100% { box-shadow: 0 0 0 0 rgba(239, 68, 68, 0.7); }
|
|
||||||
50% { box-shadow: 0 0 0 15px rgba(239, 68, 68, 0); }
|
|
||||||
}
|
|
||||||
|
|
||||||
.chat-bubble {
|
|
||||||
animation: messageSlide 0.3s ease-out;
|
|
||||||
margin-bottom: 12px;
|
|
||||||
}
|
|
||||||
|
|
||||||
@keyframes messageSlide {
|
|
||||||
from { opacity: 0; transform: translateX(-10px); }
|
|
||||||
to { opacity: 1; transform: translateX(0); }
|
|
||||||
}
|
|
||||||
|
|
||||||
/* 消息样式 */
|
|
||||||
.message-header {
|
|
||||||
display: flex;
|
|
||||||
align-items: center;
|
|
||||||
gap: 8px;
|
|
||||||
margin-bottom: 4px;
|
|
||||||
}
|
|
||||||
|
|
||||||
.message-header img {
|
|
||||||
width: 24px;
|
|
||||||
height: 24px;
|
|
||||||
border-radius: 50%;
|
|
||||||
object-fit: cover;
|
|
||||||
}
|
|
||||||
|
|
||||||
.message-sender {
|
|
||||||
font-size: 12px;
|
|
||||||
font-weight: 500;
|
|
||||||
}
|
|
||||||
|
|
||||||
.message-time {
|
|
||||||
font-size: 12px;
|
|
||||||
color: #94a3b8;
|
|
||||||
}
|
|
||||||
|
|
||||||
.message-content {
|
|
||||||
padding: 8px 16px;
|
|
||||||
border-radius: 8px;
|
|
||||||
font-size: 14px;
|
|
||||||
max-width: 70%;
|
|
||||||
}
|
|
||||||
|
|
||||||
/* 系统消息 */
|
|
||||||
.message-system .message-sender {
|
|
||||||
color: #60a5fa;
|
|
||||||
}
|
|
||||||
|
|
||||||
.message-system .message-content {
|
|
||||||
background-color: rgba(30, 64, 175, 0.3);
|
|
||||||
color: #ffffff;
|
|
||||||
}
|
|
||||||
|
|
||||||
/* 对方消息 */
|
|
||||||
.message-other .message-sender {
|
|
||||||
color: #a5b4fc;
|
|
||||||
}
|
|
||||||
|
|
||||||
.message-other .message-content {
|
|
||||||
background-color: #1e293b;
|
|
||||||
color: #ffffff;
|
|
||||||
border-top-left-radius: 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
/* 自己的消息 */
|
|
||||||
.message-self {
|
|
||||||
display: flex;
|
|
||||||
flex-direction: column;
|
|
||||||
align-items: flex-end;
|
|
||||||
}
|
|
||||||
|
|
||||||
.message-self .message-header {
|
|
||||||
flex-direction: row-reverse;
|
|
||||||
}
|
|
||||||
|
|
||||||
.message-self .message-sender {
|
|
||||||
color: #4ade80;
|
|
||||||
}
|
|
||||||
|
|
||||||
.message-self .message-content {
|
|
||||||
background-color: #4f46e5;
|
|
||||||
color: #ffffff;
|
|
||||||
border-top-right-radius: 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
/* 图片消息样式 */
|
|
||||||
.message-image-container {
|
|
||||||
display: flex;
|
|
||||||
flex-direction: column;
|
|
||||||
gap: 8px;
|
|
||||||
}
|
|
||||||
|
|
||||||
.message-image {
|
|
||||||
max-width: 200px;
|
|
||||||
max-height: 200px;
|
|
||||||
border-radius: 8px;
|
|
||||||
object-fit: cover;
|
|
||||||
}
|
|
||||||
|
|
||||||
.message-image-name {
|
|
||||||
font-size: 12px;
|
|
||||||
color: rgba(255, 255, 255, 0.7);
|
|
||||||
text-align: center;
|
|
||||||
}
|
|
||||||
|
|
||||||
.message-text {
|
|
||||||
word-wrap: break-word;
|
|
||||||
}
|
|
||||||
|
|
||||||
.custom-scrollbar::-webkit-scrollbar {
|
|
||||||
width: 6px;
|
|
||||||
}
|
|
||||||
.custom-scrollbar::-webkit-scrollbar-track {
|
|
||||||
background: rgba(255, 255, 255, 0.05);
|
|
||||||
}
|
|
||||||
.custom-scrollbar::-webkit-scrollbar-thumb {
|
|
||||||
background: rgba(255, 255, 255, 0.2);
|
|
||||||
border-radius: 3px;
|
|
||||||
}
|
|
||||||
|
|
||||||
.audio-wave {
|
|
||||||
display: flex;
|
|
||||||
align-items: center;
|
|
||||||
gap: 3px;
|
|
||||||
height: 20px;
|
|
||||||
}
|
|
||||||
|
|
||||||
.audio-wave span {
|
|
||||||
width: 3px;
|
|
||||||
background: #10b981;
|
|
||||||
border-radius: 2px;
|
|
||||||
animation: wave 1s ease-in-out infinite;
|
|
||||||
}
|
|
||||||
|
|
||||||
.audio-wave span:nth-child(1) { animation-delay: 0s; height: 40%; }
|
|
||||||
.audio-wave span:nth-child(2) { animation-delay: 0.1s; height: 70%; }
|
|
||||||
.audio-wave span:nth-child(3) { animation-delay: 0.2s; height: 100%; }
|
|
||||||
.audio-wave span:nth-child(4) { animation-delay: 0.3s; height: 60%; }
|
|
||||||
.audio-wave span:nth-child(5) { animation-delay: 0.4s; height: 30%; }
|
|
||||||
|
|
||||||
@keyframes wave {
|
|
||||||
0%, 100% { transform: scaleY(0.5); }
|
|
||||||
50% { transform: scaleY(1); }
|
|
||||||
}
|
|
||||||
|
|
||||||
.video-fade-in {
|
|
||||||
animation: videoFadeIn 0.5s ease-out;
|
|
||||||
}
|
|
||||||
|
|
||||||
@keyframes videoFadeIn {
|
|
||||||
from { opacity: 0; transform: scale(1.05); }
|
|
||||||
to { opacity: 1; transform: scale(1); }
|
|
||||||
}
|
|
||||||
|
|
||||||
/* 数据绑定标记 - 开发调试时显示
|
|
||||||
[data-field]::after {
|
|
||||||
content: attr(data-field);
|
|
||||||
position: absolute;
|
|
||||||
top: -18px;
|
|
||||||
right: 0;
|
|
||||||
background: #f59e0b;
|
|
||||||
color: #000;
|
|
||||||
font-size: 9px;
|
|
||||||
padding: 1px 4px;
|
|
||||||
border-radius: 3px;
|
|
||||||
opacity: 0;
|
|
||||||
transition: opacity 0.2s;
|
|
||||||
pointer-events: none;
|
|
||||||
z-index: 1000;
|
|
||||||
white-space: nowrap;
|
|
||||||
}
|
|
||||||
[data-field]:hover::after { opacity: 1; }
|
|
||||||
[data-field] { position: relative; }*/
|
|
||||||
|
|
||||||
/* 分辨率选项样式 */
|
|
||||||
.resolution-option {
|
|
||||||
color: rgba(255, 255, 255, 0.8);
|
|
||||||
cursor: pointer;
|
|
||||||
transition: all 0.2s;
|
|
||||||
}
|
|
||||||
.resolution-option:hover {
|
|
||||||
color: white;
|
|
||||||
}
|
|
||||||
.resolution-option.active {
|
|
||||||
background: rgba(99, 102, 241, 0.3);
|
|
||||||
color: white;
|
|
||||||
}
|
|
||||||
.resolution-option.active::before {
|
|
||||||
content: '\f00c';
|
|
||||||
font-family: 'Font Awesome 6 Free';
|
|
||||||
font-weight: 900;
|
|
||||||
font-size: 10px;
|
|
||||||
margin-right: 6px;
|
|
||||||
color: #818cf8;
|
|
||||||
}
|
|
||||||
|
|
||||||
/* 更多选项菜单动画 */
|
|
||||||
#moreOptionsMenu {
|
|
||||||
animation: menuFadeIn 0.15s ease-out;
|
|
||||||
}
|
|
||||||
@keyframes menuFadeIn {
|
|
||||||
from { opacity: 0; transform: translateX(-50%) translateY(8px); }
|
|
||||||
to { opacity: 1; transform: translateX(-50%) translateY(0); }
|
|
||||||
}
|
|
||||||
@@ -3,14 +3,14 @@
|
|||||||
* 处理通话结束后的操作,如重新连接或返回连接界面
|
* 处理通话结束后的操作,如重新连接或返回连接界面
|
||||||
*/
|
*/
|
||||||
|
|
||||||
import { showNotification } from '../utils.js';
|
import { showNotification } from '../shared/utils.js';
|
||||||
|
|
||||||
// 重新连接
|
// 重新连接
|
||||||
function reconnectCall() {
|
function reconnectCall() {
|
||||||
showNotification('正在重新连接...');
|
showNotification('正在重新连接...');
|
||||||
|
|
||||||
// 跳转到通话界面
|
// 跳转到通话界面
|
||||||
window.location.href = '../index.html';
|
window.location.href = '/';
|
||||||
}
|
}
|
||||||
|
|
||||||
// 离开
|
// 离开
|
||||||
@@ -19,7 +19,7 @@ function leaveCall() {
|
|||||||
localStorage.removeItem('connectionId');
|
localStorage.removeItem('connectionId');
|
||||||
|
|
||||||
// 跳转到连接界面
|
// 跳转到连接界面
|
||||||
window.location.href = '../connect/connect.html';
|
window.location.href = '/connect/';
|
||||||
}
|
}
|
||||||
|
|
||||||
// 绑定事件监听器
|
// 绑定事件监听器
|
||||||
|
|||||||
@@ -6,7 +6,7 @@
|
|||||||
<title>VideoCall - 通话结束</title>
|
<title>VideoCall - 通话结束</title>
|
||||||
<script src="https://cdn.tailwindcss.com"></script>
|
<script src="https://cdn.tailwindcss.com"></script>
|
||||||
<link href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/6.4.0/css/all.min.css" rel="stylesheet">
|
<link href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/6.4.0/css/all.min.css" rel="stylesheet">
|
||||||
<link rel="stylesheet" href="../css/style.css">
|
<link rel="stylesheet" href="/styles/style.css">
|
||||||
</head>
|
</head>
|
||||||
<body class="h-screen w-screen flex flex-col text-white bg-grid relative">
|
<body class="h-screen w-screen flex flex-col text-white bg-grid relative">
|
||||||
<!--
|
<!--
|
||||||
227
client/public/recordings/index.html
Normal file
@@ -0,0 +1,227 @@
|
|||||||
|
<!DOCTYPE html>
|
||||||
|
<html lang="zh-CN">
|
||||||
|
|
||||||
|
<head>
|
||||||
|
<meta charset="UTF-8">
|
||||||
|
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
||||||
|
<title>VideoCall - 录制管理</title>
|
||||||
|
<script src="https://cdn.tailwindcss.com"></script>
|
||||||
|
<link href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/6.4.0/css/all.min.css" rel="stylesheet">
|
||||||
|
<link rel="stylesheet" href="/styles/style.css">
|
||||||
|
</head>
|
||||||
|
|
||||||
|
<body class="min-h-screen w-screen text-white bg-grid recordings-page">
|
||||||
|
<div class="min-h-screen bg-black/70 flex flex-col">
|
||||||
|
<header class="glass-strong h-16 flex items-center justify-between px-6 border-b border-white/10">
|
||||||
|
<div class="flex items-center gap-3 min-w-0">
|
||||||
|
<div class="w-10 h-10 bg-gradient-to-br from-indigo-500 to-purple-600 rounded-xl flex items-center justify-center shadow-lg">
|
||||||
|
<i class="fas fa-video text-white text-lg"></i>
|
||||||
|
</div>
|
||||||
|
<div class="min-w-0">
|
||||||
|
<h1 class="font-bold text-lg tracking-tight">录制管理后台</h1>
|
||||||
|
<div class="flex items-center gap-3 text-xs text-gray-400">
|
||||||
|
<span class="w-2 h-2 bg-green-500 rounded-full"></span>
|
||||||
|
<span id="recordingRootText" class="truncate max-w-[60vw]">recordings</span>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div class="flex items-center gap-3">
|
||||||
|
<a href="/" class="recordings-icon-btn glass" title="返回视频通话">
|
||||||
|
<i class="fas fa-phone"></i>
|
||||||
|
</a>
|
||||||
|
<button id="refreshBtn" class="recordings-icon-btn glass" title="刷新列表">
|
||||||
|
<i class="fas fa-rotate-right"></i>
|
||||||
|
</button>
|
||||||
|
</div>
|
||||||
|
</header>
|
||||||
|
|
||||||
|
<main class="recordings-shell flex-1 overflow-hidden">
|
||||||
|
<section class="recordings-toolbar glass">
|
||||||
|
<div class="recordings-stat">
|
||||||
|
<span class="recordings-stat-value" id="totalCount">0</span>
|
||||||
|
<span class="recordings-stat-label">总录制</span>
|
||||||
|
</div>
|
||||||
|
<div class="recordings-stat">
|
||||||
|
<span class="recordings-stat-value" id="meetingCount">0</span>
|
||||||
|
<span class="recordings-stat-label">会议数</span>
|
||||||
|
</div>
|
||||||
|
<div class="recordings-stat">
|
||||||
|
<span class="recordings-stat-value" id="storageSize">0 MB</span>
|
||||||
|
<span class="recordings-stat-label">占用空间</span>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div class="recordings-search">
|
||||||
|
<i class="fas fa-magnifying-glass text-gray-500"></i>
|
||||||
|
<input id="searchInput" type="search" placeholder="搜索会议、文件或用户" autocomplete="off">
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div class="recordings-format-filter" id="typeFilterControl">
|
||||||
|
<select id="typeFilter" class="recordings-select-native" aria-hidden="true" tabindex="-1">
|
||||||
|
<option value="all">全部格式</option>
|
||||||
|
<option value="mp4">MP4</option>
|
||||||
|
<option value="webm">WebM</option>
|
||||||
|
</select>
|
||||||
|
<button id="typeFilterButton" class="recordings-filter-trigger" type="button" aria-haspopup="listbox" aria-expanded="false">
|
||||||
|
<span id="typeFilterText">全部格式</span>
|
||||||
|
<i class="fas fa-chevron-down"></i>
|
||||||
|
</button>
|
||||||
|
<div id="typeFilterMenu" class="recordings-filter-menu hidden" role="listbox" aria-label="录制格式筛选">
|
||||||
|
<button class="recordings-filter-option is-active" type="button" role="option" aria-selected="true" data-type-value="all">
|
||||||
|
<span>全部格式</span>
|
||||||
|
<small>所有录制</small>
|
||||||
|
</button>
|
||||||
|
<button class="recordings-filter-option" type="button" role="option" aria-selected="false" data-type-value="mp4">
|
||||||
|
<span>MP4</span>
|
||||||
|
<small>标准视频</small>
|
||||||
|
</button>
|
||||||
|
<button class="recordings-filter-option" type="button" role="option" aria-selected="false" data-type-value="webm">
|
||||||
|
<span>WebM</span>
|
||||||
|
<small>网页录制</small>
|
||||||
|
</button>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</section>
|
||||||
|
|
||||||
|
<section class="recordings-content">
|
||||||
|
<aside class="recordings-upload glass">
|
||||||
|
<div class="flex items-center justify-between mb-5">
|
||||||
|
<div>
|
||||||
|
<h2 class="text-base font-semibold">新增录制</h2>
|
||||||
|
<p class="text-xs text-gray-500 mt-1">上传到 recordings 目录</p>
|
||||||
|
</div>
|
||||||
|
<div class="w-10 h-10 rounded-xl bg-indigo-500/20 flex items-center justify-center text-indigo-300">
|
||||||
|
<i class="fas fa-cloud-arrow-up"></i>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<form id="uploadForm" class="space-y-4">
|
||||||
|
<label class="recordings-dropzone" for="recordingFile">
|
||||||
|
<input id="recordingFile" type="file" accept="video/mp4,video/webm" class="hidden" required>
|
||||||
|
<i class="fas fa-file-video text-2xl text-indigo-300"></i>
|
||||||
|
<span id="fileNameText">选择 MP4 或 WebM 文件</span>
|
||||||
|
</label>
|
||||||
|
|
||||||
|
<div>
|
||||||
|
<label class="recordings-label" for="uploadMeetingId">会议 ID</label>
|
||||||
|
<input id="uploadMeetingId" class="recordings-input" type="text" placeholder="例如 665-261-326" required>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div>
|
||||||
|
<label class="recordings-label" for="uploadUserId">用户 ID</label>
|
||||||
|
<input id="uploadUserId" class="recordings-input" type="text" placeholder="可选">
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<button id="uploadBtn" class="recordings-primary-btn" type="submit">
|
||||||
|
<i class="fas fa-plus"></i>
|
||||||
|
<span>上传录制</span>
|
||||||
|
</button>
|
||||||
|
</form>
|
||||||
|
</aside>
|
||||||
|
|
||||||
|
<section class="recordings-list glass">
|
||||||
|
<div class="recordings-list-head">
|
||||||
|
<div>
|
||||||
|
<h2 class="text-base font-semibold">录制文件</h2>
|
||||||
|
<p class="text-xs text-gray-500 mt-1" id="listSummary">等待加载</p>
|
||||||
|
</div>
|
||||||
|
<button id="clearSearchBtn" class="recordings-text-btn hidden">
|
||||||
|
<i class="fas fa-xmark"></i>
|
||||||
|
<span>清空筛选</span>
|
||||||
|
</button>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div id="loadingState" class="recordings-empty">
|
||||||
|
<div class="w-10 h-10 border-4 border-indigo-500 border-t-transparent rounded-full animate-spin"></div>
|
||||||
|
<span>正在读取 recordings 目录...</span>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div id="emptyState" class="recordings-empty hidden">
|
||||||
|
<i class="fas fa-folder-open text-3xl text-gray-500"></i>
|
||||||
|
<span>还没有录制文件</span>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div id="recordingsTableWrap" class="recordings-table-wrap hidden">
|
||||||
|
<table class="recordings-table">
|
||||||
|
<thead>
|
||||||
|
<tr>
|
||||||
|
<th>文件</th>
|
||||||
|
<th>会议</th>
|
||||||
|
<th>房主</th>
|
||||||
|
<th>参与者</th>
|
||||||
|
<th>大小</th>
|
||||||
|
<th>上传时间</th>
|
||||||
|
<th>操作</th>
|
||||||
|
</tr>
|
||||||
|
</thead>
|
||||||
|
<tbody id="recordingsTableBody"></tbody>
|
||||||
|
</table>
|
||||||
|
</div>
|
||||||
|
</section>
|
||||||
|
|
||||||
|
<aside class="recordings-preview glass">
|
||||||
|
<div class="recordings-preview-video">
|
||||||
|
<video id="previewVideo" controls playsinline></video>
|
||||||
|
<div id="previewPlaceholder" class="recordings-preview-placeholder">
|
||||||
|
<i class="fas fa-play text-2xl"></i>
|
||||||
|
<span>选择一条录制预览</span>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div class="recordings-preview-meta">
|
||||||
|
<h2 id="previewTitle">未选择录制</h2>
|
||||||
|
<div id="previewDetails" class="space-y-3 text-sm text-gray-400">
|
||||||
|
<p>从左侧列表选择文件后,可播放、下载、编辑或删除。</p>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</aside>
|
||||||
|
</section>
|
||||||
|
</main>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div id="editDialog" class="fixed inset-0 bg-black/70 hidden items-center justify-center z-50">
|
||||||
|
<form id="editForm" class="recordings-dialog glass">
|
||||||
|
<div class="flex items-center justify-between mb-5">
|
||||||
|
<div>
|
||||||
|
<h2 class="text-lg font-semibold">编辑录制信息</h2>
|
||||||
|
<p class="text-xs text-gray-500 mt-1" id="editFilenameText"></p>
|
||||||
|
</div>
|
||||||
|
<button type="button" id="closeEditBtn" class="recordings-icon-btn" title="关闭">
|
||||||
|
<i class="fas fa-xmark"></i>
|
||||||
|
</button>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div class="space-y-4">
|
||||||
|
<div>
|
||||||
|
<label class="recordings-label" for="editMeetingId">会议 ID</label>
|
||||||
|
<input id="editMeetingId" class="recordings-input" type="text" required>
|
||||||
|
</div>
|
||||||
|
<div>
|
||||||
|
<label class="recordings-label" for="editOriginalFilename">显示名称</label>
|
||||||
|
<input id="editOriginalFilename" class="recordings-input" type="text" required>
|
||||||
|
</div>
|
||||||
|
<div>
|
||||||
|
<label class="recordings-label" for="editUserId">房主用户 ID</label>
|
||||||
|
<input id="editUserId" class="recordings-input" type="text">
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div class="flex gap-3 mt-6">
|
||||||
|
<button type="button" id="cancelEditBtn" class="recordings-secondary-btn">取消</button>
|
||||||
|
<button type="submit" class="recordings-primary-btn">
|
||||||
|
<i class="fas fa-floppy-disk"></i>
|
||||||
|
<span>保存</span>
|
||||||
|
</button>
|
||||||
|
</div>
|
||||||
|
</form>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div id="notification" class="recordings-notification glass">
|
||||||
|
<i class="fas fa-info-circle text-indigo-400"></i>
|
||||||
|
<span id="notificationText"></span>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<script type="module" src="/recordings/recordings-admin.js"></script>
|
||||||
|
</body>
|
||||||
|
|
||||||
|
</html>
|
||||||
530
client/public/recordings/recordings-admin.js
Normal file
@@ -0,0 +1,530 @@
|
|||||||
|
const state = {
|
||||||
|
recordings: [],
|
||||||
|
filtered: [],
|
||||||
|
selectedKey: '',
|
||||||
|
editing: null
|
||||||
|
};
|
||||||
|
|
||||||
|
const elements = {
|
||||||
|
refreshBtn: document.getElementById('refreshBtn'),
|
||||||
|
searchInput: document.getElementById('searchInput'),
|
||||||
|
typeFilter: document.getElementById('typeFilter'),
|
||||||
|
typeFilterControl: document.getElementById('typeFilterControl'),
|
||||||
|
typeFilterButton: document.getElementById('typeFilterButton'),
|
||||||
|
typeFilterText: document.getElementById('typeFilterText'),
|
||||||
|
typeFilterMenu: document.getElementById('typeFilterMenu'),
|
||||||
|
clearSearchBtn: document.getElementById('clearSearchBtn'),
|
||||||
|
uploadForm: document.getElementById('uploadForm'),
|
||||||
|
uploadBtn: document.getElementById('uploadBtn'),
|
||||||
|
recordingFile: document.getElementById('recordingFile'),
|
||||||
|
fileNameText: document.getElementById('fileNameText'),
|
||||||
|
uploadMeetingId: document.getElementById('uploadMeetingId'),
|
||||||
|
uploadUserId: document.getElementById('uploadUserId'),
|
||||||
|
totalCount: document.getElementById('totalCount'),
|
||||||
|
meetingCount: document.getElementById('meetingCount'),
|
||||||
|
storageSize: document.getElementById('storageSize'),
|
||||||
|
recordingRootText: document.getElementById('recordingRootText'),
|
||||||
|
listSummary: document.getElementById('listSummary'),
|
||||||
|
loadingState: document.getElementById('loadingState'),
|
||||||
|
emptyState: document.getElementById('emptyState'),
|
||||||
|
recordingsTableWrap: document.getElementById('recordingsTableWrap'),
|
||||||
|
recordingsTableBody: document.getElementById('recordingsTableBody'),
|
||||||
|
previewVideo: document.getElementById('previewVideo'),
|
||||||
|
previewPlaceholder: document.getElementById('previewPlaceholder'),
|
||||||
|
previewTitle: document.getElementById('previewTitle'),
|
||||||
|
previewDetails: document.getElementById('previewDetails'),
|
||||||
|
editDialog: document.getElementById('editDialog'),
|
||||||
|
editForm: document.getElementById('editForm'),
|
||||||
|
editFilenameText: document.getElementById('editFilenameText'),
|
||||||
|
editMeetingId: document.getElementById('editMeetingId'),
|
||||||
|
editOriginalFilename: document.getElementById('editOriginalFilename'),
|
||||||
|
editUserId: document.getElementById('editUserId'),
|
||||||
|
closeEditBtn: document.getElementById('closeEditBtn'),
|
||||||
|
cancelEditBtn: document.getElementById('cancelEditBtn'),
|
||||||
|
notification: document.getElementById('notification'),
|
||||||
|
notificationText: document.getElementById('notificationText')
|
||||||
|
};
|
||||||
|
|
||||||
|
const typeFilterLabels = {
|
||||||
|
all: '全部格式',
|
||||||
|
mp4: 'MP4',
|
||||||
|
webm: 'WebM'
|
||||||
|
};
|
||||||
|
|
||||||
|
function recordingKey(recording) {
|
||||||
|
return `${recording.meetingId}/${recording.filename}`;
|
||||||
|
}
|
||||||
|
|
||||||
|
function escapeHtml(value) {
|
||||||
|
return String(value || '')
|
||||||
|
.replace(/&/g, '&')
|
||||||
|
.replace(/</g, '<')
|
||||||
|
.replace(/>/g, '>')
|
||||||
|
.replace(/"/g, '"')
|
||||||
|
.replace(/'/g, ''');
|
||||||
|
}
|
||||||
|
|
||||||
|
function formatBytes(bytes) {
|
||||||
|
const value = Number(bytes) || 0;
|
||||||
|
if (value < 1024) {
|
||||||
|
return `${value} B`;
|
||||||
|
}
|
||||||
|
|
||||||
|
const units = ['KB', 'MB', 'GB', 'TB'];
|
||||||
|
let size = value / 1024;
|
||||||
|
let index = 0;
|
||||||
|
while (size >= 1024 && index < units.length - 1) {
|
||||||
|
size /= 1024;
|
||||||
|
index += 1;
|
||||||
|
}
|
||||||
|
return `${size.toFixed(size >= 10 ? 1 : 2)} ${units[index]}`;
|
||||||
|
}
|
||||||
|
|
||||||
|
function formatDate(value) {
|
||||||
|
if (!value) {
|
||||||
|
return '-';
|
||||||
|
}
|
||||||
|
|
||||||
|
const date = new Date(value);
|
||||||
|
if (Number.isNaN(date.getTime())) {
|
||||||
|
return '-';
|
||||||
|
}
|
||||||
|
|
||||||
|
return date.toLocaleString('zh-CN', {
|
||||||
|
year: 'numeric',
|
||||||
|
month: '2-digit',
|
||||||
|
day: '2-digit',
|
||||||
|
hour: '2-digit',
|
||||||
|
minute: '2-digit'
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
function getPersonId(person) {
|
||||||
|
return person?.userId || person?.id || '';
|
||||||
|
}
|
||||||
|
|
||||||
|
function getPersonName(person) {
|
||||||
|
return person?.name || getPersonId(person) || '-';
|
||||||
|
}
|
||||||
|
|
||||||
|
function getRecordingHost(recording) {
|
||||||
|
return recording.host || (recording.userId ? {
|
||||||
|
userId: recording.userId,
|
||||||
|
id: recording.userId,
|
||||||
|
role: 'host'
|
||||||
|
} : null);
|
||||||
|
}
|
||||||
|
|
||||||
|
function getRecordingParticipants(recording) {
|
||||||
|
return Array.isArray(recording.participants) ? recording.participants : [];
|
||||||
|
}
|
||||||
|
|
||||||
|
function getPeopleSearchText(recording) {
|
||||||
|
const host = getRecordingHost(recording);
|
||||||
|
const participants = getRecordingParticipants(recording);
|
||||||
|
return [
|
||||||
|
host?.participantId,
|
||||||
|
host?.userId,
|
||||||
|
host?.id,
|
||||||
|
host?.name,
|
||||||
|
...participants.flatMap(participant => [
|
||||||
|
participant.participantId,
|
||||||
|
participant.userId,
|
||||||
|
participant.id,
|
||||||
|
participant.name
|
||||||
|
])
|
||||||
|
].filter(Boolean).join(' ');
|
||||||
|
}
|
||||||
|
|
||||||
|
function renderPersonSummary(person) {
|
||||||
|
if (!person) {
|
||||||
|
return '-';
|
||||||
|
}
|
||||||
|
|
||||||
|
const name = getPersonName(person);
|
||||||
|
const id = getPersonId(person);
|
||||||
|
return id && id !== name ? `${name} (${id})` : name;
|
||||||
|
}
|
||||||
|
|
||||||
|
function renderPeopleList(people) {
|
||||||
|
if (!people.length) {
|
||||||
|
return '<div class="recordings-person-empty">暂无参与者</div>';
|
||||||
|
}
|
||||||
|
|
||||||
|
return people.map((person) => `
|
||||||
|
<div class="recordings-person">
|
||||||
|
<img src="${escapeHtml(person.avatar || '/images/p2.png')}" alt="">
|
||||||
|
<div>
|
||||||
|
<strong>${escapeHtml(getPersonName(person))}</strong>
|
||||||
|
<span>${escapeHtml(getPersonId(person) || person.participantId || '-')}</span>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
`).join('');
|
||||||
|
}
|
||||||
|
|
||||||
|
function setTypeFilter(value) {
|
||||||
|
const nextValue = typeFilterLabels[value] ? value : 'all';
|
||||||
|
elements.typeFilter.value = nextValue;
|
||||||
|
elements.typeFilterText.textContent = typeFilterLabels[nextValue];
|
||||||
|
|
||||||
|
elements.typeFilterMenu.querySelectorAll('[data-type-value]').forEach((option) => {
|
||||||
|
const isActive = option.dataset.typeValue === nextValue;
|
||||||
|
option.classList.toggle('is-active', isActive);
|
||||||
|
option.setAttribute('aria-selected', String(isActive));
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
function setTypeFilterMenuOpen(isOpen) {
|
||||||
|
elements.typeFilterControl.classList.toggle('is-open', isOpen);
|
||||||
|
elements.typeFilterMenu.classList.toggle('hidden', !isOpen);
|
||||||
|
elements.typeFilterButton.setAttribute('aria-expanded', String(isOpen));
|
||||||
|
}
|
||||||
|
|
||||||
|
function showNotification(message, isError = false) {
|
||||||
|
elements.notificationText.textContent = message;
|
||||||
|
elements.notification.classList.toggle('recordings-notification-error', isError);
|
||||||
|
elements.notification.classList.add('recordings-notification-visible');
|
||||||
|
window.clearTimeout(showNotification.timer);
|
||||||
|
showNotification.timer = window.setTimeout(() => {
|
||||||
|
elements.notification.classList.remove('recordings-notification-visible');
|
||||||
|
}, 2600);
|
||||||
|
}
|
||||||
|
|
||||||
|
async function requestJson(url, options = {}) {
|
||||||
|
const response = await fetch(url, options);
|
||||||
|
const payload = await response.json().catch(() => ({}));
|
||||||
|
if (!response.ok || payload.success === false) {
|
||||||
|
throw new Error(payload.message || `请求失败: ${response.status}`);
|
||||||
|
}
|
||||||
|
return payload;
|
||||||
|
}
|
||||||
|
|
||||||
|
function setLoading(isLoading) {
|
||||||
|
elements.loadingState.classList.toggle('hidden', !isLoading);
|
||||||
|
elements.recordingsTableWrap.classList.toggle('hidden', isLoading || state.filtered.length === 0);
|
||||||
|
elements.emptyState.classList.toggle('hidden', isLoading || state.filtered.length > 0);
|
||||||
|
}
|
||||||
|
|
||||||
|
async function loadRecordings() {
|
||||||
|
setLoading(true);
|
||||||
|
try {
|
||||||
|
const payload = await requestJson('/api/recordings');
|
||||||
|
state.recordings = payload.recordings || [];
|
||||||
|
elements.recordingRootText.textContent = payload.root || 'recordings';
|
||||||
|
applyFilters();
|
||||||
|
const selected = state.filtered.find(item => recordingKey(item) === state.selectedKey) || state.filtered[0];
|
||||||
|
selectRecording(selected || null);
|
||||||
|
} catch (error) {
|
||||||
|
state.recordings = [];
|
||||||
|
applyFilters();
|
||||||
|
selectRecording(null);
|
||||||
|
showNotification(error.message, true);
|
||||||
|
} finally {
|
||||||
|
setLoading(false);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
function applyFilters() {
|
||||||
|
const query = elements.searchInput.value.trim().toLowerCase();
|
||||||
|
const type = elements.typeFilter.value;
|
||||||
|
|
||||||
|
state.filtered = state.recordings.filter((recording) => {
|
||||||
|
const extension = (recording.filename || '').split('.').pop().toLowerCase();
|
||||||
|
const haystack = [
|
||||||
|
recording.meetingId,
|
||||||
|
recording.filename,
|
||||||
|
recording.originalFilename,
|
||||||
|
recording.userId,
|
||||||
|
getPeopleSearchText(recording)
|
||||||
|
].join(' ').toLowerCase();
|
||||||
|
return (type === 'all' || extension === type) && (!query || haystack.includes(query));
|
||||||
|
});
|
||||||
|
|
||||||
|
elements.clearSearchBtn.classList.toggle('hidden', !query && type === 'all');
|
||||||
|
renderSummary();
|
||||||
|
renderTable();
|
||||||
|
setLoading(false);
|
||||||
|
}
|
||||||
|
|
||||||
|
function renderSummary() {
|
||||||
|
const meetings = new Set(state.recordings.map(recording => recording.meetingId));
|
||||||
|
const totalSize = state.recordings.reduce((sum, recording) => sum + (Number(recording.size) || 0), 0);
|
||||||
|
|
||||||
|
elements.totalCount.textContent = state.recordings.length;
|
||||||
|
elements.meetingCount.textContent = meetings.size;
|
||||||
|
elements.storageSize.textContent = formatBytes(totalSize);
|
||||||
|
elements.listSummary.textContent = `当前显示 ${state.filtered.length} 条,共 ${state.recordings.length} 条`;
|
||||||
|
}
|
||||||
|
|
||||||
|
function renderTable() {
|
||||||
|
elements.recordingsTableBody.innerHTML = state.filtered.map((recording) => {
|
||||||
|
const key = recordingKey(recording);
|
||||||
|
const active = key === state.selectedKey ? 'recordings-row-active' : '';
|
||||||
|
const ext = escapeHtml((recording.filename || '').split('.').pop().toUpperCase());
|
||||||
|
const host = getRecordingHost(recording);
|
||||||
|
const participants = getRecordingParticipants(recording);
|
||||||
|
|
||||||
|
return `
|
||||||
|
<tr class="${active}" data-key="${escapeHtml(key)}">
|
||||||
|
<td>
|
||||||
|
<button class="recordings-file-cell" data-action="select" data-key="${escapeHtml(key)}">
|
||||||
|
<span class="recordings-file-icon">${ext}</span>
|
||||||
|
<span class="min-w-0">
|
||||||
|
<span class="recordings-file-name">${escapeHtml(recording.originalFilename || recording.filename)}</span>
|
||||||
|
<span class="recordings-file-sub">${escapeHtml(recording.filename)}</span>
|
||||||
|
</span>
|
||||||
|
</button>
|
||||||
|
</td>
|
||||||
|
<td>${escapeHtml(recording.meetingId)}</td>
|
||||||
|
<td>${escapeHtml(renderPersonSummary(host))}</td>
|
||||||
|
<td>${participants.length}</td>
|
||||||
|
<td>${formatBytes(recording.size)}</td>
|
||||||
|
<td>${formatDate(recording.uploadedAt)}</td>
|
||||||
|
<td>
|
||||||
|
<div class="recordings-actions">
|
||||||
|
<button class="recordings-icon-btn" data-action="preview" data-key="${escapeHtml(key)}" title="预览">
|
||||||
|
<i class="fas fa-play"></i>
|
||||||
|
</button>
|
||||||
|
<a class="recordings-icon-btn" href="${escapeHtml(recording.downloadUrl)}" title="下载">
|
||||||
|
<i class="fas fa-download"></i>
|
||||||
|
</a>
|
||||||
|
<button class="recordings-icon-btn" data-action="edit" data-key="${escapeHtml(key)}" title="编辑">
|
||||||
|
<i class="fas fa-pen"></i>
|
||||||
|
</button>
|
||||||
|
<button class="recordings-icon-btn recordings-danger" data-action="delete" data-key="${escapeHtml(key)}" title="删除">
|
||||||
|
<i class="fas fa-trash"></i>
|
||||||
|
</button>
|
||||||
|
</div>
|
||||||
|
</td>
|
||||||
|
</tr>
|
||||||
|
`;
|
||||||
|
}).join('');
|
||||||
|
}
|
||||||
|
|
||||||
|
function findRecording(key) {
|
||||||
|
return state.recordings.find(recording => recordingKey(recording) === key);
|
||||||
|
}
|
||||||
|
|
||||||
|
function selectRecording(recording) {
|
||||||
|
if (!recording) {
|
||||||
|
state.selectedKey = '';
|
||||||
|
elements.previewVideo.removeAttribute('src');
|
||||||
|
elements.previewVideo.load();
|
||||||
|
elements.previewPlaceholder.classList.remove('hidden');
|
||||||
|
elements.previewTitle.textContent = '未选择录制';
|
||||||
|
elements.previewDetails.innerHTML = '<p>从左侧列表选择文件后,可播放、下载、编辑或删除。</p>';
|
||||||
|
renderTable();
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
state.selectedKey = recordingKey(recording);
|
||||||
|
const host = getRecordingHost(recording);
|
||||||
|
const participants = getRecordingParticipants(recording);
|
||||||
|
elements.previewVideo.src = recording.streamUrl;
|
||||||
|
elements.previewPlaceholder.classList.add('hidden');
|
||||||
|
elements.previewTitle.textContent = recording.originalFilename || recording.filename;
|
||||||
|
elements.previewDetails.innerHTML = `
|
||||||
|
<div class="recordings-detail-row"><span>会议 ID</span><strong>${escapeHtml(recording.meetingId)}</strong></div>
|
||||||
|
<div class="recordings-detail-row"><span>文件名</span><strong>${escapeHtml(recording.filename)}</strong></div>
|
||||||
|
<div class="recordings-detail-row"><span>格式</span><strong>${escapeHtml(recording.mimetype)}</strong></div>
|
||||||
|
<div class="recordings-detail-row"><span>大小</span><strong>${formatBytes(recording.size)}</strong></div>
|
||||||
|
<div class="recordings-detail-row"><span>用户 ID</span><strong>${escapeHtml(recording.userId || '-')}</strong></div>
|
||||||
|
<div class="recordings-detail-row"><span>上传时间</span><strong>${formatDate(recording.uploadedAt)}</strong></div>
|
||||||
|
<div class="recordings-people-section">
|
||||||
|
<div class="recordings-people-title">房主</div>
|
||||||
|
${renderPeopleList(host ? [host] : [])}
|
||||||
|
</div>
|
||||||
|
<div class="recordings-people-section">
|
||||||
|
<div class="recordings-people-title">参与者 (${participants.length})</div>
|
||||||
|
${renderPeopleList(participants)}
|
||||||
|
</div>
|
||||||
|
<div class="recordings-preview-actions">
|
||||||
|
<a class="recordings-primary-btn" href="${escapeHtml(recording.downloadUrl)}">
|
||||||
|
<i class="fas fa-download"></i>
|
||||||
|
<span>下载</span>
|
||||||
|
</a>
|
||||||
|
<button class="recordings-secondary-btn" type="button" data-preview-action="edit">编辑</button>
|
||||||
|
</div>
|
||||||
|
`;
|
||||||
|
renderTable();
|
||||||
|
}
|
||||||
|
|
||||||
|
function openEdit(recording) {
|
||||||
|
if (!recording) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
state.editing = recording;
|
||||||
|
elements.editFilenameText.textContent = recording.filename;
|
||||||
|
elements.editMeetingId.value = recording.meetingId || '';
|
||||||
|
elements.editOriginalFilename.value = recording.originalFilename || recording.filename || '';
|
||||||
|
elements.editUserId.value = recording.userId || '';
|
||||||
|
elements.editDialog.classList.remove('hidden');
|
||||||
|
elements.editDialog.classList.add('flex');
|
||||||
|
elements.editMeetingId.focus();
|
||||||
|
}
|
||||||
|
|
||||||
|
function closeEdit() {
|
||||||
|
state.editing = null;
|
||||||
|
elements.editDialog.classList.add('hidden');
|
||||||
|
elements.editDialog.classList.remove('flex');
|
||||||
|
}
|
||||||
|
|
||||||
|
async function handleUpload(event) {
|
||||||
|
event.preventDefault();
|
||||||
|
const file = elements.recordingFile.files[0];
|
||||||
|
if (!file) {
|
||||||
|
showNotification('请选择录制文件', true);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
const formData = new FormData();
|
||||||
|
formData.append('recording', file, file.name);
|
||||||
|
formData.append('filename', file.name);
|
||||||
|
formData.append('meetingId', elements.uploadMeetingId.value.trim());
|
||||||
|
formData.append('userId', elements.uploadUserId.value.trim());
|
||||||
|
|
||||||
|
elements.uploadBtn.disabled = true;
|
||||||
|
try {
|
||||||
|
await requestJson('/api/recordings', {
|
||||||
|
method: 'POST',
|
||||||
|
body: formData
|
||||||
|
});
|
||||||
|
elements.uploadForm.reset();
|
||||||
|
elements.fileNameText.textContent = '选择 MP4 或 WebM 文件';
|
||||||
|
showNotification('录制已上传');
|
||||||
|
await loadRecordings();
|
||||||
|
} catch (error) {
|
||||||
|
showNotification(error.message, true);
|
||||||
|
} finally {
|
||||||
|
elements.uploadBtn.disabled = false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
async function handleEdit(event) {
|
||||||
|
event.preventDefault();
|
||||||
|
if (!state.editing) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
const recording = state.editing;
|
||||||
|
try {
|
||||||
|
const payload = await requestJson(`/api/recordings/${encodeURIComponent(recording.meetingId)}/${encodeURIComponent(recording.filename)}`, {
|
||||||
|
method: 'PATCH',
|
||||||
|
headers: { 'Content-Type': 'application/json' },
|
||||||
|
body: JSON.stringify({
|
||||||
|
meetingId: elements.editMeetingId.value.trim(),
|
||||||
|
originalFilename: elements.editOriginalFilename.value.trim(),
|
||||||
|
userId: elements.editUserId.value.trim()
|
||||||
|
})
|
||||||
|
});
|
||||||
|
state.selectedKey = recordingKey(payload.recording);
|
||||||
|
closeEdit();
|
||||||
|
showNotification('录制信息已更新');
|
||||||
|
await loadRecordings();
|
||||||
|
} catch (error) {
|
||||||
|
showNotification(error.message, true);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
async function deleteRecording(recording) {
|
||||||
|
if (!recording) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
const confirmed = window.confirm(`确定删除录制文件 "${recording.originalFilename || recording.filename}" 吗?`);
|
||||||
|
if (!confirmed) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
try {
|
||||||
|
await requestJson(`/api/recordings/${encodeURIComponent(recording.meetingId)}/${encodeURIComponent(recording.filename)}`, {
|
||||||
|
method: 'DELETE'
|
||||||
|
});
|
||||||
|
if (state.selectedKey === recordingKey(recording)) {
|
||||||
|
state.selectedKey = '';
|
||||||
|
}
|
||||||
|
showNotification('录制已删除');
|
||||||
|
await loadRecordings();
|
||||||
|
} catch (error) {
|
||||||
|
showNotification(error.message, true);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
function bindEvents() {
|
||||||
|
elements.refreshBtn.addEventListener('click', loadRecordings);
|
||||||
|
elements.searchInput.addEventListener('input', applyFilters);
|
||||||
|
elements.typeFilter.addEventListener('change', applyFilters);
|
||||||
|
elements.typeFilterButton.addEventListener('click', () => {
|
||||||
|
setTypeFilterMenuOpen(!elements.typeFilterControl.classList.contains('is-open'));
|
||||||
|
});
|
||||||
|
elements.typeFilterMenu.addEventListener('click', (event) => {
|
||||||
|
const option = event.target.closest('[data-type-value]');
|
||||||
|
if (!option) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
setTypeFilter(option.dataset.typeValue);
|
||||||
|
setTypeFilterMenuOpen(false);
|
||||||
|
applyFilters();
|
||||||
|
});
|
||||||
|
document.addEventListener('click', (event) => {
|
||||||
|
if (!elements.typeFilterControl.contains(event.target)) {
|
||||||
|
setTypeFilterMenuOpen(false);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
document.addEventListener('keydown', (event) => {
|
||||||
|
if (event.key === 'Escape') {
|
||||||
|
setTypeFilterMenuOpen(false);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
elements.clearSearchBtn.addEventListener('click', () => {
|
||||||
|
elements.searchInput.value = '';
|
||||||
|
setTypeFilter('all');
|
||||||
|
applyFilters();
|
||||||
|
});
|
||||||
|
elements.recordingFile.addEventListener('change', () => {
|
||||||
|
const file = elements.recordingFile.files[0];
|
||||||
|
elements.fileNameText.textContent = file ? file.name : '选择 MP4 或 WebM 文件';
|
||||||
|
});
|
||||||
|
elements.uploadForm.addEventListener('submit', handleUpload);
|
||||||
|
elements.editForm.addEventListener('submit', handleEdit);
|
||||||
|
elements.closeEditBtn.addEventListener('click', closeEdit);
|
||||||
|
elements.cancelEditBtn.addEventListener('click', closeEdit);
|
||||||
|
elements.editDialog.addEventListener('click', (event) => {
|
||||||
|
if (event.target === elements.editDialog) {
|
||||||
|
closeEdit();
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
elements.recordingsTableBody.addEventListener('click', (event) => {
|
||||||
|
const control = event.target.closest('[data-action]');
|
||||||
|
if (!control) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
const recording = findRecording(control.dataset.key);
|
||||||
|
const action = control.dataset.action;
|
||||||
|
if (action === 'select' || action === 'preview') {
|
||||||
|
selectRecording(recording);
|
||||||
|
if (action === 'preview') {
|
||||||
|
elements.previewVideo.play().catch(() => undefined);
|
||||||
|
}
|
||||||
|
} else if (action === 'edit') {
|
||||||
|
openEdit(recording);
|
||||||
|
} else if (action === 'delete') {
|
||||||
|
deleteRecording(recording);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
elements.previewDetails.addEventListener('click', (event) => {
|
||||||
|
const control = event.target.closest('[data-preview-action]');
|
||||||
|
if (control && control.dataset.previewAction === 'edit') {
|
||||||
|
openEdit(findRecording(state.selectedKey));
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
bindEvents();
|
||||||
|
setTypeFilter(elements.typeFilter.value);
|
||||||
|
loadRecordings();
|
||||||
@@ -1,5 +1,5 @@
|
|||||||
import { Observer, Sender } from "../module/sender.js";
|
import { Observer, Sender } from "/module/core/sender.js";
|
||||||
import { InputRemoting } from "../module/inputremoting.js";
|
import { InputRemoting } from "/module/input/inputremoting.js";
|
||||||
|
|
||||||
export class VideoPlayer {
|
export class VideoPlayer {
|
||||||
constructor() {
|
constructor() {
|
||||||
@@ -1,61 +0,0 @@
|
|||||||
export function createMessageElement(message, formatTimestamp) {
|
|
||||||
const messageDiv = document.createElement('div');
|
|
||||||
let messageClass = 'chat-bubble';
|
|
||||||
|
|
||||||
if (message.type === 'system') {
|
|
||||||
messageClass += ' message-system';
|
|
||||||
} else if (message.isSelf) {
|
|
||||||
messageClass += ' message-self';
|
|
||||||
} else {
|
|
||||||
messageClass += ' message-other';
|
|
||||||
}
|
|
||||||
|
|
||||||
messageDiv.className = messageClass;
|
|
||||||
messageDiv.dataset.messageId = message.id;
|
|
||||||
|
|
||||||
const contentHTML = message.type === 'file' && message.content.startsWith('data:image/')
|
|
||||||
? `
|
|
||||||
<div class="message-image-container">
|
|
||||||
<img src="${message.content}" class="message-image" alt="${message.fileName || '\u56fe\u7247'}">
|
|
||||||
${message.fileName ? `<div class="message-image-name">${message.fileName}</div>` : ''}
|
|
||||||
</div>
|
|
||||||
`
|
|
||||||
: `
|
|
||||||
<div class="message-text">
|
|
||||||
${message.content}
|
|
||||||
</div>
|
|
||||||
`;
|
|
||||||
|
|
||||||
messageDiv.innerHTML = `
|
|
||||||
<div class="message-header">
|
|
||||||
<img src="${message.senderAvatar}" class="message-avatar">
|
|
||||||
<div>
|
|
||||||
<span class="message-sender">${message.senderName}</span>
|
|
||||||
<span class="message-time">${formatTimestamp(message.timestamp)}</span>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
<div class="message-content">
|
|
||||||
${contentHTML}
|
|
||||||
</div>
|
|
||||||
`;
|
|
||||||
|
|
||||||
return messageDiv;
|
|
||||||
}
|
|
||||||
|
|
||||||
export function renderChatMessagesInto(container, messages, formatTimestamp) {
|
|
||||||
if (!container) return;
|
|
||||||
|
|
||||||
container.innerHTML = '';
|
|
||||||
|
|
||||||
const startTimeElement = document.createElement('div');
|
|
||||||
startTimeElement.className = 'text-center text-xs text-gray-500 my-4';
|
|
||||||
const startTime = messages[0]?.timestamp || new Date().toISOString();
|
|
||||||
startTimeElement.textContent = `\u901a\u8bdd\u5f00\u59cb ${formatTimestamp(startTime)}`;
|
|
||||||
container.appendChild(startTimeElement);
|
|
||||||
|
|
||||||
messages.forEach(message => {
|
|
||||||
container.appendChild(createMessageElement(message, formatTimestamp));
|
|
||||||
});
|
|
||||||
|
|
||||||
container.scrollTop = container.scrollHeight;
|
|
||||||
}
|
|
||||||
18
client/public/shared/dom.js
Normal file
@@ -0,0 +1,18 @@
|
|||||||
|
export function textValue(value, fallback = '') {
|
||||||
|
return value == null || value === '' ? fallback : String(value);
|
||||||
|
}
|
||||||
|
|
||||||
|
export function createTextElement(tagName, className, value, fallback = '') {
|
||||||
|
const element = document.createElement(tagName);
|
||||||
|
if (className) {
|
||||||
|
element.className = className;
|
||||||
|
}
|
||||||
|
element.textContent = textValue(value, fallback);
|
||||||
|
return element;
|
||||||
|
}
|
||||||
|
|
||||||
|
export function createIconElement(className) {
|
||||||
|
const icon = document.createElement('i');
|
||||||
|
icon.className = className;
|
||||||
|
return icon;
|
||||||
|
}
|
||||||
914
client/public/styles/style.css
Normal file
@@ -0,0 +1,914 @@
|
|||||||
|
@import url('https://fonts.googleapis.com/css2?family=Inter:wght@300;400;500;600;700&display=swap');
|
||||||
|
|
||||||
|
body {
|
||||||
|
font-family: 'Inter', sans-serif;
|
||||||
|
background: #0f172a;
|
||||||
|
overflow: hidden;
|
||||||
|
}
|
||||||
|
|
||||||
|
.bg-grid {
|
||||||
|
background-image:
|
||||||
|
linear-gradient(rgba(99, 102, 241, 0.1) 1px, transparent 1px),
|
||||||
|
linear-gradient(90deg, rgba(99, 102, 241, 0.1) 1px, transparent 1px);
|
||||||
|
background-size: 40px 40px;
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
@keyframes gridMove {
|
||||||
|
0% { transform: translate(0, 0); }
|
||||||
|
100% { transform: translate(20px, 20px); }
|
||||||
|
}
|
||||||
|
|
||||||
|
.glass {
|
||||||
|
background: rgba(30, 41, 59, 0.7);
|
||||||
|
backdrop-filter: blur(12px);
|
||||||
|
-webkit-backdrop-filter: blur(12px);
|
||||||
|
border: 1px solid rgba(255, 255, 255, 0.1);
|
||||||
|
}
|
||||||
|
|
||||||
|
.glass-strong {
|
||||||
|
background: rgba(15, 23, 42, 0.9);
|
||||||
|
backdrop-filter: blur(20px);
|
||||||
|
-webkit-backdrop-filter: blur(20px);
|
||||||
|
}
|
||||||
|
|
||||||
|
.control-btn {
|
||||||
|
transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
|
||||||
|
}
|
||||||
|
|
||||||
|
.control-btn:hover {
|
||||||
|
transform: translateY(-2px);
|
||||||
|
box-shadow: 0 10px 25px -5px rgba(0, 0, 0, 0.3);
|
||||||
|
}
|
||||||
|
|
||||||
|
.end-call-pulse {
|
||||||
|
animation: pulse-red 2s infinite;
|
||||||
|
}
|
||||||
|
|
||||||
|
@keyframes pulse-red {
|
||||||
|
0%, 100% { box-shadow: 0 0 0 0 rgba(239, 68, 68, 0.7); }
|
||||||
|
50% { box-shadow: 0 0 0 15px rgba(239, 68, 68, 0); }
|
||||||
|
}
|
||||||
|
|
||||||
|
.chat-bubble {
|
||||||
|
animation: messageSlide 0.3s ease-out;
|
||||||
|
margin-bottom: 12px;
|
||||||
|
}
|
||||||
|
|
||||||
|
@keyframes messageSlide {
|
||||||
|
from { opacity: 0; transform: translateX(-10px); }
|
||||||
|
to { opacity: 1; transform: translateX(0); }
|
||||||
|
}
|
||||||
|
|
||||||
|
/* 消息样式 */
|
||||||
|
.message-header {
|
||||||
|
display: flex;
|
||||||
|
align-items: center;
|
||||||
|
gap: 8px;
|
||||||
|
margin-bottom: 4px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.message-header img {
|
||||||
|
width: 24px;
|
||||||
|
height: 24px;
|
||||||
|
border-radius: 50%;
|
||||||
|
object-fit: cover;
|
||||||
|
}
|
||||||
|
|
||||||
|
.message-sender {
|
||||||
|
font-size: 12px;
|
||||||
|
font-weight: 500;
|
||||||
|
}
|
||||||
|
|
||||||
|
.message-time {
|
||||||
|
font-size: 12px;
|
||||||
|
color: #94a3b8;
|
||||||
|
}
|
||||||
|
|
||||||
|
.message-content {
|
||||||
|
padding: 8px 16px;
|
||||||
|
border-radius: 8px;
|
||||||
|
font-size: 14px;
|
||||||
|
max-width: 70%;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* 系统消息 */
|
||||||
|
.message-system .message-sender {
|
||||||
|
color: #60a5fa;
|
||||||
|
}
|
||||||
|
|
||||||
|
.message-system .message-content {
|
||||||
|
background-color: rgba(30, 64, 175, 0.3);
|
||||||
|
color: #ffffff;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* 对方消息 */
|
||||||
|
.message-other .message-sender {
|
||||||
|
color: #a5b4fc;
|
||||||
|
}
|
||||||
|
|
||||||
|
.message-other .message-content {
|
||||||
|
background-color: #1e293b;
|
||||||
|
color: #ffffff;
|
||||||
|
border-top-left-radius: 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* 自己的消息 */
|
||||||
|
.message-self {
|
||||||
|
display: flex;
|
||||||
|
flex-direction: column;
|
||||||
|
align-items: flex-end;
|
||||||
|
}
|
||||||
|
|
||||||
|
.message-self .message-header {
|
||||||
|
flex-direction: row-reverse;
|
||||||
|
}
|
||||||
|
|
||||||
|
.message-self .message-sender {
|
||||||
|
color: #4ade80;
|
||||||
|
}
|
||||||
|
|
||||||
|
.message-self .message-content {
|
||||||
|
background-color: #4f46e5;
|
||||||
|
color: #ffffff;
|
||||||
|
border-top-right-radius: 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* 图片消息样式 */
|
||||||
|
.message-image-container {
|
||||||
|
display: flex;
|
||||||
|
flex-direction: column;
|
||||||
|
gap: 8px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.message-image {
|
||||||
|
max-width: 200px;
|
||||||
|
max-height: 200px;
|
||||||
|
border-radius: 8px;
|
||||||
|
object-fit: cover;
|
||||||
|
}
|
||||||
|
|
||||||
|
.message-image-name {
|
||||||
|
font-size: 12px;
|
||||||
|
color: rgba(255, 255, 255, 0.7);
|
||||||
|
text-align: center;
|
||||||
|
}
|
||||||
|
|
||||||
|
.message-text {
|
||||||
|
word-wrap: break-word;
|
||||||
|
}
|
||||||
|
|
||||||
|
.custom-scrollbar::-webkit-scrollbar {
|
||||||
|
width: 6px;
|
||||||
|
}
|
||||||
|
.custom-scrollbar::-webkit-scrollbar-track {
|
||||||
|
background: rgba(255, 255, 255, 0.05);
|
||||||
|
}
|
||||||
|
.custom-scrollbar::-webkit-scrollbar-thumb {
|
||||||
|
background: rgba(255, 255, 255, 0.2);
|
||||||
|
border-radius: 3px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.audio-wave {
|
||||||
|
display: flex;
|
||||||
|
align-items: center;
|
||||||
|
gap: 3px;
|
||||||
|
height: 20px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.audio-wave span {
|
||||||
|
width: 3px;
|
||||||
|
background: #10b981;
|
||||||
|
border-radius: 2px;
|
||||||
|
animation: wave 1s ease-in-out infinite;
|
||||||
|
}
|
||||||
|
|
||||||
|
.audio-wave span:nth-child(1) { animation-delay: 0s; height: 40%; }
|
||||||
|
.audio-wave span:nth-child(2) { animation-delay: 0.1s; height: 70%; }
|
||||||
|
.audio-wave span:nth-child(3) { animation-delay: 0.2s; height: 100%; }
|
||||||
|
.audio-wave span:nth-child(4) { animation-delay: 0.3s; height: 60%; }
|
||||||
|
.audio-wave span:nth-child(5) { animation-delay: 0.4s; height: 30%; }
|
||||||
|
|
||||||
|
@keyframes wave {
|
||||||
|
0%, 100% { transform: scaleY(0.5); }
|
||||||
|
50% { transform: scaleY(1); }
|
||||||
|
}
|
||||||
|
|
||||||
|
.video-fade-in {
|
||||||
|
animation: videoFadeIn 0.5s ease-out;
|
||||||
|
}
|
||||||
|
|
||||||
|
@keyframes videoFadeIn {
|
||||||
|
from { opacity: 0; transform: scale(1.05); }
|
||||||
|
to { opacity: 1; transform: scale(1); }
|
||||||
|
}
|
||||||
|
|
||||||
|
/* 数据绑定标记 - 开发调试时显示
|
||||||
|
[data-field]::after {
|
||||||
|
content: attr(data-field);
|
||||||
|
position: absolute;
|
||||||
|
top: -18px;
|
||||||
|
right: 0;
|
||||||
|
background: #f59e0b;
|
||||||
|
color: #000;
|
||||||
|
font-size: 9px;
|
||||||
|
padding: 1px 4px;
|
||||||
|
border-radius: 3px;
|
||||||
|
opacity: 0;
|
||||||
|
transition: opacity 0.2s;
|
||||||
|
pointer-events: none;
|
||||||
|
z-index: 1000;
|
||||||
|
white-space: nowrap;
|
||||||
|
}
|
||||||
|
[data-field]:hover::after { opacity: 1; }
|
||||||
|
[data-field] { position: relative; }*/
|
||||||
|
|
||||||
|
/* 分辨率选项样式 */
|
||||||
|
.resolution-option {
|
||||||
|
color: rgba(255, 255, 255, 0.8);
|
||||||
|
cursor: pointer;
|
||||||
|
transition: all 0.2s;
|
||||||
|
}
|
||||||
|
.resolution-option:hover {
|
||||||
|
color: white;
|
||||||
|
}
|
||||||
|
.resolution-option.active {
|
||||||
|
background: rgba(99, 102, 241, 0.3);
|
||||||
|
color: white;
|
||||||
|
}
|
||||||
|
.resolution-option.active::before {
|
||||||
|
content: '\f00c';
|
||||||
|
font-family: 'Font Awesome 6 Free';
|
||||||
|
font-weight: 900;
|
||||||
|
font-size: 10px;
|
||||||
|
margin-right: 6px;
|
||||||
|
color: #818cf8;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* 更多选项菜单动画 */
|
||||||
|
#moreOptionsMenu {
|
||||||
|
animation: menuFadeIn 0.15s ease-out;
|
||||||
|
}
|
||||||
|
@keyframes menuFadeIn {
|
||||||
|
from { opacity: 0; transform: translateX(-50%) translateY(8px); }
|
||||||
|
to { opacity: 1; transform: translateX(-50%) translateY(0); }
|
||||||
|
}
|
||||||
|
|
||||||
|
.recordings-page {
|
||||||
|
overflow: hidden;
|
||||||
|
}
|
||||||
|
|
||||||
|
.recordings-shell {
|
||||||
|
padding: 24px;
|
||||||
|
display: flex;
|
||||||
|
flex-direction: column;
|
||||||
|
gap: 16px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.recordings-toolbar {
|
||||||
|
position: relative;
|
||||||
|
z-index: 50;
|
||||||
|
min-height: 76px;
|
||||||
|
border-radius: 16px;
|
||||||
|
padding: 14px;
|
||||||
|
display: grid;
|
||||||
|
grid-template-columns: repeat(3, minmax(112px, max-content)) minmax(220px, 1fr) 152px;
|
||||||
|
align-items: center;
|
||||||
|
gap: 12px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.recordings-stat {
|
||||||
|
min-width: 112px;
|
||||||
|
padding: 6px 10px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.recordings-stat-value {
|
||||||
|
display: block;
|
||||||
|
font-size: 20px;
|
||||||
|
line-height: 1.1;
|
||||||
|
font-weight: 700;
|
||||||
|
color: #ffffff;
|
||||||
|
}
|
||||||
|
|
||||||
|
.recordings-stat-label {
|
||||||
|
display: block;
|
||||||
|
margin-top: 4px;
|
||||||
|
font-size: 12px;
|
||||||
|
color: #94a3b8;
|
||||||
|
}
|
||||||
|
|
||||||
|
.recordings-search,
|
||||||
|
.recordings-input {
|
||||||
|
height: 42px;
|
||||||
|
border-radius: 12px;
|
||||||
|
border: 1px solid rgba(255, 255, 255, 0.12);
|
||||||
|
background: rgba(15, 23, 42, 0.58);
|
||||||
|
color: #ffffff;
|
||||||
|
}
|
||||||
|
|
||||||
|
.recordings-search {
|
||||||
|
display: flex;
|
||||||
|
align-items: center;
|
||||||
|
gap: 10px;
|
||||||
|
padding: 0 14px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.recordings-search input {
|
||||||
|
width: 100%;
|
||||||
|
min-width: 0;
|
||||||
|
border: 0;
|
||||||
|
outline: 0;
|
||||||
|
background: transparent;
|
||||||
|
color: #ffffff;
|
||||||
|
font-size: 14px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.recordings-search input::placeholder,
|
||||||
|
.recordings-input::placeholder {
|
||||||
|
color: #64748b;
|
||||||
|
}
|
||||||
|
|
||||||
|
.recordings-format-filter {
|
||||||
|
position: relative;
|
||||||
|
z-index: 20;
|
||||||
|
min-width: 152px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.recordings-select-native {
|
||||||
|
position: absolute;
|
||||||
|
inset: 0;
|
||||||
|
width: 100%;
|
||||||
|
height: 42px;
|
||||||
|
opacity: 0;
|
||||||
|
pointer-events: none;
|
||||||
|
}
|
||||||
|
|
||||||
|
.recordings-filter-trigger {
|
||||||
|
width: 100%;
|
||||||
|
height: 42px;
|
||||||
|
padding: 0 12px 0 14px;
|
||||||
|
border: 1px solid rgba(129, 140, 248, 0.45);
|
||||||
|
border-radius: 12px;
|
||||||
|
background: linear-gradient(180deg, rgba(30, 41, 59, 0.96), rgba(15, 23, 42, 0.94));
|
||||||
|
color: #e5e7eb;
|
||||||
|
display: flex;
|
||||||
|
align-items: center;
|
||||||
|
justify-content: space-between;
|
||||||
|
gap: 10px;
|
||||||
|
font-size: 14px;
|
||||||
|
font-weight: 700;
|
||||||
|
box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.08), 0 10px 24px rgba(2, 6, 23, 0.24);
|
||||||
|
}
|
||||||
|
|
||||||
|
.recordings-filter-trigger i {
|
||||||
|
color: #c7d2fe;
|
||||||
|
font-size: 12px;
|
||||||
|
transition: transform 0.2s ease;
|
||||||
|
}
|
||||||
|
|
||||||
|
.recordings-filter-trigger:hover,
|
||||||
|
.recordings-format-filter.is-open .recordings-filter-trigger {
|
||||||
|
border-color: rgba(165, 180, 252, 0.9);
|
||||||
|
background: linear-gradient(180deg, rgba(49, 46, 129, 0.72), rgba(30, 41, 59, 0.96));
|
||||||
|
}
|
||||||
|
|
||||||
|
.recordings-filter-trigger:focus-visible {
|
||||||
|
border-color: rgba(129, 140, 248, 0.95);
|
||||||
|
box-shadow: 0 0 0 3px rgba(99, 102, 241, 0.24), inset 0 1px 0 rgba(255, 255, 255, 0.1);
|
||||||
|
}
|
||||||
|
|
||||||
|
.recordings-format-filter.is-open .recordings-filter-trigger i {
|
||||||
|
transform: rotate(180deg);
|
||||||
|
}
|
||||||
|
|
||||||
|
.recordings-filter-menu {
|
||||||
|
position: absolute;
|
||||||
|
top: calc(100% + 8px);
|
||||||
|
right: 0;
|
||||||
|
left: 0;
|
||||||
|
z-index: 40;
|
||||||
|
padding: 6px;
|
||||||
|
border: 1px solid rgba(148, 163, 184, 0.18);
|
||||||
|
border-radius: 14px;
|
||||||
|
background: rgba(15, 23, 42, 0.98);
|
||||||
|
box-shadow: 0 18px 40px rgba(2, 6, 23, 0.42), inset 0 1px 0 rgba(255, 255, 255, 0.06);
|
||||||
|
}
|
||||||
|
|
||||||
|
.recordings-filter-option {
|
||||||
|
position: relative;
|
||||||
|
width: 100%;
|
||||||
|
min-height: 50px;
|
||||||
|
padding: 8px 34px 8px 10px;
|
||||||
|
border: 0;
|
||||||
|
border-radius: 10px;
|
||||||
|
background: transparent;
|
||||||
|
color: #e2e8f0;
|
||||||
|
display: flex;
|
||||||
|
flex-direction: column;
|
||||||
|
align-items: flex-start;
|
||||||
|
justify-content: center;
|
||||||
|
gap: 2px;
|
||||||
|
text-align: left;
|
||||||
|
cursor: pointer;
|
||||||
|
transition: background 0.18s, color 0.18s;
|
||||||
|
}
|
||||||
|
|
||||||
|
.recordings-filter-option span {
|
||||||
|
font-size: 14px;
|
||||||
|
font-weight: 700;
|
||||||
|
}
|
||||||
|
|
||||||
|
.recordings-filter-option small {
|
||||||
|
color: #64748b;
|
||||||
|
font-size: 11px;
|
||||||
|
line-height: 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
.recordings-filter-option:hover,
|
||||||
|
.recordings-filter-option.is-active {
|
||||||
|
background: rgba(79, 70, 229, 0.22);
|
||||||
|
color: #ffffff;
|
||||||
|
}
|
||||||
|
|
||||||
|
.recordings-filter-option.is-active::after {
|
||||||
|
content: "\f00c";
|
||||||
|
position: absolute;
|
||||||
|
top: 50%;
|
||||||
|
right: 12px;
|
||||||
|
transform: translateY(-50%);
|
||||||
|
color: #a5b4fc;
|
||||||
|
font-family: "Font Awesome 6 Free";
|
||||||
|
font-size: 12px;
|
||||||
|
font-weight: 900;
|
||||||
|
}
|
||||||
|
|
||||||
|
.recordings-content {
|
||||||
|
min-height: 0;
|
||||||
|
flex: 1;
|
||||||
|
display: grid;
|
||||||
|
grid-template-columns: 280px minmax(420px, 1fr) 360px;
|
||||||
|
gap: 16px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.recordings-upload,
|
||||||
|
.recordings-list,
|
||||||
|
.recordings-preview {
|
||||||
|
min-height: 0;
|
||||||
|
border-radius: 16px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.recordings-upload {
|
||||||
|
padding: 18px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.recordings-list {
|
||||||
|
padding: 0;
|
||||||
|
display: flex;
|
||||||
|
flex-direction: column;
|
||||||
|
overflow: hidden;
|
||||||
|
}
|
||||||
|
|
||||||
|
.recordings-list-head {
|
||||||
|
min-height: 72px;
|
||||||
|
padding: 18px;
|
||||||
|
display: flex;
|
||||||
|
align-items: center;
|
||||||
|
justify-content: space-between;
|
||||||
|
gap: 12px;
|
||||||
|
border-bottom: 1px solid rgba(255, 255, 255, 0.1);
|
||||||
|
}
|
||||||
|
|
||||||
|
.recordings-preview {
|
||||||
|
padding: 16px;
|
||||||
|
display: flex;
|
||||||
|
flex-direction: column;
|
||||||
|
gap: 16px;
|
||||||
|
overflow: hidden;
|
||||||
|
}
|
||||||
|
|
||||||
|
.recordings-dropzone {
|
||||||
|
min-height: 132px;
|
||||||
|
border-radius: 14px;
|
||||||
|
border: 1px dashed rgba(129, 140, 248, 0.55);
|
||||||
|
background: rgba(79, 70, 229, 0.08);
|
||||||
|
color: #c7d2fe;
|
||||||
|
display: flex;
|
||||||
|
flex-direction: column;
|
||||||
|
align-items: center;
|
||||||
|
justify-content: center;
|
||||||
|
gap: 10px;
|
||||||
|
text-align: center;
|
||||||
|
cursor: pointer;
|
||||||
|
transition: background 0.2s, border-color 0.2s;
|
||||||
|
}
|
||||||
|
|
||||||
|
.recordings-dropzone:hover {
|
||||||
|
background: rgba(79, 70, 229, 0.16);
|
||||||
|
border-color: rgba(165, 180, 252, 0.8);
|
||||||
|
}
|
||||||
|
|
||||||
|
.recordings-label {
|
||||||
|
display: block;
|
||||||
|
margin-bottom: 8px;
|
||||||
|
font-size: 12px;
|
||||||
|
color: #94a3b8;
|
||||||
|
}
|
||||||
|
|
||||||
|
.recordings-input {
|
||||||
|
width: 100%;
|
||||||
|
padding: 0 12px;
|
||||||
|
outline: 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
.recordings-input:focus,
|
||||||
|
.recordings-search:focus-within {
|
||||||
|
border-color: rgba(129, 140, 248, 0.9);
|
||||||
|
box-shadow: 0 0 0 3px rgba(99, 102, 241, 0.22);
|
||||||
|
}
|
||||||
|
|
||||||
|
.recordings-primary-btn,
|
||||||
|
.recordings-secondary-btn,
|
||||||
|
.recordings-text-btn,
|
||||||
|
.recordings-icon-btn {
|
||||||
|
border: 0;
|
||||||
|
outline: 0;
|
||||||
|
cursor: pointer;
|
||||||
|
transition: transform 0.2s, background 0.2s, color 0.2s, border-color 0.2s;
|
||||||
|
}
|
||||||
|
|
||||||
|
.recordings-primary-btn,
|
||||||
|
.recordings-secondary-btn {
|
||||||
|
min-height: 42px;
|
||||||
|
border-radius: 12px;
|
||||||
|
display: inline-flex;
|
||||||
|
align-items: center;
|
||||||
|
justify-content: center;
|
||||||
|
gap: 8px;
|
||||||
|
font-size: 14px;
|
||||||
|
font-weight: 600;
|
||||||
|
}
|
||||||
|
|
||||||
|
.recordings-primary-btn {
|
||||||
|
width: 100%;
|
||||||
|
background: #4f46e5;
|
||||||
|
color: #ffffff;
|
||||||
|
}
|
||||||
|
|
||||||
|
.recordings-primary-btn:hover {
|
||||||
|
background: #4338ca;
|
||||||
|
}
|
||||||
|
|
||||||
|
.recordings-primary-btn:disabled {
|
||||||
|
opacity: 0.55;
|
||||||
|
cursor: wait;
|
||||||
|
}
|
||||||
|
|
||||||
|
.recordings-secondary-btn {
|
||||||
|
width: 100%;
|
||||||
|
background: rgba(255, 255, 255, 0.08);
|
||||||
|
color: #e2e8f0;
|
||||||
|
border: 1px solid rgba(255, 255, 255, 0.1);
|
||||||
|
}
|
||||||
|
|
||||||
|
.recordings-secondary-btn:hover {
|
||||||
|
background: rgba(255, 255, 255, 0.14);
|
||||||
|
}
|
||||||
|
|
||||||
|
.recordings-text-btn {
|
||||||
|
display: inline-flex;
|
||||||
|
align-items: center;
|
||||||
|
gap: 8px;
|
||||||
|
color: #c7d2fe;
|
||||||
|
background: transparent;
|
||||||
|
font-size: 13px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.recordings-icon-btn {
|
||||||
|
width: 38px;
|
||||||
|
height: 38px;
|
||||||
|
border-radius: 11px;
|
||||||
|
display: inline-flex;
|
||||||
|
align-items: center;
|
||||||
|
justify-content: center;
|
||||||
|
color: #cbd5e1;
|
||||||
|
background: rgba(255, 255, 255, 0.06);
|
||||||
|
}
|
||||||
|
|
||||||
|
.recordings-icon-btn:hover {
|
||||||
|
transform: translateY(-1px);
|
||||||
|
color: #ffffff;
|
||||||
|
background: rgba(255, 255, 255, 0.12);
|
||||||
|
}
|
||||||
|
|
||||||
|
.recordings-danger {
|
||||||
|
color: #fca5a5;
|
||||||
|
}
|
||||||
|
|
||||||
|
.recordings-danger:hover {
|
||||||
|
color: #ffffff;
|
||||||
|
background: rgba(239, 68, 68, 0.75);
|
||||||
|
}
|
||||||
|
|
||||||
|
.recordings-table-wrap {
|
||||||
|
flex: 1;
|
||||||
|
min-height: 0;
|
||||||
|
overflow: auto;
|
||||||
|
}
|
||||||
|
|
||||||
|
.recordings-table {
|
||||||
|
width: 100%;
|
||||||
|
border-collapse: collapse;
|
||||||
|
table-layout: fixed;
|
||||||
|
}
|
||||||
|
|
||||||
|
.recordings-table th,
|
||||||
|
.recordings-table td {
|
||||||
|
padding: 13px 14px;
|
||||||
|
border-bottom: 1px solid rgba(255, 255, 255, 0.08);
|
||||||
|
text-align: left;
|
||||||
|
vertical-align: middle;
|
||||||
|
}
|
||||||
|
|
||||||
|
.recordings-table th {
|
||||||
|
position: sticky;
|
||||||
|
top: 0;
|
||||||
|
z-index: 1;
|
||||||
|
background: rgba(15, 23, 42, 0.95);
|
||||||
|
color: #94a3b8;
|
||||||
|
font-size: 12px;
|
||||||
|
font-weight: 600;
|
||||||
|
}
|
||||||
|
|
||||||
|
.recordings-table th:nth-child(1) { width: 28%; }
|
||||||
|
.recordings-table th:nth-child(2) { width: 12%; }
|
||||||
|
.recordings-table th:nth-child(3) { width: 15%; }
|
||||||
|
.recordings-table th:nth-child(4) { width: 8%; }
|
||||||
|
.recordings-table th:nth-child(5) { width: 9%; }
|
||||||
|
.recordings-table th:nth-child(6) { width: 14%; }
|
||||||
|
.recordings-table th:nth-child(7) { width: 14%; }
|
||||||
|
|
||||||
|
.recordings-table tbody tr {
|
||||||
|
transition: background 0.2s;
|
||||||
|
}
|
||||||
|
|
||||||
|
.recordings-table tbody tr:hover,
|
||||||
|
.recordings-row-active {
|
||||||
|
background: rgba(99, 102, 241, 0.14);
|
||||||
|
}
|
||||||
|
|
||||||
|
.recordings-file-cell {
|
||||||
|
max-width: 100%;
|
||||||
|
display: flex;
|
||||||
|
align-items: center;
|
||||||
|
gap: 10px;
|
||||||
|
border: 0;
|
||||||
|
background: transparent;
|
||||||
|
color: inherit;
|
||||||
|
text-align: left;
|
||||||
|
cursor: pointer;
|
||||||
|
}
|
||||||
|
|
||||||
|
.recordings-file-icon {
|
||||||
|
flex: 0 0 auto;
|
||||||
|
width: 46px;
|
||||||
|
height: 30px;
|
||||||
|
border-radius: 8px;
|
||||||
|
display: inline-flex;
|
||||||
|
align-items: center;
|
||||||
|
justify-content: center;
|
||||||
|
background: rgba(16, 185, 129, 0.16);
|
||||||
|
color: #6ee7b7;
|
||||||
|
font-size: 11px;
|
||||||
|
font-weight: 700;
|
||||||
|
}
|
||||||
|
|
||||||
|
.recordings-file-name,
|
||||||
|
.recordings-file-sub {
|
||||||
|
display: block;
|
||||||
|
overflow: hidden;
|
||||||
|
text-overflow: ellipsis;
|
||||||
|
white-space: nowrap;
|
||||||
|
}
|
||||||
|
|
||||||
|
.recordings-file-name {
|
||||||
|
color: #ffffff;
|
||||||
|
font-size: 14px;
|
||||||
|
font-weight: 600;
|
||||||
|
}
|
||||||
|
|
||||||
|
.recordings-file-sub {
|
||||||
|
margin-top: 3px;
|
||||||
|
color: #64748b;
|
||||||
|
font-size: 12px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.recordings-actions {
|
||||||
|
display: flex;
|
||||||
|
align-items: center;
|
||||||
|
gap: 6px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.recordings-empty {
|
||||||
|
flex: 1;
|
||||||
|
min-height: 260px;
|
||||||
|
display: flex;
|
||||||
|
flex-direction: column;
|
||||||
|
align-items: center;
|
||||||
|
justify-content: center;
|
||||||
|
gap: 14px;
|
||||||
|
color: #94a3b8;
|
||||||
|
}
|
||||||
|
|
||||||
|
.recordings-preview-video {
|
||||||
|
position: relative;
|
||||||
|
aspect-ratio: 16 / 9;
|
||||||
|
border-radius: 14px;
|
||||||
|
overflow: hidden;
|
||||||
|
background: #020617;
|
||||||
|
border: 1px solid rgba(255, 255, 255, 0.1);
|
||||||
|
}
|
||||||
|
|
||||||
|
.recordings-preview-video video {
|
||||||
|
width: 100%;
|
||||||
|
height: 100%;
|
||||||
|
object-fit: contain;
|
||||||
|
}
|
||||||
|
|
||||||
|
.recordings-preview-placeholder {
|
||||||
|
position: absolute;
|
||||||
|
inset: 0;
|
||||||
|
display: flex;
|
||||||
|
flex-direction: column;
|
||||||
|
align-items: center;
|
||||||
|
justify-content: center;
|
||||||
|
gap: 10px;
|
||||||
|
color: #94a3b8;
|
||||||
|
background: linear-gradient(135deg, rgba(49, 46, 129, 0.55), rgba(8, 47, 73, 0.45));
|
||||||
|
}
|
||||||
|
|
||||||
|
.recordings-preview-meta {
|
||||||
|
min-height: 0;
|
||||||
|
overflow: auto;
|
||||||
|
}
|
||||||
|
|
||||||
|
.recordings-preview-meta h2 {
|
||||||
|
margin-bottom: 14px;
|
||||||
|
font-size: 17px;
|
||||||
|
font-weight: 700;
|
||||||
|
word-break: break-word;
|
||||||
|
}
|
||||||
|
|
||||||
|
.recordings-detail-row {
|
||||||
|
display: flex;
|
||||||
|
justify-content: space-between;
|
||||||
|
gap: 16px;
|
||||||
|
padding: 10px 0;
|
||||||
|
border-bottom: 1px solid rgba(255, 255, 255, 0.08);
|
||||||
|
}
|
||||||
|
|
||||||
|
.recordings-detail-row span {
|
||||||
|
color: #94a3b8;
|
||||||
|
}
|
||||||
|
|
||||||
|
.recordings-detail-row strong {
|
||||||
|
color: #e2e8f0;
|
||||||
|
font-weight: 600;
|
||||||
|
text-align: right;
|
||||||
|
word-break: break-all;
|
||||||
|
}
|
||||||
|
|
||||||
|
.recordings-people-section {
|
||||||
|
padding: 12px 0;
|
||||||
|
border-bottom: 1px solid rgba(255, 255, 255, 0.08);
|
||||||
|
}
|
||||||
|
|
||||||
|
.recordings-people-title {
|
||||||
|
margin-bottom: 10px;
|
||||||
|
color: #94a3b8;
|
||||||
|
font-size: 13px;
|
||||||
|
font-weight: 600;
|
||||||
|
}
|
||||||
|
|
||||||
|
.recordings-person {
|
||||||
|
display: flex;
|
||||||
|
align-items: center;
|
||||||
|
gap: 10px;
|
||||||
|
padding: 8px 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
.recordings-person img {
|
||||||
|
width: 34px;
|
||||||
|
height: 34px;
|
||||||
|
border-radius: 999px;
|
||||||
|
object-fit: cover;
|
||||||
|
background: rgba(255, 255, 255, 0.08);
|
||||||
|
}
|
||||||
|
|
||||||
|
.recordings-person strong,
|
||||||
|
.recordings-person span {
|
||||||
|
display: block;
|
||||||
|
max-width: 230px;
|
||||||
|
overflow: hidden;
|
||||||
|
text-overflow: ellipsis;
|
||||||
|
white-space: nowrap;
|
||||||
|
}
|
||||||
|
|
||||||
|
.recordings-person strong {
|
||||||
|
color: #ffffff;
|
||||||
|
font-size: 13px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.recordings-person span,
|
||||||
|
.recordings-person-empty {
|
||||||
|
color: #64748b;
|
||||||
|
font-size: 12px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.recordings-preview-actions {
|
||||||
|
display: grid;
|
||||||
|
grid-template-columns: 1fr 1fr;
|
||||||
|
gap: 10px;
|
||||||
|
margin-top: 16px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.recordings-dialog {
|
||||||
|
width: min(440px, calc(100vw - 32px));
|
||||||
|
border-radius: 18px;
|
||||||
|
padding: 22px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.recordings-notification {
|
||||||
|
position: fixed;
|
||||||
|
top: 82px;
|
||||||
|
left: 50%;
|
||||||
|
transform: translate(-50%, -16px);
|
||||||
|
z-index: 60;
|
||||||
|
min-height: 44px;
|
||||||
|
padding: 0 18px;
|
||||||
|
border-radius: 999px;
|
||||||
|
display: flex;
|
||||||
|
align-items: center;
|
||||||
|
gap: 10px;
|
||||||
|
color: #ffffff;
|
||||||
|
opacity: 0;
|
||||||
|
pointer-events: none;
|
||||||
|
transition: opacity 0.2s, transform 0.2s;
|
||||||
|
}
|
||||||
|
|
||||||
|
.recordings-notification-visible {
|
||||||
|
opacity: 1;
|
||||||
|
transform: translate(-50%, 0);
|
||||||
|
}
|
||||||
|
|
||||||
|
.recordings-notification-error i {
|
||||||
|
color: #f87171;
|
||||||
|
}
|
||||||
|
|
||||||
|
@media (max-width: 1180px) {
|
||||||
|
.recordings-content {
|
||||||
|
grid-template-columns: 260px minmax(420px, 1fr);
|
||||||
|
}
|
||||||
|
|
||||||
|
.recordings-preview {
|
||||||
|
grid-column: 1 / -1;
|
||||||
|
min-height: 360px;
|
||||||
|
display: grid;
|
||||||
|
grid-template-columns: minmax(360px, 0.8fr) 1fr;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@media (max-width: 860px) {
|
||||||
|
.recordings-page {
|
||||||
|
overflow: auto;
|
||||||
|
}
|
||||||
|
|
||||||
|
.recordings-shell {
|
||||||
|
padding: 14px;
|
||||||
|
overflow: visible;
|
||||||
|
}
|
||||||
|
|
||||||
|
.recordings-toolbar {
|
||||||
|
grid-template-columns: 1fr 1fr;
|
||||||
|
}
|
||||||
|
|
||||||
|
.recordings-search,
|
||||||
|
.recordings-format-filter {
|
||||||
|
grid-column: 1 / -1;
|
||||||
|
}
|
||||||
|
|
||||||
|
.recordings-content,
|
||||||
|
.recordings-preview {
|
||||||
|
display: flex;
|
||||||
|
flex-direction: column;
|
||||||
|
}
|
||||||
|
|
||||||
|
.recordings-list,
|
||||||
|
.recordings-upload,
|
||||||
|
.recordings-preview {
|
||||||
|
flex: none;
|
||||||
|
}
|
||||||
|
|
||||||
|
.recordings-table {
|
||||||
|
min-width: 920px;
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -1,4 +1,4 @@
|
|||||||
import * as Logger from "./logger.js";
|
import * as Logger from "../utils/logger.js";
|
||||||
|
|
||||||
export default class Peer extends EventTarget {
|
export default class Peer extends EventTarget {
|
||||||
constructor(connectionId, polite, config, resendIntervalMsec = 5000) {
|
constructor(connectionId, polite, config, resendIntervalMsec = 5000) {
|
||||||
@@ -1,5 +1,5 @@
|
|||||||
import Peer from "./peer.js";
|
import Peer from "./peer.js";
|
||||||
import * as Logger from "./logger.js";
|
import * as Logger from "../utils/logger.js";
|
||||||
|
|
||||||
function uuid4() {
|
function uuid4() {
|
||||||
var temp_url = URL.createObjectURL(new Blob());
|
var temp_url = URL.createObjectURL(new Blob());
|
||||||
@@ -5,11 +5,11 @@ import {
|
|||||||
Touchscreen,
|
Touchscreen,
|
||||||
StateEvent,
|
StateEvent,
|
||||||
TextEvent
|
TextEvent
|
||||||
} from "./inputdevice.js";
|
} from "../input/inputdevice.js";
|
||||||
|
|
||||||
import { LocalInputManager } from "./inputremoting.js";
|
import { LocalInputManager } from "../input/inputremoting.js";
|
||||||
import { GamepadHandler } from "./gamepadhandler.js";
|
import { GamepadHandler } from "../input/gamepadhandler.js";
|
||||||
import { PointerCorrector } from "./pointercorrect.js";
|
import { PointerCorrector } from "../input/pointercorrect.js";
|
||||||
|
|
||||||
export class Sender extends LocalInputManager {
|
export class Sender extends LocalInputManager {
|
||||||
constructor(elem) {
|
constructor(elem) {
|
||||||
@@ -1,11 +1,12 @@
|
|||||||
import * as Logger from "./logger.js";
|
import * as Logger from "../utils/logger.js";
|
||||||
|
|
||||||
export class Signaling extends EventTarget {
|
export class Signaling extends EventTarget {
|
||||||
|
|
||||||
constructor(interval = 1000) {
|
constructor(interval = 1000, baseUrl = null) {
|
||||||
super();
|
super();
|
||||||
this.running = false;
|
this.running = false;
|
||||||
this.interval = interval;
|
this.interval = interval;
|
||||||
|
this.baseUrl = baseUrl;
|
||||||
this.sleep = msec => new Promise(resolve => setTimeout(resolve, msec));
|
this.sleep = msec => new Promise(resolve => setTimeout(resolve, msec));
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -19,7 +20,7 @@ export class Signaling extends EventTarget {
|
|||||||
}
|
}
|
||||||
|
|
||||||
url(method, parameter = '') {
|
url(method, parameter = '') {
|
||||||
let ret = location.origin + '/signaling';
|
let ret = (this.baseUrl || location.origin) + '/signaling';
|
||||||
if (method)
|
if (method)
|
||||||
ret += '/' + method;
|
ret += '/' + method;
|
||||||
if (parameter)
|
if (parameter)
|
||||||
@@ -151,16 +152,17 @@ export class Signaling extends EventTarget {
|
|||||||
|
|
||||||
export class WebSocketSignaling extends EventTarget {
|
export class WebSocketSignaling extends EventTarget {
|
||||||
|
|
||||||
constructor(interval = 1000) {
|
constructor(interval = 1000, websocketUrl = null) {
|
||||||
super();
|
super();
|
||||||
this.interval = interval;
|
this.interval = interval;
|
||||||
this.sleep = msec => new Promise(resolve => setTimeout(resolve, msec));
|
this.sleep = msec => new Promise(resolve => setTimeout(resolve, msec));
|
||||||
|
|
||||||
let websocketUrl;
|
if (!websocketUrl) {
|
||||||
if (location.protocol === "https:") {
|
if (location.protocol === "https:") {
|
||||||
websocketUrl = "wss://" + location.host;
|
websocketUrl = "wss://" + location.host;
|
||||||
} else {
|
} else {
|
||||||
websocketUrl = "ws://" + location.host;
|
websocketUrl = "ws://" + location.host;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
this.websocket = new WebSocket(websocketUrl);
|
this.websocket = new WebSocket(websocketUrl);
|
||||||
@@ -301,6 +303,12 @@ export class WebSocketSignaling extends EventTarget {
|
|||||||
this.websocket.send(sendJson);
|
this.websocket.send(sendJson);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
sendUserInfo(payload) {
|
||||||
|
const sendJson = JSON.stringify({ type: 'host-userInfo', data: payload });
|
||||||
|
Logger.log(sendJson);
|
||||||
|
this.websocket.send(sendJson);
|
||||||
|
}
|
||||||
|
|
||||||
sendInviteCall(payload) {
|
sendInviteCall(payload) {
|
||||||
const sendJson = JSON.stringify({ type: 'invite-call', data: payload });
|
const sendJson = JSON.stringify({ type: 'invite-call', data: payload });
|
||||||
Logger.log(sendJson);
|
Logger.log(sendJson);
|
||||||
@@ -1,8 +1,8 @@
|
|||||||
import {
|
import {
|
||||||
MemoryHelper,
|
MemoryHelper,
|
||||||
} from "./memoryhelper.js";
|
} from "../utils/memoryhelper.js";
|
||||||
|
|
||||||
import { CharNumber } from "./charnumber.js";
|
import { CharNumber } from "../utils/charnumber.js";
|
||||||
import { Keymap } from "./keymap.js";
|
import { Keymap } from "./keymap.js";
|
||||||
import { MouseButton } from "./mousebutton.js";
|
import { MouseButton } from "./mousebutton.js";
|
||||||
import { GamepadButton } from "./gamepadbutton.js";
|
import { GamepadButton } from "./gamepadbutton.js";
|
||||||
@@ -4,7 +4,7 @@ import {
|
|||||||
|
|
||||||
import {
|
import {
|
||||||
MemoryHelper
|
MemoryHelper
|
||||||
} from "./memoryhelper.js";
|
} from "../utils/memoryhelper.js";
|
||||||
|
|
||||||
export class LocalInputManager {
|
export class LocalInputManager {
|
||||||
constructor() {
|
constructor() {
|
||||||
@@ -1,4 +1,4 @@
|
|||||||
import { sleep } from "./testutils";
|
import { sleep } from "../helpers/testutils.js";
|
||||||
|
|
||||||
/** @type {MockPrivateSignalingManager | MockPublicSignalingManager} */
|
/** @type {MockPrivateSignalingManager | MockPublicSignalingManager} */
|
||||||
let manager;
|
let manager;
|
||||||
@@ -1,4 +1,4 @@
|
|||||||
import { sleep, getUniqueId } from './testutils';
|
import { sleep, getUniqueId } from '../helpers/testutils.js';
|
||||||
|
|
||||||
export class PeerConnectionMock extends EventTarget {
|
export class PeerConnectionMock extends EventTarget {
|
||||||
constructor(config) {
|
constructor(config) {
|
||||||
@@ -11,7 +11,7 @@ import {
|
|||||||
StateEvent,
|
StateEvent,
|
||||||
InputEvent,
|
InputEvent,
|
||||||
TextEvent
|
TextEvent
|
||||||
} from "../src/inputdevice.js";
|
} from "../../src/input/inputdevice.js";
|
||||||
|
|
||||||
describe(`FourCC`, () => {
|
describe(`FourCC`, () => {
|
||||||
test('toInt32', () => {
|
test('toInt32', () => {
|
||||||
@@ -4,7 +4,7 @@ import {
|
|||||||
KeyboardState,
|
KeyboardState,
|
||||||
TouchscreenState,
|
TouchscreenState,
|
||||||
GamepadState
|
GamepadState
|
||||||
} from "../src/inputdevice.js";
|
} from "../../src/input/inputdevice.js";
|
||||||
|
|
||||||
import {
|
import {
|
||||||
MessageType,
|
MessageType,
|
||||||
@@ -12,14 +12,14 @@ import {
|
|||||||
NewEventsMsg,
|
NewEventsMsg,
|
||||||
RemoveDeviceMsg,
|
RemoveDeviceMsg,
|
||||||
InputRemoting,
|
InputRemoting,
|
||||||
} from "../src/inputremoting.js";
|
} from "../../src/input/inputremoting.js";
|
||||||
|
|
||||||
import {
|
import {
|
||||||
Sender,
|
Sender,
|
||||||
Observer
|
Observer
|
||||||
} from "../src/sender.js";
|
} from "../../src/core/sender.js";
|
||||||
|
|
||||||
import {DOMRect} from "./domrect.js";
|
import {DOMRect} from "../helpers/domrect.js";
|
||||||
|
|
||||||
describe(`InputRemoting`, () => {
|
describe(`InputRemoting`, () => {
|
||||||
let sender = null;
|
let sender = null;
|
||||||
124
client/test/unit/meeting-recorder.test.js
Normal file
@@ -0,0 +1,124 @@
|
|||||||
|
import { jest } from '@jest/globals';
|
||||||
|
import { MeetingRecorder } from '../../public/call/media/meeting-recorder.js';
|
||||||
|
|
||||||
|
class MediaStreamMock {
|
||||||
|
constructor(tracks = []) {
|
||||||
|
this.tracks = tracks;
|
||||||
|
}
|
||||||
|
|
||||||
|
getTracks() {
|
||||||
|
return this.tracks;
|
||||||
|
}
|
||||||
|
|
||||||
|
getAudioTracks() {
|
||||||
|
return this.tracks.filter(track => track.kind === 'audio');
|
||||||
|
}
|
||||||
|
|
||||||
|
getVideoTracks() {
|
||||||
|
return this.tracks.filter(track => track.kind === 'video');
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
class MediaRecorderMock {
|
||||||
|
static isTypeSupported() {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
constructor(stream, options) {
|
||||||
|
this.stream = stream;
|
||||||
|
this.mimeType = options.mimeType;
|
||||||
|
this.state = 'inactive';
|
||||||
|
}
|
||||||
|
|
||||||
|
start() {
|
||||||
|
this.state = 'recording';
|
||||||
|
}
|
||||||
|
|
||||||
|
stop() {
|
||||||
|
this.state = 'inactive';
|
||||||
|
this.ondataavailable({ data: new Blob(['recording'], { type: this.mimeType }) });
|
||||||
|
this.onstop();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
function createTrack(kind) {
|
||||||
|
return {
|
||||||
|
kind,
|
||||||
|
readyState: 'live',
|
||||||
|
stop: jest.fn(),
|
||||||
|
clone: jest.fn(() => createTrack(kind))
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
function createWindowMock({ mediaRecorder = MediaRecorderMock } = {}) {
|
||||||
|
return {
|
||||||
|
MediaRecorder: mediaRecorder,
|
||||||
|
MediaStream: MediaStreamMock,
|
||||||
|
URL: {
|
||||||
|
createObjectURL: jest.fn(() => 'blob:recording'),
|
||||||
|
revokeObjectURL: jest.fn()
|
||||||
|
},
|
||||||
|
requestAnimationFrame: jest.fn(() => 1),
|
||||||
|
cancelAnimationFrame: jest.fn(),
|
||||||
|
setTimeout: jest.fn((callback) => {
|
||||||
|
callback();
|
||||||
|
return 1;
|
||||||
|
})
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
describe('MeetingRecorder', () => {
|
||||||
|
beforeEach(() => {
|
||||||
|
HTMLCanvasElement.prototype.getContext = jest.fn(() => ({
|
||||||
|
fillStyle: '',
|
||||||
|
font: '',
|
||||||
|
textAlign: '',
|
||||||
|
textBaseline: '',
|
||||||
|
fillRect: jest.fn(),
|
||||||
|
fillText: jest.fn(),
|
||||||
|
drawImage: jest.fn()
|
||||||
|
}));
|
||||||
|
HTMLCanvasElement.prototype.captureStream = jest.fn(() => new MediaStreamMock([createTrack('video')]));
|
||||||
|
});
|
||||||
|
|
||||||
|
afterEach(() => {
|
||||||
|
jest.restoreAllMocks();
|
||||||
|
document.body.innerHTML = '';
|
||||||
|
});
|
||||||
|
|
||||||
|
test('starts and stops recording a meeting file', async () => {
|
||||||
|
const windowRef = createWindowMock();
|
||||||
|
const recorder = new MeetingRecorder({ documentRef: document, windowRef });
|
||||||
|
const localVideo = document.createElement('video');
|
||||||
|
localVideo.id = 'localVideo';
|
||||||
|
localVideo.srcObject = new MediaStreamMock([createTrack('video')]);
|
||||||
|
Object.defineProperty(localVideo, 'readyState', { value: 2 });
|
||||||
|
Object.defineProperty(localVideo, 'videoWidth', { value: 640 });
|
||||||
|
Object.defineProperty(localVideo, 'videoHeight', { value: 360 });
|
||||||
|
localVideo.getBoundingClientRect = () => ({ width: 320, height: 180 });
|
||||||
|
document.body.appendChild(localVideo);
|
||||||
|
|
||||||
|
await recorder.start({
|
||||||
|
localStream: new MediaStreamMock([createTrack('audio')]),
|
||||||
|
connectionId: '123-456-789'
|
||||||
|
});
|
||||||
|
|
||||||
|
expect(recorder.isRecording()).toBe(true);
|
||||||
|
|
||||||
|
const result = await recorder.stop();
|
||||||
|
|
||||||
|
expect(result.filename).toContain('meeting-recording-123-456-789');
|
||||||
|
expect(result.mimeType.toLowerCase()).toBe('video/mp4;codecs=avc1.42e01e,mp4a.40.2');
|
||||||
|
expect(result.filename).toMatch(/\.mp4$/);
|
||||||
|
expect(windowRef.URL.createObjectURL).not.toHaveBeenCalled();
|
||||||
|
expect(recorder.isRecording()).toBe(false);
|
||||||
|
});
|
||||||
|
|
||||||
|
test('reports unsupported browsers', async () => {
|
||||||
|
HTMLCanvasElement.prototype.captureStream = undefined;
|
||||||
|
const windowRef = createWindowMock({ mediaRecorder: undefined });
|
||||||
|
const recorder = new MeetingRecorder({ documentRef: document, windowRef });
|
||||||
|
|
||||||
|
await expect(recorder.start()).rejects.toThrow('当前浏览器不支持会议录制');
|
||||||
|
});
|
||||||
|
});
|
||||||