【m】优化拆分,拆分为多个脚本
This commit is contained in:
132
WebApp/client/public/onebyone/models.js
Normal file
132
WebApp/client/public/onebyone/models.js
Normal file
@@ -0,0 +1,132 @@
|
||||
/**
|
||||
* 类型定义和数据模型
|
||||
*/
|
||||
|
||||
/**
|
||||
* @typedef {Object} CallSession
|
||||
* @property {string} id - 通话唯一标识 (UUID)
|
||||
* @property {'video'|'audio'} type - 通话类型
|
||||
* @property {'connecting'|'ongoing'|'ended'|'failed'} status - 通话状态
|
||||
* @property {string} startTime - ISO 8601 时间戳
|
||||
* @property {number} duration - 已进行秒数
|
||||
* @property {boolean} isEncrypted - 是否启用端到端加密
|
||||
* @property {LocalUser} localUser - 本地用户信息
|
||||
* @property {RemoteUser} remoteUser - 远端用户信息
|
||||
*/
|
||||
|
||||
/**
|
||||
* @typedef {Object} LocalUser
|
||||
* @property {string} id - 用户ID
|
||||
* @property {string} name - 显示名称
|
||||
* @property {string} avatar - 头像URL
|
||||
* @property {boolean} isHost - 是否主持人
|
||||
* @property {MediaState} mediaState - 媒体状态
|
||||
*/
|
||||
|
||||
/**
|
||||
* @typedef {Object} RemoteUser
|
||||
* @property {string} id - 用户ID
|
||||
* @property {string} name - 显示名称
|
||||
* @property {string} avatar - 头像URL
|
||||
* @property {'online'|'offline'|'connecting'} status - 在线状态
|
||||
* @property {MediaState} mediaState - 媒体状态
|
||||
* @property {'excellent'|'good'|'fair'|'poor'} networkQuality - 网络质量
|
||||
*/
|
||||
|
||||
/**
|
||||
* @typedef {Object} MediaState
|
||||
* @property {boolean} audio - 音频是否开启
|
||||
* @property {boolean} video - 视频是否开启
|
||||
* @property {boolean} screenShare - 是否屏幕共享
|
||||
* @property {boolean} recording - 是否正在录屏
|
||||
* @property {boolean} isSpeaking - 是否正在说话(VAD)
|
||||
*/
|
||||
|
||||
/**
|
||||
* @typedef {Object} ChatMessage
|
||||
* @property {string} id - 消息唯一ID
|
||||
* @property {string} senderId - 发送者ID
|
||||
* @property {string} senderName - 发送者名称
|
||||
* @property {string} senderAvatar - 发送者头像URL
|
||||
* @property {string} content - 消息内容
|
||||
* @property {'text'|'file'|'system'} type - 消息类型
|
||||
* @property {string} timestamp - ISO 8601 时间戳
|
||||
* @property {boolean} isSelf - 是否为自己发送
|
||||
*/
|
||||
|
||||
// 模拟通话会话数据
|
||||
const mockCallSession = {
|
||||
id: "call-8842-2024-001",
|
||||
type: "video",
|
||||
status: "ongoing", // connecting | ongoing | ended | failed
|
||||
startTime: "2024-01-15T14:30:00.000Z",
|
||||
duration: 0, // 秒数,后端可不返回,前端本地计算
|
||||
isEncrypted: true,
|
||||
|
||||
// 本地用户信息
|
||||
localUser: {
|
||||
id: "user-local-001",
|
||||
name: "我",
|
||||
avatar: "https://images.unsplash.com/photo-1507003211169-0a1dd7228f2d?w=400&h=400&fit=crop",
|
||||
isHost: true,
|
||||
mediaState: {
|
||||
audio: true,
|
||||
video: true,
|
||||
screenShare: false,
|
||||
recording: false,
|
||||
isSpeaking: false
|
||||
}
|
||||
},
|
||||
|
||||
// 远端用户信息
|
||||
remoteUser: {
|
||||
id: "user-remote-002",
|
||||
name: "Sarah Chen",
|
||||
avatar: "https://images.unsplash.com/photo-1494790108377-be9c29b29330?w=400&h=400&fit=crop",
|
||||
status: "online", // online | offline | connecting
|
||||
networkQuality: "excellent", // excellent | good | fair | poor
|
||||
mediaState: {
|
||||
audio: true,
|
||||
video: true,
|
||||
screenShare: false,
|
||||
recording: false,
|
||||
isSpeaking: false
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
// 模拟聊天消息数据
|
||||
const mockMessages = [
|
||||
{
|
||||
id: "msg-001",
|
||||
senderId: "system",
|
||||
senderName: "系统",
|
||||
senderAvatar: "https://via.placeholder.com/100",
|
||||
content: "通话已建立连接",
|
||||
type: "system",
|
||||
timestamp: "2024-01-15T14:30:00.000Z",
|
||||
isSelf: false
|
||||
},
|
||||
{
|
||||
id: "msg-002",
|
||||
senderId: "user-remote-002",
|
||||
senderName: "Sarah Chen",
|
||||
senderAvatar: "https://images.unsplash.com/photo-1494790108377-be9c29b29330?w=100&h=100&fit=crop",
|
||||
content: "嗨,能听到我说话吗?",
|
||||
type: "text",
|
||||
timestamp: "2024-01-15T14:32:15.000Z",
|
||||
isSelf: false
|
||||
},
|
||||
{
|
||||
id: "msg-003",
|
||||
senderId: "user-local-001",
|
||||
senderName: "我",
|
||||
senderAvatar: "https://images.unsplash.com/photo-1507003211169-0a1dd7228f2d?w=100&h=100&fit=crop",
|
||||
content: "很清楚!你的画面也很清晰 👍",
|
||||
type: "text",
|
||||
timestamp: "2024-01-15T14:32:45.000Z",
|
||||
isSelf: true
|
||||
}
|
||||
];
|
||||
|
||||
export { mockCallSession, mockMessages };
|
||||
Reference in New Issue
Block a user