-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex.html
632 lines (588 loc) · 25.4 KB
/
index.html
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
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8" />
<meta http-equiv="X-UA-Compatible" content="IE=edge" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>StreamerHelper配置助手</title>
<link rel="stylesheet" href="https://cdn.staticfile.org/element-ui/2.15.7/theme-chalk/index.min.css" />
<style>
* {
margin: 0px;
padding: 0px;
}
.outside-box {
width: 100%;
height: 100vh;
display: flex;
flex-direction: column;
flex-grow: 10;
background-color: #eee;
}
.top-box {
height: 70px;
}
.bottom-box {
flex-grow: 1;
margin: 10px;
}
#list-card {
overflow-y: scroll;
height: 80vh;
}
#main {
padding: 10px;
}
#json-code {
height: 75vh;
}
.block {
display: flex;
justify-content: space-between;
align-items: center;
flex-wrap: wrap;
margin-bottom: 5px;
}
.el-tag+.el-tag {
margin-left: 10px;
}
.button-new-tag {
margin-left: 10px;
height: 32px;
line-height: 30px;
padding-top: 0;
padding-bottom: 0;
}
.input-new-tag {
width: 90px;
margin-left: 10px;
vertical-align: bottom;
}
[v-cloak] {
display: none;
}
</style>
</head>
<body>
<div class="outside-box" id="app" v-cloak>
<div class="top-box">
<el-header>
<el-card id="header-card"> {{title}} {{version + '版本'}} By: <a
href="https://github.com/ni00/StreamerHelperTool">倪小白</a> </el-card>
</el-header>
</div>
<el-card class="bottom-box">
<el-row id="main-box">
<el-col :span="6">
<div id="aside">
<div id="add" align="center">
<el-button type="primary" icon="el-icon-plus" @click="card_add">添加录制信息</el-button>
</el-button>
</div>
<el-card id="list-card">
<!-- list-card -->
<el-card v-for='(item,index) of infoObject.streamerInfo' class="box-card">
<div slot="header" class="clearfix">
<span>{{item.name}}</span>
<el-button-group style="float: right; padding: 0 0">
<el-button size="mini" icon="el-icon-edit" @click="card_edit(index)">
</el-button>
<el-button size="mini" icon="el-icon-copy-document" @click="card_copy(index)">
</el-button>
<el-button size="mini" icon="el-icon-delete" @click="card_del(index)">
</el-button>
</el-button-group>
</div>
<div class="text item">
{{item.roomUrl}}<br>
{{item.desc}}<br>
<el-tag v-for="tag in item.tags" :key="tag" type="" effect="light">
{{ tag }}
</el-tag>
</div>
</el-card>
<!-- list-card -->
</div>
</el-col>
<el-col :span="18">
<div id="main">
<div align="center">
<el-button-group>
<el-button type="primary" icon="el-icon-edit" @click="userInfo">用户设置</el-button>
<el-button type="success" icon="el-icon-download" @click="downloadInfoJson">下载配置
</el-button>
<el-button type="warning" icon="el-icon-upload2" id="fileImport" @click="clickLoad">上传配置
</el-button>
<el-button type="danger" icon="el-icon-delete" @click="deleteInfoJson">清空配置</el-button>
</el-button-group>
</div>
<el-input id="json-code" type="textarea" :rows="25" placeholder="请输入内容" v-model="textarea1">
</el-input>
</div>
</el-col>
</el-row>
</el-card>
<!-- userDialog -->
<el-dialog title="用户设置" :visible.sync="userDialogVisible" width="40%" center>
<el-divider content-position="center">基础配置</el-divider>
<div class="block"><span>调试开关 </span>
<el-switch v-model="infoObject.StreamerHelper.debug" active-color="#13ce66" inactive-color="#ff4949">
</el-switch>
</div>
<div class="block">
<span class="demonstration">投稿检测间隔(秒)</span>
<el-input-number v-model="infoObject.StreamerHelper.roomCheckTime" label="秒">
</el-input-number>
</div>
<div class="block">
<span class="demonstration">录制检测间隔(秒)</span>
<el-input-number v-model="infoObject.StreamerHelper.recycleCheckTime" label="秒">
</el-input-number>
</div>
<div class="block">
<span class="demonstration">投稿时忽略小于此大小的文件(MB)</span>
<el-input-number v-model="infoObject.StreamerHelper.videoPartLimitSize" label="秒">
</el-input-number>
</div>
<div class="block">
<span class="demonstration">此级别之上(包括)的日志将被推送</span>
<el-radio-group v-model="infoObject.StreamerHelper.logLevel" size="mini">
<el-radio-button label="trace"></el-radio-button>
<el-radio-button label="debug"></el-radio-button>
<el-radio-button label="info"></el-radio-button>
<el-radio-button label="warn"></el-radio-button>
<el-radio-button label="error"></el-radio-button>
</el-radio-group>
</div>
<el-divider content-position="center">邮箱配置</el-divider>
<div class="block"><span class="demonstration">邮箱推送</span>
<el-switch v-model="infoObject.StreamerHelper.push.mail.enable" active-color="#13ce66"
inactive-color="#ff4949">
</el-switch>
</div>
<div>
<el-row>
<el-col :span="12">
<span class="demonstration">STMP 服务主机</span>
</el-col>
<el-col :span="12">
<el-input v-model="infoObject.StreamerHelper.push.mail.host" size="small"></el-input>
</el-col>
</el-row>
</div>
<div class="block">
<span class="demonstration">STMP 服务端口</span>
<el-input-number v-model="infoObject.StreamerHelper.push.mail.port" :min="0" :max="65535">
</el-input-number>
</div>
<div>
<el-row>
<el-col :span="12">
<span class="demonstration">STMP 服务邮箱</span>
</el-col>
<el-col :span="12">
<el-input v-model="infoObject.StreamerHelper.push.mail.from" size="small"></el-input>
</el-col>
</el-row>
</div>
<div>
<el-row>
<el-col :span="12">
<span class="demonstration">STMP 服务密码</span>
</el-col>
<el-col :span="12">
<el-input v-model="infoObject.StreamerHelper.push.mail.pwd" size="small"></el-input>
</el-col>
</el-row>
</div>
<div>
<el-row>
<el-col :span="12">
<span class="demonstration">接受者邮箱</span>
</el-col>
<el-col :span="12">
<el-input v-model="infoObject.StreamerHelper.push.mail.to" size="small"></el-input>
</el-col>
</el-row>
</div>
<div class="block"><span class="demonstration">安全服务</span>
<el-switch v-model="infoObject.StreamerHelper.push.mail.secure" active-color="#13ce66"
inactive-color="#ff4949">
</el-switch>
</div>
<el-divider content-position="center">微信配置</el-divider>
<div class="block"><span class="demonstration">微信推送</span>
<el-switch v-model="infoObject.StreamerHelper.push.wechat.enable" active-color="#13ce66"
inactive-color="#ff4949">
</el-switch>
</div>
<div>
<el-row>
<el-col :span="12">
<span class="demonstration">Server 酱 sendKey</span>
</el-col>
<el-col :span="12">
<el-input v-model="infoObject.StreamerHelper.push.wechat.sendKey" size="small"></el-input>
</el-col>
</el-row>
</div>
<el-divider content-position="center">B站配置</el-divider>
<div>
<el-row>
<el-col :span="12">
<span class="demonstration">nickname</span>
</el-col>
<el-col :span="12">
<el-input v-model="infoObject.personInfo.nickname" size="small"></el-input>
</el-col>
</el-row>
</div>
<div>
<el-row>
<el-col :span="12">
<span class="demonstration">access_token</span>
</el-col>
<el-col :span="12">
<el-input v-model="infoObject.personInfo.access_token" size="small"></el-input>
</el-col>
</el-row>
</div>
<div>
<el-row>
<el-col :span="12">
<span class="demonstration">refresh_token</span>
</el-col>
<el-col :span="12">
<el-input v-model="infoObject.personInfo.refresh_token" size="small"></el-input>
</el-col>
</el-row>
</div>
<div class="block">
<span class="demonstration">expires_in</span>
<el-input-number v-model="infoObject.personInfo.expires_in">
</el-input-number>
</div>
<div class="block">
<span class="demonstration">tokenSignDate</span>
<el-input-number v-model="infoObject.personInfo.tokenSignDate">
</el-input-number>
</div>
<div class="block">
<span class="demonstration">mid</span>
<el-input-number v-model="infoObject.personInfo.mid">
</el-input-number>
</div>
<div class="block">
<span class="demonstration">cookies</span>
<el-input-number v-model="infoObject.personInfo.cookies">
</el-input-number>
</div>
<span slot="footer" class="dialog-footer">
<el-button type="primary" @click="userDialogVisible = false">确 定</el-button>
</span>
</el-dialog>
<!-- userDialog -->
<!-- roomDialog -->
<el-dialog title="录制信息" :visible.sync="roomDialogVisible" width="40%" center>
<div>
<el-row>
<el-col :span="12">
<span class="demonstration">主播名</span>
</el-col>
<el-col :span="12">
<el-input v-model="oneRoom.name" size="small"></el-input>
</el-col>
</el-row>
</div>
<div class="block"><span class="demonstration">是否投稿</span>
<el-switch v-model="oneRoom.uploadLocalFile" active-color="#13ce66" inactive-color="#ff4949">
</el-switch>
</div>
<div class="block"><span class="demonstration">是否删除本地视频文件</span>
<el-switch v-model="oneRoom.deleteLocalFile" active-color="#13ce66" inactive-color="#ff4949">
</el-switch>
</div>
<div class="block">
<span class="demonstration">投稿成功后延迟删除本地文件的时间(天)</span>
<el-input-number v-model="oneRoom.delayTime" label="天">
</el-input-number>
</div>
<div>
<el-row>
<el-col :span="12">
<span class="demonstration">稿件标题,支持占位符 </span>
</el-col>
<el-col :span="12">
<el-input v-model="oneRoom.templateTitle" size="small"></el-input>
</el-col>
</el-row>
</div>
<div>
<el-row>
<el-col :span="12">
<span class="demonstration">稿件描述 </span>
</el-col>
<el-col :span="12">
<el-input v-model="oneRoom.desc" size="small"></el-input>
</el-col>
</el-row>
</div>
<div>
<el-row>
<el-col :span="12">
<span class="demonstration">稿件来源</span>
</el-col>
<el-col :span="12">
<el-radio-group v-model="oneRoom.copyright">
<el-radio-button label=1>自制</el-radio-button>
<el-radio-button label=2>转载</el-radio-button>
</el-radio-group>
</el-col>
</el-row>
</div>
<div>
<el-row>
<el-col :span="12">
<span class="demonstration">稿件直播源(需要copyright为2)</span>
</el-col>
<el-col :span="12">
<el-input v-model="oneRoom.source" size="small"></el-input>
</el-col>
</el-row>
</div>
<div>
<el-row>
<el-col :span="12">
<span class="demonstration">稿件动态</span>
</el-col>
<el-col :span="12">
<el-input v-model="oneRoom.dynamic" size="small"></el-input>
</el-col>
</el-row>
</div>
<div>
<el-row>
<el-col :span="12">
<span class="demonstration">直播间地址</span>
</el-col>
<el-col :span="12">
<el-input v-model="oneRoom.roomUrl" size="small"></el-input>
</el-col>
</el-row>
</div>
<div class="block">
<span class="demonstration">稿件分区</span>
<el-input-number v-model="oneRoom.tid" label="tid">
</el-input-number>
</div>
<div>
<el-row>
<el-col :span="12">
<span class="demonstration">标签(至少一个)</span>
</el-col>
<el-col :span="12">
<el-tag :key="tag" v-for="tag in oneRoom.tags" closable :disable-transitions="false"
@close="handleClose(tag)">
{{tag}}
</el-tag>
<el-input class="input-new-tag" v-if="inputVisible" v-model="inputValue" ref="saveTagInput"
size="small" @keyup.enter.native="handleInputConfirm" @blur="handleInputConfirm">
</el-input>
<el-button v-else class="button-new-tag" size="small" @click="showInput">+ 新标签</el-button>
</el-col>
</el-row>
</div>
<span slot="footer" class="dialog-footer">
<el-button type="primary" @click="roomEvent">确 定</el-button>
</span>
</el-dialog>
<!-- roomDialog -->
<input type="file" id="files" ref="refFile" style="display: none" v-on:change="fileLoad">
</div>
<!-- Vue -->
<script src="https://cdn.staticfile.org/vue/2.6.14/vue.min.js"></script>
<script src="https://cdn.staticfile.org/element-ui/2.15.7/index.min.js"></script>
<script>
function download(filename, text) {
var element = document.createElement('a');
element.setAttribute('href', 'data:text/plain;charset=utf-8,' + encodeURIComponent(text));
element.setAttribute('download', filename);
element.style.display = 'none';
document.body.appendChild(element);
element.click();
document.body.removeChild(element);
}
const json_raw = `{"StreamerHelper":{"debug":false,"roomCheckTime":600,"recycleCheckTime":1800,"videoPartLimitSize":100,"logLevel":"error","push":{"mail":{"enable":true,"host":"","port":465,"from":"","pwd":"","to":"","secure":true},"wechat":{"enable":false,"sendkey":""}}},"personInfo":{"nickname":"","access_token":"","refresh_token":"","expires_in":0,"tokenSignDate":0,"mid":0,"cookies":""},"streamerInfo":[{"name":"主播1","uploadLocalFile":true,"deleteLocalFile":true,"templateTitle":"{{name}}{{time}} 直播","delayTime":0,"desc":"","source":"","dynamic":"","copyright":2,"roomUrl":"https://live.xxx.com/111","tid":121,"tags":["tag1","tag2","tag3"]},{"name":"主播2","uploadLocalFile":true,"deleteLocalFile":false,"templateTitle":"{{name}}{{time}} 直播","delayTime":1,"desc":"","source":"","dynamic":"","copyright":2,"roomUrl":"https://live.xxx.com/222","tid":171,"tags":["tag1","tag2","tag3"]}]}`
function deepCopy(obj) {
let data = JSON.stringify(obj)
let newData = JSON.parse(data)
return newData
}
const room_raw = {
"name": "主播1",
"uploadLocalFile": true,
"deleteLocalFile": true,
"templateTitle": "{{name}}{{time}} 直播",
"delayTime": 0,
"desc": "",
"source": "",
"dynamic": "",
"copyright": 2,
"roomUrl": "https://live.xxx.com/111",
"tid": 121,
"tags": [
"tag1",
"tag2",
"tag3"
]
}
const vm = new Vue({
el: "#app",
data: {
title: "StreamerHelper配置助手",
version: '1.0',
infoObject: JSON.parse(json_raw),
userDialogVisible: false,
roomDialogVisible: false,
inputVisible: false,
inputValue: '',
roomFlag: -1,
userDialogValues: {
"debug": false,
"roomCheckTime": 600,
"recycleCheckTime": 1800,
"videoPartLimitSize": 100,
"logLevel": "error",
"push": {
"mail": {
"enable": true,
"host": "smtp.qq.com",
"port": 465,
"from": "***@qq.com",
"pwd": "***",
"to": "***@gmail.com",
"secure": true
},
"wechat": {
"enable": true,
"sendKey": "***"
}
},
"personInfo": {
"nickname": "",
"access_token": "",
"refresh_token": "",
"expires_in": 0,
"tokenSignDate": 0,
"mid": 0,
"cookies": ""
}
},
oneRoom: deepCopy(room_raw)
},
methods: {
userInfo() {
this.userDialogVisible = true;
},
handleClose(tag) {
this.oneRoom.tags.splice(this.oneRoom.tags.indexOf(tag), 1);
},
showInput() {
this.inputVisible = true;
this.$nextTick(_ => {
this.$refs.saveTagInput.$refs.input.focus();
});
},
handleInputConfirm() {
let inputValue = this.inputValue;
if (inputValue) {
this.oneRoom.tags.push(inputValue);
}
this.inputVisible = false;
this.inputValue = '';
},
downloadInfoJson() {
download('info.json', this.textarea1)
this.$message({
message: 'info.json下载成功',
type: 'success'
});
},
clickLoad() {
this.$refs.refFile.dispatchEvent(new MouseEvent('click'))
},
fileLoad() {
try {
const selectedFile = this.$refs.refFile.files[0];
var reader = new FileReader();
reader.readAsText(selectedFile);
reader.onload = function () {
const obj = JSON.parse(this.result);
vm.textarea1 = JSON.stringify(obj, null, "\t");
vm.$message({
message: '上传成功',
type: 'success'
});
}
} catch (error) {
this.$message({
showClose: true,
message: '上传错误!',
type: 'error'
});
}
},
deleteInfoJson() {
this.textarea1 = json_raw;
localStorage.clear();
},
card_add() {
this.roomFlag = -1;
this.oneRoom = deepCopy(room_raw);
this.roomDialogVisible = true;
},
card_edit(index) {
this.roomFlag = index;
this.oneRoom = deepCopy(this.infoObject.streamerInfo[index]);
this.roomDialogVisible = true;
},
card_copy(index) {
const room = deepCopy(this.infoObject.streamerInfo[index]);
this.infoObject.streamerInfo.push(room);
},
card_del(index) {
this.infoObject.streamerInfo.splice(index, 1);
},
roomEvent() {
this.roomDialogVisible = false;
if (this.roomFlag == -1) {
this.infoObject.streamerInfo.push(this.oneRoom);
this.oneRoom = deepCopy(room_raw);
} else {
const x = deepCopy(this.oneRoom);
this.infoObject.streamerInfo.splice(this.roomFlag, 1, x);
this.oneRoom = deepCopy(room_raw);
}
}
},
computed: {
textarea1: {
set(value) {
this.infoObject = JSON.parse(value);
},
get() {
const x = JSON.stringify(this.infoObject, null, "\t");
localStorage.setItem("infojson", x);
return x
}
}
},
beforeMount() {
if (localStorage.getItem("infojson")) {
this.infoObject = JSON.parse(localStorage.getItem("infojson"));
}
},
});
</script>
</body>
</html>