trtc-cloud-js-sdk 2.0.0 → 2.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/package.json +7 -57
- package/trtc-cloud-js-sdk.js +1 -0
- package/.eslintrc.js +0 -88
- package/.prettierrc +0 -5
- package/CHANGELOG.md +0 -58
- package/build/jsdoc/clean-doc.js +0 -12
- package/build/jsdoc/fix-doc.js +0 -141
- package/build/jsdoc/jsdoc.json +0 -42
- package/build/package-bundle.js +0 -29
- package/build/rollup.config.dev.js +0 -88
- package/build/rollup.config.prod.js +0 -93
- package/build/rollup.js +0 -359
- package/build/template/npm-package/package.json +0 -24
- package/coverage/Chrome 103.0.5060 (Mac OS X 10.15.7)/base.css +0 -213
- package/coverage/Chrome 103.0.5060 (Mac OS X 10.15.7)/index.html +0 -80
- package/coverage/Chrome 103.0.5060 (Mac OS X 10.15.7)/prettify.css +0 -1
- package/coverage/Chrome 103.0.5060 (Mac OS X 10.15.7)/prettify.js +0 -1
- package/coverage/Chrome 103.0.5060 (Mac OS X 10.15.7)/sort-arrow-sprite.png +0 -0
- package/coverage/Chrome 103.0.5060 (Mac OS X 10.15.7)/sorter.js +0 -158
- package/examples/apiExample/.env +0 -2
- package/examples/apiExample/README.md +0 -70
- package/examples/apiExample/package-lock.json +0 -30915
- package/examples/apiExample/package.json +0 -51
- package/examples/apiExample/public/audio.js +0 -195
- package/examples/apiExample/public/audio.js.map +0 -7
- package/examples/apiExample/public/av_processing.js +0 -1
- package/examples/apiExample/public/basic/av_processing.wasm +0 -0
- package/examples/apiExample/public/basic/worker.js +0 -10434
- package/examples/apiExample/public/favicon.ico +0 -0
- package/examples/apiExample/public/index.html +0 -47
- package/examples/apiExample/public/logo192.png +0 -0
- package/examples/apiExample/public/logo512.png +0 -0
- package/examples/apiExample/public/manifest.json +0 -25
- package/examples/apiExample/public/robots.txt +0 -3
- package/examples/apiExample/src/App.css +0 -37
- package/examples/apiExample/src/App.js +0 -25
- package/examples/apiExample/src/api/http.js +0 -127
- package/examples/apiExample/src/api/nav.js +0 -44
- package/examples/apiExample/src/components/BasicInfoComponent.css +0 -16
- package/examples/apiExample/src/components/BasicInfoComponent.js +0 -27
- package/examples/apiExample/src/config/gen-test-user-sig.js +0 -64
- package/examples/apiExample/src/config/lib-generate-test-usersig.min.js +0 -7052
- package/examples/apiExample/src/config/nav.js +0 -136
- package/examples/apiExample/src/home.js +0 -16
- package/examples/apiExample/src/index.css +0 -21
- package/examples/apiExample/src/index.js +0 -12
- package/examples/apiExample/src/logo.svg +0 -1
- package/examples/apiExample/src/page/basic/screen-share/index.css +0 -52
- package/examples/apiExample/src/page/basic/screen-share/index.js +0 -223
- package/examples/apiExample/src/page/basic/setDevice/index.js +0 -262
- package/examples/apiExample/src/page/basic/setDevice/index.scss +0 -93
- package/examples/apiExample/src/page/basic/video-call/index.js +0 -521
- package/examples/apiExample/src/page/basic/video-call/index.scss +0 -93
- package/examples/apiExample/src/page/basic/video-call-init/index.js +0 -382
- package/examples/apiExample/src/page/basic/video-call-init/index.scss +0 -93
- package/examples/apiExample/src/page/basic/video-live/index.css +0 -37
- package/examples/apiExample/src/page/basic/video-live/index.js +0 -188
- package/examples/apiExample/src/page/layout.js +0 -22
- package/examples/apiExample/src/page/layout.scss +0 -76
- package/examples/apiExample/src/utils/utils.js +0 -35
- package/examples/jsExample/assets/css/bootstrap-material-design.css +0 -12169
- package/examples/jsExample/assets/css/bootstrap-material-design.min.css +0 -8
- package/examples/jsExample/assets/css/common.css +0 -48
- package/examples/jsExample/assets/icon/iconfont.js +0 -1
- package/examples/jsExample/assets/js/bootstrap-material-design.js +0 -6939
- package/examples/jsExample/assets/js/bootstrap-material-design.js.map +0 -1
- package/examples/jsExample/assets/js/bootstrap-material-design.min.js +0 -1
- package/examples/jsExample/assets/js/graph.js +0 -695
- package/examples/jsExample/assets/js/jquery-3.2.1.min.js +0 -4
- package/examples/jsExample/assets/js/jquery-3.2.1.slim.min.js +0 -4
- package/examples/jsExample/assets/js/lib-generate-test-usersig.min.js +0 -2
- package/examples/jsExample/assets/js/popper.js +0 -2442
- package/examples/jsExample/index.html +0 -57
- package/examples/jsExample/rtc/css/common.css +0 -82
- package/examples/jsExample/rtc/index.html +0 -107
- package/examples/jsExample/rtc/js/index.js +0 -142
- package/examples/vueDemo/LICENSE +0 -21
- package/examples/vueDemo/README.md +0 -144
- package/examples/vueDemo/README_EN.md +0 -136
- package/examples/vueDemo/av_processing.wasm +0 -0
- package/examples/vueDemo/index.html +0 -23
- package/examples/vueDemo/package-lock.json +0 -1375
- package/examples/vueDemo/package.json +0 -36
- package/examples/vueDemo/src/App.vue +0 -12
- package/examples/vueDemo/src/api/index.js +0 -59
- package/examples/vueDemo/src/assets/css/color-dark.css +0 -28
- package/examples/vueDemo/src/assets/css/icon.css +0 -4
- package/examples/vueDemo/src/assets/css/main.css +0 -177
- package/examples/vueDemo/src/assets/img/img.jpg +0 -0
- package/examples/vueDemo/src/assets/img/login-bg.jpg +0 -0
- package/examples/vueDemo/src/components/Header.vue +0 -172
- package/examples/vueDemo/src/components/Sidebar.vue +0 -117
- package/examples/vueDemo/src/components/Tags.vue +0 -174
- package/examples/vueDemo/src/components/tendency.vue +0 -206
- package/examples/vueDemo/src/components/trtc/main-menu.vue +0 -50
- package/examples/vueDemo/src/components/trtc/nav-bar.vue +0 -53
- package/examples/vueDemo/src/components/trtc/show-screen-capture.vue +0 -118
- package/examples/vueDemo/src/components/trtc/trtc-state-check.vue +0 -117
- package/examples/vueDemo/src/config/gen-test-user-sig.js +0 -67
- package/examples/vueDemo/src/config/lib-generate-test-usersig.min.js +0 -7052
- package/examples/vueDemo/src/main.js +0 -11
- package/examples/vueDemo/src/plugins/element.js +0 -17
- package/examples/vueDemo/src/router/index.js +0 -73
- package/examples/vueDemo/src/store/sidebar.js +0 -17
- package/examples/vueDemo/src/store/tags.js +0 -48
- package/examples/vueDemo/src/utils/i18n.js +0 -24
- package/examples/vueDemo/src/utils/request.js +0 -34
- package/examples/vueDemo/src/utils/utils.js +0 -35
- package/examples/vueDemo/src/views/Home.vue +0 -46
- package/examples/vueDemo/src/views/I18n.vue +0 -40
- package/examples/vueDemo/src/views/Icon.vue +0 -229
- package/examples/vueDemo/src/views/basic/trtc.vue +0 -194
- package/examples/vueDemo/src/views/feature/index.vue +0 -259
- package/examples/vueDemo/src/views/github/index.vue +0 -243
- package/examples/vueDemo/src/views/improve/live-index.vue +0 -256
- package/examples/vueDemo/src/views/improve/live-room-anchor.vue +0 -689
- package/examples/vueDemo/src/views/improve/live-room-audience.vue +0 -383
- package/examples/vueDemo/src/views/sdkAppId/index.vue +0 -284
- package/examples/vueDemo/vite.config.js +0 -18
- package/examples/vueDemo/worker.js +0 -22
- package/karma.conf.js +0 -99
- package/scripts/publish.js +0 -86
- package/src/Camera.ts +0 -80
- package/src/Mic.ts +0 -145
- package/src/common/IError.ts +0 -6
- package/src/common/ITRTCCloud.ts +0 -68
- package/src/common/constants.ts +0 -116
- package/src/common/trtc-code.ts +0 -43
- package/src/common/trtc-define.ts +0 -1007
- package/src/common/trtc-event.ts +0 -29
- package/src/index.ts +0 -1672
- package/src/utils/environment.js +0 -297
- package/src/utils/raf.js +0 -131
- package/src/utils/time.js +0 -22
- package/src/utils/utils.ts +0 -71
- package/src/utils/uuid.js +0 -12
- package/test/unit/env.test.js +0 -25
- package/test/unit/get-user-media.test.js +0 -40
- package/test/unit/ice-parser.test.js +0 -23
- package/test/unit/sdp.test.js +0 -45
- package/test/unit/signal.test.js +0 -78
- package/tsconfig.json +0 -32
- /package/{build/template/npm-package/README.md → README.md} +0 -0
|
@@ -1,383 +0,0 @@
|
|
|
1
|
-
<template name="trtcRoomAudience">
|
|
2
|
-
<div id="live-room">
|
|
3
|
-
<nav-bar :title="'房间号:' + roomId+';观众:'+userId"></nav-bar>
|
|
4
|
-
|
|
5
|
-
<!-- 视频容器 -->
|
|
6
|
-
<div id="video-container"></div>
|
|
7
|
-
|
|
8
|
-
<div id="controll-bar">
|
|
9
|
-
<b-button variant="link" @click="exitRoom">
|
|
10
|
-
<b-iconstack font-scale="1">
|
|
11
|
-
<b-icon icon="power" variant="warning"></b-icon>
|
|
12
|
-
</b-iconstack>
|
|
13
|
-
</b-button>
|
|
14
|
-
</div>
|
|
15
|
-
|
|
16
|
-
<div>
|
|
17
|
-
<b-modal id="no-anchor-modal" size="lg" title="提示" @ok="exitAndDeleteRoom">此房间没有主播,请换一个房间.</b-modal>
|
|
18
|
-
<b-modal
|
|
19
|
-
id="live-stop-modal"
|
|
20
|
-
size="lg"
|
|
21
|
-
title="提示"
|
|
22
|
-
@ok="exitRoom"
|
|
23
|
-
>所有主播已经离开,点“OK” 离开房间,点“chancel”继续等待。</b-modal>
|
|
24
|
-
</div>
|
|
25
|
-
</div>
|
|
26
|
-
</template>
|
|
27
|
-
|
|
28
|
-
<script>
|
|
29
|
-
import TRTCCloud from 'trtc-js-sdk';
|
|
30
|
-
import {destroyLiveRoom} from '../../common/live-room-service';
|
|
31
|
-
import {
|
|
32
|
-
TRTCAppScene,
|
|
33
|
-
TRTCVideoStreamType,
|
|
34
|
-
TRTCVideoFillMode,
|
|
35
|
-
TRTCRoleType,
|
|
36
|
-
TRTCParams,
|
|
37
|
-
} from "@trtc/cloud-sdk-types";
|
|
38
|
-
import genTestUserSig from '../../debug/gen-test-user-sig';
|
|
39
|
-
import Log from '../../common/log';
|
|
40
|
-
const logger = new Log(`trtcRoom`);
|
|
41
|
-
let trtcCloud = null; // 用于TRTCIns 实例, mounted 时实体化
|
|
42
|
-
export default {
|
|
43
|
-
data() {
|
|
44
|
-
return {
|
|
45
|
-
roomId: 0,
|
|
46
|
-
userId: '',
|
|
47
|
-
videosList: [],
|
|
48
|
-
streamType: TRTCVideoStreamType.TRTCVideoStreamTypeBig,
|
|
49
|
-
isMuteMic: false,
|
|
50
|
-
isDisableCamara : false,
|
|
51
|
-
isScreenSharing: false,
|
|
52
|
-
getScreensTaskID: 0,
|
|
53
|
-
screensList: [],
|
|
54
|
-
screensListVisiable: false,
|
|
55
|
-
videoContainer: null,
|
|
56
|
-
enablePush: false,
|
|
57
|
-
anchorIdList: [], // 主播ID列表
|
|
58
|
-
noAnchorTimoutID: '',
|
|
59
|
-
noAnchorCountDown: 3, // 空房间倒计时检测的最大时长,如果达到了这个时间,仍没有触发 onUserVideoAvailable ,就会提示用户是否要退出此直播间。
|
|
60
|
-
|
|
61
|
-
// 存放远程用户视频列表
|
|
62
|
-
remoteVideos: {},
|
|
63
|
-
};
|
|
64
|
-
},
|
|
65
|
-
|
|
66
|
-
computed: {
|
|
67
|
-
subStreamWidth() {
|
|
68
|
-
return Math.floor(this.videoContainer.clientWidth * 0.2);
|
|
69
|
-
},
|
|
70
|
-
|
|
71
|
-
subStreamHeight () {
|
|
72
|
-
return Math.floor(this.videoContainer.clientHeight * 0.2);
|
|
73
|
-
}
|
|
74
|
-
},
|
|
75
|
-
|
|
76
|
-
methods: {
|
|
77
|
-
|
|
78
|
-
/**
|
|
79
|
-
* 启动一个计时器,当进入了空的房间 n 秒后给出提示
|
|
80
|
-
*/
|
|
81
|
-
startNoAnchorCountDown() {
|
|
82
|
-
this.noAnchorTimoutID = setTimeout(()=>{
|
|
83
|
-
if (this.anchorIdList.length===0) {
|
|
84
|
-
this.$bvModal.show('no-anchor-modal');
|
|
85
|
-
}
|
|
86
|
-
},this.noAnchorCountDown * 1000);
|
|
87
|
-
},
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
/**
|
|
91
|
-
* 当进入房间时触发的回调
|
|
92
|
-
* @param {number} result - 进房结果, 大于 0 时,为进房间消耗的时间,这表示进进房成功。如果为 -1 ,则表示进房失败。
|
|
93
|
-
**/
|
|
94
|
-
onEnterRoom(result) {
|
|
95
|
-
if ( result > 0 ) {
|
|
96
|
-
logger.log(`onEnterRoom,进房成功,使用了 ${result} 毫秒`);
|
|
97
|
-
this.startNoAnchorCountDown();
|
|
98
|
-
} else {
|
|
99
|
-
this.$bvToast.toast(`进房失败 ${result}`);
|
|
100
|
-
logger.warn(`onEnterRoom: 进房失败 ${result}`);
|
|
101
|
-
}
|
|
102
|
-
},
|
|
103
|
-
|
|
104
|
-
/**
|
|
105
|
-
* 当退出房间时触发的回调
|
|
106
|
-
*/
|
|
107
|
-
onExitRoom(reason) {
|
|
108
|
-
logger.warn(`onExitRoom, reason: ${reason}`);
|
|
109
|
-
},
|
|
110
|
-
|
|
111
|
-
/**
|
|
112
|
-
* 当主播进房时,把主播ID push 到列表里,并返回列表的长度
|
|
113
|
-
*/
|
|
114
|
-
anchorIn(uid) {
|
|
115
|
-
if (!this.anchorIdList.includes(uid)) {
|
|
116
|
-
this.anchorIdList.push(uid);
|
|
117
|
-
}
|
|
118
|
-
return this.anchorIdList.length;
|
|
119
|
-
},
|
|
120
|
-
|
|
121
|
-
/**
|
|
122
|
-
* 当主播退房时,把主播ID 从列表中 去除,并返回列表的长度
|
|
123
|
-
*/
|
|
124
|
-
anchorOut(uid) {
|
|
125
|
-
let idx = this.anchorIdList.indexOf(uid);
|
|
126
|
-
this.anchorIdList = this.anchorIdList.slice(idx);
|
|
127
|
-
return this.anchorIdList.length;
|
|
128
|
-
},
|
|
129
|
-
|
|
130
|
-
/**
|
|
131
|
-
* 远程用户视频流的状态发生变更时触发。
|
|
132
|
-
* @param {number} uid - 用户标识
|
|
133
|
-
* @param {boolean} available - 画面是否开启
|
|
134
|
-
**/
|
|
135
|
-
onUserVideoAvailable(uid, available) {
|
|
136
|
-
logger.log(`onUserVideoAvailable: uid: ${uid}, available ${available}`);
|
|
137
|
-
if (available === 1) {
|
|
138
|
-
clearTimeout(this.noAnchorTimoutID);
|
|
139
|
-
this.anchorIn(uid);
|
|
140
|
-
this.showAnchorVideo(uid);
|
|
141
|
-
this.$bvToast.toast(`主播 ${uid} 进入房间`, {variant: 'primary'});
|
|
142
|
-
} else {
|
|
143
|
-
this.$bvToast.toast(`主播 ${uid} 退出房间`, {variant: 'warning'});
|
|
144
|
-
this.closeAnchorVideo(uid);
|
|
145
|
-
if (this.anchorOut() === 0) {
|
|
146
|
-
this.$bvModal.show('live-stop-modal');
|
|
147
|
-
}
|
|
148
|
-
}
|
|
149
|
-
},
|
|
150
|
-
|
|
151
|
-
/**
|
|
152
|
-
* 显示主播的视频,直播模式下,显示主播的画面
|
|
153
|
-
*/
|
|
154
|
-
showAnchorVideo(uid) {
|
|
155
|
-
let id = `${uid}-${this.roomId}-${TRTCVideoStreamType.TRTCVideoStreamTypeBig}`;
|
|
156
|
-
logger.log(`showAnchorVideo: remoteVideoIndex: ${this.remoteVideoIndex}; uid: ${uid}; `);
|
|
157
|
-
let view = document.getElementById(id);
|
|
158
|
-
if (!view) {
|
|
159
|
-
view = document.createElement('div');
|
|
160
|
-
view.id = id;
|
|
161
|
-
this.videoContainer.appendChild(view);
|
|
162
|
-
}
|
|
163
|
-
if (view.className.indexOf('anchor-view') < 0) {
|
|
164
|
-
view.classList.add('anchor-view');
|
|
165
|
-
}
|
|
166
|
-
this.remoteVideos[id] = view;
|
|
167
|
-
trtcCloud.startRemoteView(uid, view);
|
|
168
|
-
trtcCloud.setRemoteViewFillMode(uid, TRTCVideoFillMode.TRTCVideoFillMode_Fill);
|
|
169
|
-
this.videoTypeSettingAutoWrap();
|
|
170
|
-
},
|
|
171
|
-
|
|
172
|
-
/**
|
|
173
|
-
* 关闭主播的视频
|
|
174
|
-
* @param {number} uid
|
|
175
|
-
*/
|
|
176
|
-
closeAnchorVideo(uid) {
|
|
177
|
-
let id = `${uid}-${this.roomId}-${TRTCVideoStreamType.TRTCVideoStreamTypeBig}`;
|
|
178
|
-
let view = document.getElementById(id);
|
|
179
|
-
if (view) {
|
|
180
|
-
this.videoContainer.removeChild(view);
|
|
181
|
-
}
|
|
182
|
-
delete this.remoteVideos[id];
|
|
183
|
-
this.remoteVideoIndex--;
|
|
184
|
-
this.videoTypeSettingAutoWrap();
|
|
185
|
-
},
|
|
186
|
-
|
|
187
|
-
/**
|
|
188
|
-
* 视频元素自动换行排版
|
|
189
|
-
*/
|
|
190
|
-
videoTypeSettingAutoWrap () {
|
|
191
|
-
let maxPerline = 2; // 每行最多放三个
|
|
192
|
-
let remoteVideos = this.remoteVideos;
|
|
193
|
-
let winWidth = 100; // 窗口宽度,百分比值
|
|
194
|
-
let winHeight = 100; // 窗口高度,百分比值
|
|
195
|
-
let len = Object.keys(remoteVideos).length;
|
|
196
|
-
let nw = 1;
|
|
197
|
-
let nh = 1;
|
|
198
|
-
for (let id in remoteVideos) {
|
|
199
|
-
nw = len <= maxPerline ? len : maxPerline;
|
|
200
|
-
nh = Math.ceil(len / maxPerline);
|
|
201
|
-
remoteVideos[id].className = `user-video-container-auto-wrap`;
|
|
202
|
-
remoteVideos[id].style.width = `${winWidth / nw}vw`
|
|
203
|
-
remoteVideos[id].style.height = `${winHeight / nh}vh`
|
|
204
|
-
}
|
|
205
|
-
},
|
|
206
|
-
|
|
207
|
-
/**
|
|
208
|
-
* 当主播进入本房间
|
|
209
|
-
*/
|
|
210
|
-
onRemoteUserEnterRoom(uid) {
|
|
211
|
-
logger.warn('onRemoteUserEnterRoom', uid);
|
|
212
|
-
if (!this.anchorIdList.includes(uid)) {
|
|
213
|
-
this.anchorIdList.push(uid);
|
|
214
|
-
this.$bvToast.toast(`主播 ${uid},进入房间。`, {
|
|
215
|
-
variant: 'primary'
|
|
216
|
-
});
|
|
217
|
-
}
|
|
218
|
-
},
|
|
219
|
-
|
|
220
|
-
onRemoteUserLeaveRoom(uid) {
|
|
221
|
-
logger.warn('onRemoteUserLeaveRoom', uid);
|
|
222
|
-
this.closeAnchorVideo(uid);
|
|
223
|
-
if (this.anchorOut(uid) === 0) {
|
|
224
|
-
this.$bvModal.show('live-stop-modal');
|
|
225
|
-
}
|
|
226
|
-
},
|
|
227
|
-
|
|
228
|
-
/**
|
|
229
|
-
* 当远程用户屏幕分享的状态发生变化
|
|
230
|
-
**/
|
|
231
|
-
onUserSubStreamAvailable(uid, available) {
|
|
232
|
-
logger.log(`onUserSubStreamAvailable ${uid}, ${available}`);
|
|
233
|
-
if (available) {
|
|
234
|
-
this.showRemoteScreenSharing(uid);
|
|
235
|
-
} else {
|
|
236
|
-
this.closeRemoteScreenSharing(uid);
|
|
237
|
-
}
|
|
238
|
-
},
|
|
239
|
-
|
|
240
|
-
/**
|
|
241
|
-
* 显示远程用户的屏幕分享
|
|
242
|
-
*/
|
|
243
|
-
showRemoteScreenSharing(uid) {
|
|
244
|
-
let id = `${uid}-${this.roomId}-${TRTCVideoStreamType.TRTCVideoStreamTypeSub}`;
|
|
245
|
-
logger.log(`showRemoteScreenSharing: uid: ${id}`);
|
|
246
|
-
let W = this.subStreamWidth;
|
|
247
|
-
let H = this.subStreamHeight;
|
|
248
|
-
let view = document.getElementById(id);
|
|
249
|
-
if (!view) {
|
|
250
|
-
view = document.createElement('div');
|
|
251
|
-
view.id = id;
|
|
252
|
-
view.style.width = `${W}px`;
|
|
253
|
-
view.style.height = `${H}px`;
|
|
254
|
-
this.videoContainer.appendChild(view);
|
|
255
|
-
}
|
|
256
|
-
this.remoteVideos[id] = view;
|
|
257
|
-
trtcCloud.startRemoteSubStreamView(uid, view);
|
|
258
|
-
trtcCloud.setRemoteSubStreamViewFillMode(uid, TRTCVideoFillMode.TRTCVideoFillMode_Fill);
|
|
259
|
-
this.videoTypeSettingAutoWrap();
|
|
260
|
-
},
|
|
261
|
-
|
|
262
|
-
/**
|
|
263
|
-
* 关闭远程用户的屏幕分享
|
|
264
|
-
*
|
|
265
|
-
* @param {*} uid
|
|
266
|
-
*/
|
|
267
|
-
closeRemoteScreenSharing (uid) {
|
|
268
|
-
let id = `${uid}-${this.roomId}-${TRTCVideoStreamType.TRTCVideoStreamTypeSub}`;
|
|
269
|
-
let view = document.getElementById(id);
|
|
270
|
-
if (view) {
|
|
271
|
-
this.videoContainer.removeChild(view);
|
|
272
|
-
}
|
|
273
|
-
delete this.remoteVideos[id];
|
|
274
|
-
},
|
|
275
|
-
|
|
276
|
-
/**
|
|
277
|
-
* 离开房间
|
|
278
|
-
*/
|
|
279
|
-
exitRoom(event) {
|
|
280
|
-
logger.log('exitRoom', event);
|
|
281
|
-
trtcCloud.exitRoom();
|
|
282
|
-
let my = this;
|
|
283
|
-
|
|
284
|
-
setTimeout(()=>{
|
|
285
|
-
my.$router.push('/live-index/audience');
|
|
286
|
-
}, 0 );
|
|
287
|
-
},
|
|
288
|
-
|
|
289
|
-
/**
|
|
290
|
-
* 退出并清除房间
|
|
291
|
-
*/
|
|
292
|
-
exitAndDeleteRoom() {
|
|
293
|
-
destroyLiveRoom(this.roomId);
|
|
294
|
-
this.exitRoom();
|
|
295
|
-
}
|
|
296
|
-
|
|
297
|
-
},
|
|
298
|
-
|
|
299
|
-
mounted() {
|
|
300
|
-
// 1. 获取用于承载视频的 HTMLElement;
|
|
301
|
-
this.videoContainer = document.querySelector('#video-container');
|
|
302
|
-
logger.log(`mounted: `, this.$route.params);
|
|
303
|
-
|
|
304
|
-
// 获取 vue-router 传参:userId 和 roomId
|
|
305
|
-
this.roomId = parseInt(this.$route.params.roomId); // roomId 为整数类型
|
|
306
|
-
this.userId = this.$route.params.userId; // userId 为字符串类型
|
|
307
|
-
|
|
308
|
-
if (!this.roomId || !this.userId) {
|
|
309
|
-
this.$bvToast.toast('roomId 或 userId 为空,请填写后再试。');
|
|
310
|
-
this.$router.push('live-index/audience');
|
|
311
|
-
return;
|
|
312
|
-
}
|
|
313
|
-
|
|
314
|
-
// 2. 计算签名
|
|
315
|
-
this.sdkInfo = genTestUserSig(this.userId);
|
|
316
|
-
|
|
317
|
-
// 3. 实例化一个 TRTCCloud (包装了 TRTCCloud的类)
|
|
318
|
-
trtcCloud = new TRTCCloud();
|
|
319
|
-
logger.warn(`sdk version: ${trtcCloud.getSDKVersion()}`);
|
|
320
|
-
|
|
321
|
-
// 4. 配置基本的事件订阅
|
|
322
|
-
trtcCloud.on('onEnterRoom', this.onEnterRoom.bind(this));
|
|
323
|
-
trtcCloud.on('onExitRoom', this.onExitRoom.bind(this));
|
|
324
|
-
trtcCloud.on('onUserVideoAvailable', this.onUserVideoAvailable.bind(this));
|
|
325
|
-
trtcCloud.on('onRemoteUserEnterRoom', this.onRemoteUserEnterRoom.bind(this));
|
|
326
|
-
trtcCloud.on('onRemoteUserLeaveRoom', this.onRemoteUserLeaveRoom.bind(this));
|
|
327
|
-
trtcCloud.on('onUserSubStreamAvailable', this.onUserSubStreamAvailable.bind(this));
|
|
328
|
-
|
|
329
|
-
// 5. 进入房间
|
|
330
|
-
// TRTCParams 详细说明,请查看文档:https://web.sdk.qcloud.com/trtc/electron/doc/zh-cn/trtc_electron_sdk/TRTCParams.html
|
|
331
|
-
let param = new TRTCParams();
|
|
332
|
-
param.sdkAppId = this.sdkInfo.sdkappid;
|
|
333
|
-
param.userSig = this.sdkInfo.userSig;
|
|
334
|
-
param.roomId = this.roomId;
|
|
335
|
-
param.userId = this.userId;
|
|
336
|
-
param.privateMapKey = ''; // 房间签名(非必填)7.1.157 版本以上(含),可以忽略此参数,7.1.157 之前的版本建议赋值为空字符串
|
|
337
|
-
param.businessInfo = ''; // 业务数据(非必填)7.1.157 版本以上(含),可以忽略此参数,7.1.157 之前的版本建议赋值为空字符串
|
|
338
|
-
param.role = TRTCRoleType.TRTCRoleAudience; // 直播场景下的角色,仅适用于直播场景(TRTCAppSceneLIVE 和 TRTCAppSceneVoiceChatRoom),视频通话场景下指定无效。默认值:主播(TRTCRoleAnchor)
|
|
339
|
-
trtcCloud.enterRoom(param, TRTCAppScene.TRTCAppSceneLIVE);
|
|
340
|
-
|
|
341
|
-
// 挂到 windows BOM 下,方便调试。
|
|
342
|
-
window.trtc = trtcCloud;
|
|
343
|
-
},
|
|
344
|
-
|
|
345
|
-
beforeDestroy() {
|
|
346
|
-
this.isScreenSharing = false;
|
|
347
|
-
}
|
|
348
|
-
};
|
|
349
|
-
</script>
|
|
350
|
-
|
|
351
|
-
<style scoped>
|
|
352
|
-
#controll-bar {
|
|
353
|
-
position: fixed;
|
|
354
|
-
width: 100%;
|
|
355
|
-
height: 10vh;
|
|
356
|
-
bottom: 0;
|
|
357
|
-
left: 0;
|
|
358
|
-
text-align: center;
|
|
359
|
-
background-color: rgba(0, 0, 0, 0.3);
|
|
360
|
-
padding-top: 0.9em;
|
|
361
|
-
}
|
|
362
|
-
|
|
363
|
-
#controll-bar > button {
|
|
364
|
-
margin: 0 2em;
|
|
365
|
-
border: none;
|
|
366
|
-
}
|
|
367
|
-
|
|
368
|
-
#controll-bar > button > .b-icon {
|
|
369
|
-
width: 2.5;
|
|
370
|
-
}
|
|
371
|
-
</style>
|
|
372
|
-
<style>
|
|
373
|
-
.user-video-container-auto-wrap {
|
|
374
|
-
float: left;
|
|
375
|
-
overflow: hidden;
|
|
376
|
-
}
|
|
377
|
-
</style>
|
|
378
|
-
<style>
|
|
379
|
-
.anchor-view {
|
|
380
|
-
width: 100vw;
|
|
381
|
-
height: 101vh;
|
|
382
|
-
}
|
|
383
|
-
</style>
|
|
@@ -1,284 +0,0 @@
|
|
|
1
|
-
<template>
|
|
2
|
-
<div class="fillcontain">
|
|
3
|
-
<div class="query-container">
|
|
4
|
-
<div class="query-project-name">
|
|
5
|
-
<label for="project-name">项目:</label>
|
|
6
|
-
<el-select class="query-select-container" v-model="selectValue" placeholder="请选择" id="project-name" multiple
|
|
7
|
-
collapse-tags @change="getNewSdkAppId">
|
|
8
|
-
<el-option v-for="(item, idx) in selectProjectNameList" :key="item.value + '-' + idx" :label="item.name"
|
|
9
|
-
:value="item.value">
|
|
10
|
-
</el-option>
|
|
11
|
-
</el-select>
|
|
12
|
-
</div>
|
|
13
|
-
|
|
14
|
-
<label for="date-range" class="date-range-label">日期选择:</label>
|
|
15
|
-
<el-date-picker class="date-range" v-model="dateRange" type="daterange" @blur="getNewSdkAppId"
|
|
16
|
-
placeholder="选择日期范围">
|
|
17
|
-
</el-date-picker>
|
|
18
|
-
</div>
|
|
19
|
-
<tendency :sevenDate='sevenDate' :sevenDay='sevenDay' :title='graphicTitle' :legend="legend" :loading="loading">
|
|
20
|
-
</tendency>
|
|
21
|
-
<div class="table_container">
|
|
22
|
-
<el-table v-loading="tableLoading" :data="tableData" style="width: 100%" border>
|
|
23
|
-
<el-table-column v-for="(item, index) in headerTable" :key="index" :label="item.label" :prop="item.name">
|
|
24
|
-
</el-table-column>
|
|
25
|
-
</el-table>
|
|
26
|
-
</div>
|
|
27
|
-
</div>
|
|
28
|
-
</template>
|
|
29
|
-
|
|
30
|
-
<script>
|
|
31
|
-
import dayjs from "dayjs";
|
|
32
|
-
import tendency from '@/components/tendency.vue';
|
|
33
|
-
import {
|
|
34
|
-
getProjectName,
|
|
35
|
-
getSdkAppId,
|
|
36
|
-
} from "@/api/index";
|
|
37
|
-
import { getUrlParam } from "@/utils/utils";
|
|
38
|
-
|
|
39
|
-
const defaultProjectName = 'uniappApiExampleExt';
|
|
40
|
-
export default {
|
|
41
|
-
data() {
|
|
42
|
-
return {
|
|
43
|
-
headerTable: [
|
|
44
|
-
{
|
|
45
|
-
label: "时间",
|
|
46
|
-
name: "time",
|
|
47
|
-
},
|
|
48
|
-
],
|
|
49
|
-
|
|
50
|
-
graphicTitle: '新增 sdkAppId',
|
|
51
|
-
sevenDay: [],
|
|
52
|
-
sevenDate: [],
|
|
53
|
-
legend: [],
|
|
54
|
-
selectProjectNameList: [],
|
|
55
|
-
preSelectValue: [], // 前面选择的项目名称, 用于对比选择是否改变, 从而减少请求
|
|
56
|
-
selectValue: [],
|
|
57
|
-
preDateRange: [], // 前面选择的日期选择范围, 用于对比时间是否改变, 从而减少请求
|
|
58
|
-
dateRange: [], // 默认最近一周
|
|
59
|
-
loading: false,
|
|
60
|
-
tableLoading: false,
|
|
61
|
-
tableData: [],
|
|
62
|
-
};
|
|
63
|
-
},
|
|
64
|
-
created() {
|
|
65
|
-
this.initData();
|
|
66
|
-
},
|
|
67
|
-
mounted() {
|
|
68
|
-
const fromSource = getUrlParam('from') || '';
|
|
69
|
-
// 访问来源于小马时,隐藏侧边栏、项目选择项
|
|
70
|
-
if (fromSource === 'bi') {
|
|
71
|
-
document.querySelector('.sidebar').style.display = 'none'; // 隐藏侧边栏
|
|
72
|
-
document.querySelector('.header').style.display = 'none'; // 隐藏 header
|
|
73
|
-
document.querySelector('.tags').style.display = 'none'; // 隐藏 tags
|
|
74
|
-
document.querySelector('.query-project-name').style.display = 'none'; // 隐藏 select
|
|
75
|
-
document.querySelector('.content-box').style.position = 'static';
|
|
76
|
-
}
|
|
77
|
-
},
|
|
78
|
-
components: {
|
|
79
|
-
tendency,
|
|
80
|
-
},
|
|
81
|
-
methods: {
|
|
82
|
-
async initData() {
|
|
83
|
-
try {
|
|
84
|
-
await this.getProjectNameList();
|
|
85
|
-
await this.getNewSdkAppId();
|
|
86
|
-
} catch (err) {
|
|
87
|
-
console.log("获取数据失败", err);
|
|
88
|
-
}
|
|
89
|
-
},
|
|
90
|
-
// 获取所有的项目名称列表
|
|
91
|
-
async getProjectNameList() {
|
|
92
|
-
try {
|
|
93
|
-
const response = await getProjectName({ type: 'external' });
|
|
94
|
-
this.selectProjectNameList = response.data && response.data.projectNameList || [];
|
|
95
|
-
|
|
96
|
-
// 项目名称处理
|
|
97
|
-
const urlProjectNameList = (getUrlParam('projectName') || '').length > 0 ? getUrlParam('projectName').split(',') : [];
|
|
98
|
-
if (urlProjectNameList.length > 0) {
|
|
99
|
-
this.selectValue = urlProjectNameList;
|
|
100
|
-
this.preSelectValue = this.selectValue;
|
|
101
|
-
this.headerTable = [...this.headerTable, ...urlProjectNameList.map(str => ({ length: str, name: `${str}Value` }))]
|
|
102
|
-
} else {
|
|
103
|
-
this.selectValue = [defaultProjectName];
|
|
104
|
-
this.preSelectValue = this.selectValue;
|
|
105
|
-
this.headerTable = [...this.headerTable, {
|
|
106
|
-
label: defaultProjectName,
|
|
107
|
-
name: `${defaultProjectName}Value`,
|
|
108
|
-
}]
|
|
109
|
-
}
|
|
110
|
-
// 查询时间处理
|
|
111
|
-
let startTime = getUrlParam('startTime') || '';
|
|
112
|
-
let endTime = getUrlParam('endTime') || '';
|
|
113
|
-
startTime = startTime.includes('-') ? startTime : +startTime;
|
|
114
|
-
endTime = endTime.includes('-') ? endTime : +endTime;
|
|
115
|
-
// 字符串时间('2022-08-03 12:12:04')、时间戳时间(1658592000000),转成日期时间戳
|
|
116
|
-
if (startTime && endTime) { // url 中同时包含 startTime、endTime
|
|
117
|
-
startTime = dayjs(dayjs(startTime).format('YYYY-MM-DD HH:mm:ss')).valueOf();
|
|
118
|
-
endTime = dayjs(dayjs(endTime).format('YYYY-MM-DD HH:mm:ss')).valueOf();
|
|
119
|
-
} else if (!startTime && !endTime) { // url 中没有 startTime、endTime
|
|
120
|
-
startTime = (new Date()).getTime() - 7 * 24 * 60 * 60 * 1000;
|
|
121
|
-
endTime = (new Date()).getTime();
|
|
122
|
-
} else if (startTime && !endTime) { // url 中有 startTime 没有 endTime
|
|
123
|
-
startTime = dayjs(dayjs(startTime).format('YYYY-MM-DD')).valueOf();
|
|
124
|
-
endTime = dayjs(dayjs(startTime + 7 * 24 * 60 * 60 * 1000).format('YYYY-MM-DD')).valueOf();
|
|
125
|
-
} else if (!startTime && endTime) { // url 中没有 startTime 有 endTime
|
|
126
|
-
endTime = dayjs(dayjs(endTime).format('YYYY-MM-DD HH:mm:ss')).valueOf();
|
|
127
|
-
startTime = dayjs(dayjs(endTime - 7 * 24 * 60 * 60 * 1000).format('YYYY-MM-DD')).valueOf();
|
|
128
|
-
}
|
|
129
|
-
this.dateRange = [startTime, endTime];
|
|
130
|
-
} catch (error) {
|
|
131
|
-
console.error('getProjectNameList = ', error);
|
|
132
|
-
}
|
|
133
|
-
},
|
|
134
|
-
// 获取新增 sdkAppId 数据
|
|
135
|
-
async getNewSdkAppId() {
|
|
136
|
-
this.tableData = [];
|
|
137
|
-
this.sevenDay = [];
|
|
138
|
-
this.sevenDate = [];
|
|
139
|
-
this.legend = [];
|
|
140
|
-
const projectNameList = this.selectValue;
|
|
141
|
-
if (projectNameList.length === 0) {
|
|
142
|
-
return;
|
|
143
|
-
}
|
|
144
|
-
let startTimeStamps, endTimeStamps;
|
|
145
|
-
if (this.dateRange.length > 0) {
|
|
146
|
-
startTimeStamps = dayjs(dayjs(this.dateRange[0]).format('YYYY-MM-DD')).valueOf();
|
|
147
|
-
endTimeStamps = dayjs(dayjs(this.dateRange[1]).format('YYYY-MM-DD')).valueOf();
|
|
148
|
-
}
|
|
149
|
-
// 项目选择未改变且查询时间段未改变时, 不请求新的数据
|
|
150
|
-
if (this.dateRange.length > 0) {
|
|
151
|
-
if ((this.preSelectValue.join(',') === projectNameList.join(',')) && (this.preDateRange.join(',') === `${startTimeStamps},${endTimeStamps}`)) {
|
|
152
|
-
return;
|
|
153
|
-
}
|
|
154
|
-
} else {
|
|
155
|
-
if (this.preSelectValue.join(',') === projectNameList.join(',')) {
|
|
156
|
-
return;
|
|
157
|
-
}
|
|
158
|
-
}
|
|
159
|
-
this.preSelectValue = projectNameList;
|
|
160
|
-
this.preDateRange = [startTimeStamps, endTimeStamps];
|
|
161
|
-
this.headerTable = [this.headerTable[0], ...this.preSelectValue.map(str => ({ label: str, name: str }))]
|
|
162
|
-
|
|
163
|
-
try {
|
|
164
|
-
this.loading = true;
|
|
165
|
-
this.tableLoading = true;
|
|
166
|
-
const response = await getSdkAppId({
|
|
167
|
-
projectNameList,
|
|
168
|
-
startTimeStamps,
|
|
169
|
-
endTimeStamps,
|
|
170
|
-
});
|
|
171
|
-
this.loading = false;
|
|
172
|
-
this.tableLoading = false;
|
|
173
|
-
const { data } = response;
|
|
174
|
-
this.legend = projectNameList;
|
|
175
|
-
this.sevenDay = Object.keys(data[projectNameList[0]].data).map(str => dayjs(+str).format('YYYY-MM-DD'));
|
|
176
|
-
const dataList = projectNameList.map(key => {
|
|
177
|
-
const temp = data[key].data;
|
|
178
|
-
return Object.keys(temp).map(val => temp[val].num);
|
|
179
|
-
});
|
|
180
|
-
this.graphicTitle = `${this.selectValue.join(',')} 新增 sdkAppId`
|
|
181
|
-
this.sevenDate = dataList;
|
|
182
|
-
const tempData = dataList[0].map((key, idx) => {
|
|
183
|
-
let result = {
|
|
184
|
-
time: this.sevenDay[idx],
|
|
185
|
-
};
|
|
186
|
-
projectNameList.forEach((key, index) => {
|
|
187
|
-
const dateKey = new Date(this.sevenDay[idx] + ' 00:00:00').getTime();
|
|
188
|
-
const obj = data[key].data;
|
|
189
|
-
const sdkAppIdList = obj[`${dateKey}`].list.map(obj => obj.sdkAppId);
|
|
190
|
-
const content = sdkAppIdList.length > 0 ? dataList[index][idx] + '\nsdkAppId:' + sdkAppIdList.join(', ') : 0;
|
|
191
|
-
// const content = sdkAppIdList.length > 0 ? dataList[index][idx] + '【 ' + sdkAppIdList.join(', ') + ' 】' : 0;
|
|
192
|
-
result = {
|
|
193
|
-
...result,
|
|
194
|
-
[`${key}`]: content,
|
|
195
|
-
}
|
|
196
|
-
});
|
|
197
|
-
return result;
|
|
198
|
-
});
|
|
199
|
-
this.tableData = tempData;
|
|
200
|
-
} catch (error) {
|
|
201
|
-
console.error(' getNewSdkAppId = ', error);
|
|
202
|
-
this.loading = false;
|
|
203
|
-
this.tableLoading = false;
|
|
204
|
-
}
|
|
205
|
-
},
|
|
206
|
-
},
|
|
207
|
-
};
|
|
208
|
-
</script>
|
|
209
|
-
|
|
210
|
-
<style lang="less">
|
|
211
|
-
// @import "../style/mixin";
|
|
212
|
-
|
|
213
|
-
.query-container {
|
|
214
|
-
display: flex;
|
|
215
|
-
padding: 20px;
|
|
216
|
-
align-items: center;
|
|
217
|
-
|
|
218
|
-
.date-range-label {
|
|
219
|
-
margin-left: 12px;
|
|
220
|
-
}
|
|
221
|
-
|
|
222
|
-
.query-select-container {
|
|
223
|
-
width: 260px;
|
|
224
|
-
}
|
|
225
|
-
}
|
|
226
|
-
|
|
227
|
-
.el-table {
|
|
228
|
-
.cell {
|
|
229
|
-
white-space: pre-line;
|
|
230
|
-
}
|
|
231
|
-
}
|
|
232
|
-
|
|
233
|
-
.demo-table-expand {
|
|
234
|
-
font-size: 0;
|
|
235
|
-
}
|
|
236
|
-
|
|
237
|
-
.demo-table-expand label {
|
|
238
|
-
width: 90px;
|
|
239
|
-
color: #99a9bf;
|
|
240
|
-
}
|
|
241
|
-
|
|
242
|
-
.demo-table-expand .el-form-item {
|
|
243
|
-
margin-right: 0;
|
|
244
|
-
margin-bottom: 0;
|
|
245
|
-
width: 50%;
|
|
246
|
-
}
|
|
247
|
-
|
|
248
|
-
.table_container {
|
|
249
|
-
padding: 20px;
|
|
250
|
-
}
|
|
251
|
-
|
|
252
|
-
.Pagination {
|
|
253
|
-
display: flex;
|
|
254
|
-
justify-content: flex-start;
|
|
255
|
-
margin-top: 8px;
|
|
256
|
-
}
|
|
257
|
-
|
|
258
|
-
.avatar-uploader .el-upload {
|
|
259
|
-
border: 1px dashed #d9d9d9;
|
|
260
|
-
border-radius: 6px;
|
|
261
|
-
cursor: pointer;
|
|
262
|
-
position: relative;
|
|
263
|
-
overflow: hidden;
|
|
264
|
-
}
|
|
265
|
-
|
|
266
|
-
.avatar-uploader .el-upload:hover {
|
|
267
|
-
border-color: #20a0ff;
|
|
268
|
-
}
|
|
269
|
-
|
|
270
|
-
.avatar-uploader-icon {
|
|
271
|
-
font-size: 28px;
|
|
272
|
-
color: #8c939d;
|
|
273
|
-
width: 120px;
|
|
274
|
-
height: 120px;
|
|
275
|
-
line-height: 120px;
|
|
276
|
-
text-align: center;
|
|
277
|
-
}
|
|
278
|
-
|
|
279
|
-
.avatar {
|
|
280
|
-
width: 120px;
|
|
281
|
-
height: 120px;
|
|
282
|
-
display: block;
|
|
283
|
-
}
|
|
284
|
-
</style>
|
|
@@ -1,18 +0,0 @@
|
|
|
1
|
-
import vue from '@vitejs/plugin-vue';
|
|
2
|
-
import { resolve } from 'path';
|
|
3
|
-
|
|
4
|
-
export default {
|
|
5
|
-
base: './',
|
|
6
|
-
resolve: {
|
|
7
|
-
alias: {
|
|
8
|
-
"@": resolve(__dirname, 'src'),
|
|
9
|
-
},
|
|
10
|
-
},
|
|
11
|
-
plugins: [vue()],
|
|
12
|
-
optimizeDeps: {
|
|
13
|
-
include: ['schart.js']
|
|
14
|
-
},
|
|
15
|
-
server: {
|
|
16
|
-
port: 8080,
|
|
17
|
-
}
|
|
18
|
-
}
|