ClassDataProxy.js
8.8 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
class ClassDataProxy {
constructor() {
}
//获取课堂初始化的参数
static getInitClassData() {
let _data = {};
_data.classId = this.classId;
_data.portal = this.portal;
_data.userRole = this.userRole;
_data.userName = this.userName;
_data.userId = this.userId;
return _data;
}
//获取加入课堂的参数
static getJoinClassData() {
let _data = {};
_data.password = this.password;
_data.userName = this.userName;
_data.autoLogin = this.autoLogin;
return _data;
}
//生成时间戳毫秒
static creatTimestamp() {
let time = new Date().getTime();
return time;
}
//生成时间戳 string
static creatTimestampStr() {
let curTime = new Date();
let timeStr = "" + curTime.getFullYear() + "-";
timeStr += (curTime.getMonth() + 1) + "-";
timeStr += curTime.getDate() + "-";
timeStr += curTime.getHours() + "-";
timeStr += curTime.getMinutes() + "-";
timeStr += curTime.getSeconds();
return timeStr;
}
//把时间戳转为时间格式
static timestampToDateTime(value) {
var theTime = parseInt(value);// 秒
var theTime1 = 0;// 分
var theTime2 = 0;// 小时
if (theTime > 60) {
theTime1 = parseInt(theTime / 60);
theTime = parseInt(theTime % 60);
if (theTime1 > 60) {
theTime2 = parseInt(theTime1 / 60);
theTime1 = parseInt(theTime1 % 60);
}
}
var result = "" + parseInt(theTime) + "";
if (result < 10) {
result = "0" + parseInt(theTime) + "";
}
if (theTime1 > 0) {
if(theTime1<10){
result = "0" + parseInt(theTime1) + ":" + result;
}else{
result = "" + parseInt(theTime1) + ":" + result;
}
}
if (theTime2 > 0) {
if(theTime2<10){
result = "0" + parseInt(theTime2) + ":" + result;
}else {
result = "" + parseInt(theTime2) + ":" + result;
}
}
return result;
}
//把时间戳转为时间格式 只显示时分秒
static timestampToDateTimeSign(value) {
let theTime = new Date(value * 1000);
let hours = theTime.getHours();
let minutes = theTime.getMinutes();
let seconds = theTime.getSeconds();
let timeValue = '';
timeValue = ((hours < 10) ? "0" : "") + hours
timeValue += ((minutes < 10) ? ":0" : ":") + minutes
timeValue += ((seconds < 10) ? ":0" : ":") + seconds
return timeValue;
}
//把时间戳转为时间格式
static timestampToDateTimeFull(value) {
var theTime = parseInt(value);// 秒
var theTime1 = 0;// 分
var theTime2 = 0;// 小时
if (theTime > 60) {
theTime1 = parseInt(theTime / 60);
theTime = parseInt(theTime % 60);
if (theTime1 > 60) {
theTime2 = parseInt(theTime1 / 60);
theTime1 = parseInt(theTime1 % 60);
}
}
var result = "" + parseInt(theTime) + "";
if (result < 10) {
result = "0" + parseInt(theTime) + "";
}
if (theTime1 > 0) {
if(theTime1<10){
result = "0" + parseInt(theTime1) + ":" + result;
}else{
result = "" + parseInt(theTime1) + ":" + result;
}
}else {
result = "0" + parseInt(theTime1) + ":" + result;
}
if (theTime2 > 0) {
if(theTime2<10){
result = "0" + parseInt(theTime2) + ":" + result;
}else {
result = "" + parseInt(theTime2) + ":" + result;
}
}else {
result = "0" + parseInt(theTime2) + ":" + result;
}
return result;
}
//显示完整大小
static getFitInFull(w1, h1, w2, h2) {
if (w1 == 0 || h1 == 0 || w2 == 0 || h2 == 0) {
console.warn("getFull->传入的参数值必须大于0", w1, h1, w2, h2);
return;
}
let wScale = w2 / w1;
let hScale = h2 / h1;
let whScale = w2 / h2;
if (wScale <= 1 && hScale <= 1) {
return {w: parseInt(w2), h: parseInt(h2)}
}
let newW = w2;
let newH = h2;
if (wScale > hScale) {
//缩放宽
newW = w1;
newH = newW / whScale;
} else {
//缩放高
newH = h1;
newW = newH * whScale;
}
return {w: parseInt(newW), h: parseInt(newH)}
}
//按宽度显示
static getFitInWidth(w1, h1, w2, h2) {
if (w1 == 0 || h1 == 0 || w2 == 0 || h2 == 0) {
console.warn("getW->传入的参数值必须大于0", w1, h1, w2, h2);
return;
}
let wScale = w2 / w1;
let hScale = h2 / h1;
let whScale = w2 / h2;
let newW = w1;
let newH = newW / whScale;
return {w: parseInt(newW), h: parseInt(newH)}
}
//按高度显示
static getFitInHeight(w1, h1, w2, h2) {
if (w1 == 0 || h1 == 0 || w2 == 0 || h2 == 0) {
console.warn("getH->传入的参数值必须大于0", w1, h1, w2, h2);
return;
}
let wScale = w2 / w1;
let hScale = h2 / h1;
let whScale = w2 / h2;
let newH = h1;
let newW = newH * whScale;
return {w: parseInt(newW), h: parseInt(newH)}
}
//获取浏览器和信息
static getBrowserInfo() {
var Sys = {};
var ua = navigator.userAgent.toLowerCase();
var re = /(trident|msie|firefox|chrome|opera|version).*?([\d.]+)/;
var m = ua.match(re);
if (!m) m = ["version/1.0.0", "version", "1.0.0"];
Sys.explorer = m[1].replace(/version/, "'safari");
//判断是否是IE11
if (Sys.explorer == "trident") {
Sys.explorer = "IE11"
Sys.explorerVersion = "11.0";
} else if (Sys.explorer == "msie") {
//IE
Sys.explorer = "IE"
Sys.explorerVersion = m[2];
} else {
//非IE
Sys.explorerVersion = m[2];
}
return Sys;
}
}
//Class
ClassDataProxy.siteId = "";
ClassDataProxy.classType = 1;
ClassDataProxy.className = "";
ClassDataProxy.classId = 0;
ClassDataProxy.classStatus = 0;
ClassDataProxy.classTimestamp = 0;
ClassDataProxy.recordPlaybackMaxTime = 0;
ClassDataProxy.isRecordPlayBack = false;
ClassDataProxy.portal = "";//IP+Port
ClassDataProxy.classStartTime = "";
ClassDataProxy.classStopTime = "";
ClassDataProxy.classBeginTime = "";
ClassDataProxy.classEndTime = "";
//USER
ClassDataProxy.userName = "";
ClassDataProxy.userId = "0";
ClassDataProxy.password = "";
ClassDataProxy.nodeId = 0;
ClassDataProxy.userRole = "normal";
ClassDataProxy.autoLogin = "";
ClassDataProxy.rosterList={};//用户列表数据
ClassDataProxy.rosterListUpdata={};//用户更新的数据
ClassDataProxy.curRosterHostInfo;//老师更新的信息
ClassDataProxy.curUserInfoTeaOrStu;
ClassDataProxy.curRosterInvisibleNodeId=0;
ClassDataProxy.USER_HOST = 'host';
ClassDataProxy.USER_NOTMAL = 'normal';
ClassDataProxy.USER_INVISIBLE = 'invisible';
ClassDataProxy.docServer = "";//文档服务器地址
ClassDataProxy.maxAudioChannels = 0;//最大音频路数
ClassDataProxy.maxVideoChannels = 0;//最大视频路数
ClassDataProxy.maxMediaChannels=0;//最大音视频路数,以音视频路数中的最大值为准
ClassDataProxy.currentPageNum = 1,//页码是第1页
ClassDataProxy.currentDocId = 0,//父级(文档)的itemIdx标识,如果当前没有文档,设置为0即可
//视频质量相关设置
ClassDataProxy.fps = 15;//帧频
ClassDataProxy.gop = 3;//关键帧间隔(秒)
ClassDataProxy.videoQuality = 2;//画面质量 0-低;1-中;2-高;
ClassDataProxy.curVideoQuality = 2;//画面质量 0-低;1-中;2-高;
ClassDataProxy.ssTunnelAppURL = '';//屏幕共享插件的地址
ClassDataProxy.locationProtocol="http://";
ClassDataProxy.locationProt = "192.168.31.8:3000";//端口
ClassDataProxy.SCENE_DOC=0;
ClassDataProxy.SCENE_SCREEN_SHARE=1;
ClassDataProxy.SCENE_MEDIA_SHARE=2;
ClassDataProxy.SCENE_MUSIC_SHARE=3
ClassDataProxy.currentSceneApeName=ClassDataProxy.SCENE_DOC;//默认显示文档区域
ClassDataProxy.isKeypress = true;//控制按回车键发送消息
ClassDataProxy.serverTimeDistance=0;//
ClassDataProxy.localConfig={};//语言编码
ClassDataProxy.isDraw;//是否在使用画笔
ClassDataProxy.isLaser;//是否在使用激光笔
ClassDataProxy.curSeek=1; //当前伴音seek;
ClassDataProxy.curVideoSeek=1;//当前媒体共享seek;
ClassDataProxy.isEnableDraw=false;//学生端画笔默认隐藏
export default ClassDataProxy;