完善web一些功能

This commit is contained in:
2024-11-27 17:39:02 +08:00
parent 48a15c8769
commit e8cceef419
12 changed files with 647 additions and 143 deletions

View File

@@ -89,15 +89,16 @@
<script src="/js/httpUtils.js"></script>
<script src="/js/CommonConfig.js"></script>
<script>
function timeTips(isLive,that) {
if(isLive){
function timeTips(isLive, that) {
if (isLive) {
layer.tips('是从开始到结束时间范围内,主播开播会启动录制,超过结束范围不会中断正在录制的任务', that);
}else{
} else {
layer.tips('仅在当前时间范围内录制,如遇到正在直播,则延迟到下播时停止录制', that);
}
}
var roomId = getParam("roomId");
var editArray = getParam("array")
layui.use(['form', 'laytpl', 'laydate'], function () {
var form = layui.form;
@@ -123,15 +124,35 @@
}
field.weeks = weeks;
console.log(field)
addRoomConfig(field)
.then(json => {
layer.msg(json.message, function () {
if (json.status == 100) {
close()
}
})
if (editArray === null) {
var loadIndex=showLoadingDialog();
addRoomConfig(field)
.then(json => {
layer.close(loadIndex)
layer.msg(json.message, function () {
if (json.status == 100) {
close()
}
})
})
} else {
var array = []
editArray.split(',').forEach(element => {
array.push(element)
});
var loadIndex=showLoadingDialog();
setArrayRoomConfig(array, field)
.then(json => {
layer.close(loadIndex)
layer.msg(json.message, function () {
if (json.status == 100) {
close()
}
})
})
}
})
return false; // 阻止默认 form 跳转
});
@@ -155,6 +176,9 @@
$('#btn_reset').get(0).disabled = true;
editRoom()
}
if (editArray !== null) {
editArrayRoom()
}
}
function getUserInfo() {
getBiliAllUser()
@@ -183,12 +207,20 @@
for (let i = 0; i < json.weeks.length; i++) {
result[`week_${json.weeks[i]}`] = true;
}
form.val('form-filter',result);
form.val('form-filter', result);
$('#url').get(0).disabled = true;
}
})
}
function editArrayRoom() {
$('#btn_reset').get(0).disabled = true;
$('#url').get(0).disabled = true;
var result = {
'url': editArray
};
form.val('form-filter', result);
}
init();
});
</script>

View File

@@ -0,0 +1,132 @@
<!DOCTYPE html>
<html lang="zh-CN">
<head>
<meta charset="utf-8">
<link rel="stylesheet" href="/layui/css/layui.css">
</head>
<table class="layui-hide" id="followList" lay-filter="followTable"></table>
<body>
</body>
<script src="/layui/layui.js"></script>
<script src="/js/jquery-3.2.1.js"></script>
<script src="/js/CommonConfig.js"></script>
<script src="/js/httpUtils.js"></script>
<script type="text/html" id="toolbarDemo">
<div class="layui-btn-container">
<button class="layui-btn layui-btn-sm" lay-event="select">配置选择项</button>
</div>
</script>
<script type="text/html" id="toolDemo">
<div class="layui-clear-space">
<a class="layui-btn layui-btn-xs" lay-event="add">添加</a>
</div>
</script>
<script>
var userId = getParam("uid");
layui.use(function () {
var laytpl = layui.laytpl;
var table = layui.table;
table.render({
elem: '#followList',
url: '/live/config/followLive?userId=' + userId,
toolbar: '#toolbarDemo',
height: '350px',
totalRow: false, // 开启合计行
page: false,
response: {
statusCode: 100 // 重新规定成功的状态码为 200table 组件默认为 0
},
parseData: function (res) {
return {
"code": res.status, //解析接口状态
"msg": res.message, //解析提示文本
"data": res.data, //解析数据列表
"count": res.count
};
},
cols: [[
{ type: 'checkbox', fixed: 'left' },
{ field: 'uname', title: '用户名', width: 150, fixed: 'left' },
{ field: 'uid', title: 'UID', width: 150, sort: true, templet: '<div><a href="https://space.bilibili.com/{{= d.uid}}" target="_blank">{{= d.uid}}</a>' },
{ field: 'room_id', title: '房间号', width: 150, sort: true, templet: '<div><a href="https://live.bilibili.com/{{= d.room_id}}" target="_blank">{{= d.room_id}}</a>' },
{ field: 'face', title: '头像', width: 80, templet: '<div><image src="" onerror="showImage(\'{{= d.face }}\',this);" style="width: 30px;height: 30px;"></div>' },
{ field: 'title', title: '标题', width: 150, },
{ fixed: "right", title: "操作", width: 50, align: "center", toolbar: "#toolDemo" }
]],
done: function () {
onDone()
},
error: function (res, msg) {
console.log(res, msg)
}
});
function onDone() {
table.on('toolbar(followTable)', function (obj) {
if (obj.event === 'select') {
var data = table.checkStatus(obj.config.id).data;
console.log(data)
var array = []
data.forEach(item => {
array.push({
"roomId": item.room_id,
"uname": item.uname
})
});
var loadIndex = layer.msg('配置中', {
icon: 16,
shade: 0.6
});
addFollowRoomList(JSON.stringify(array))
.then(json => {
layer.close(loadIndex)
layer.msg("已成功配置" + json.count + "个房间")
})
}
})
table.on('tool(followTable)', function (obj) {
if (obj.event === 'add') {
var loadIndex = layer.msg('配置中', {
icon: 16,
shade: 0.6
});
var array = []
array.push({
"roomId": obj.data.room_id,
"uname": obj.data.uname
})
addFollowRoomList(JSON.stringify(array))
.then(data => {
layer.close(loadIndex)
layer.msg("已成功配置" + data.count + "个房间")
})
}
})
}
function openTips(message, mid) {
layer.alert(message, {
title: "提示",
btn: ['打开配置页', '前往UP主页', '取消'],
btnAlign: 'c', // 按钮居中显示
btn1: function () {
window.open("/html/body/live.html?type=createRoom", '_blank')
},
btn2: function () {
window.open("https://space.bilibili.com/" + mid, '_blank')
},
btn3: function () {
}
});
}
})
</script>