优化WEB端,可以使用回车直接发送弹幕;爬虫优化

This commit is contained in:
xiongxiaoyang 2019-11-15 14:44:20 +08:00
parent c30fb7965a
commit 95149646f6
7 changed files with 823 additions and 553 deletions

View File

@ -35,8 +35,8 @@ spring:
type: com.alibaba.druid.pool.DruidDataSource type: com.alibaba.druid.pool.DruidDataSource
driverClassName: com.mysql.jdbc.Driver driverClassName: com.mysql.jdbc.Driver
url: jdbc:mysql://127.0.0.1:3306/books?useUnicode=true&characterEncoding=utf8&serverTimezone=Asia/Shanghai url: jdbc:mysql://127.0.0.1:3306/books?useUnicode=true&characterEncoding=utf8&serverTimezone=Asia/Shanghai
username: root username: books
password: test123456 password: books
#password: #password:
initialSize: 1 initialSize: 1
minIdle: 3 minIdle: 3

View File

@ -0,0 +1,10 @@
#爬虫线程数
threadCount=1
#爬取优先级 1评分优先 2更新时间优先
priority=1
#小说最低评分0表示不限制
lowestScore=0
#小说最小更新时间
minUptTime=2000-01-01 00:00:00
#爬取最大条数,0表示不限制
maxNumber=0

View File

@ -159,14 +159,15 @@ function detail(id) {
}); });
} }
function edit(id) { function edit(){
console.log('打开配置页面');
layer.open({ layer.open({
type: 2, type : 2,
title: '编辑', title : '增加',
maxmin: true, maxmin : true,
shadeClose: false, // 点击遮罩关闭层 shadeClose : false,
area: ['800px', '520px'], area : [ '800px', '520px' ],
content: prefix + '/edit/' + id // iframe的url content : prefix + '/edit'
}); });
} }

View File

@ -9,14 +9,9 @@
<div class="ibox-body"> <div class="ibox-body">
<div class="fixed-table-toolbar"> <div class="fixed-table-toolbar">
<div class="columns pull-left"> <div class="columns pull-left">
<button shiro:hasPermission="books:bookCrawl:add" type="button" <button type="button" class="btn btn-info"
class="btn btn-primary" onclick="add()"> onclick="edit()">
<i class="fa fa-plus" aria-hidden="true"></i>添加 <i class="" aria-hidden="true"></i>爬虫配置
</button>
<button shiro:hasPermission="books:bookCrawl:batchRemove" type="button"
class="btn btn-danger"
onclick="batchRemove()">
<i class="fa fa-trash" aria-hidden="true"></i>删除
</button> </button>
</div> </div>
<div class="columns pull-right"> <div class="columns pull-right">

View File

@ -1,5 +1,5 @@
server: server:
port: 80 port: 8080
spring: spring:
datasource: datasource:

View File

@ -309,35 +309,16 @@
// 弹幕定时器 // 弹幕定时器
var timers = []; var timers = [];
// 控制弹幕显隐变量 // 控制弹幕显隐变量
//监听键盘事件
$("#screenBulletText").keypress(function (even) {
if (even.which == 13) {
//enter键按下
sendBullet();
}
});
// 监听发送按钮 // 监听发送按钮
$(".send").on("click", function () { $(".send").on("click", function () {
var bullet = $("#screenBulletText").val(); sendBullet();
var contentId = $("#contentIdHidden").val();
if (bullet && contentId) {
$.ajax({
type: "POST",
url: "/book/sendBullet",
contentType: 'application/x-www-form-urlencoded;charset=utf-8',
data: {contentId: contentId, bullet: bullet},
dataType: "json",
success: function (data) {
console.log(data);
var bullet = $("#screenBulletText").val("")
},
error: function (e) {
console.log(e);
layer.alert("发送失败");
return;
}
});
} else {
layer.alert("发送内容不能为空");
return;
}
// 创建弹幕
var jqueryDom = createScreenbullet(bullet);
// 添加定时任务
addInterval(jqueryDom);
}); });
// 监听关闭弹幕按钮 // 监听关闭弹幕按钮
$("[lay-skin='_switch']").click(function () { $("[lay-skin='_switch']").click(function () {
@ -488,6 +469,36 @@
while(true) if(new Date().getTime()-start > n) break; while(true) if(new Date().getTime()-start > n) break;
} }
//发送弹幕
function sendBullet(){
var bullet = $("#screenBulletText").val();
var contentId = $("#contentIdHidden").val();
if (bullet && contentId) {
$.ajax({
type: "POST",
url: "/book/sendBullet",
contentType: 'application/x-www-form-urlencoded;charset=utf-8',
data: {contentId: contentId, bullet: bullet},
dataType: "json",
success: function (data) {
console.log(data);
var bullet = $("#screenBulletText").val("")
},
error: function (e) {
console.log(e);
layer.alert("发送失败");
return;
}
});
} else {
layer.alert("发送内容不能为空");
return;
}
// 创建弹幕
var jqueryDom = createScreenbullet(bullet);
// 添加定时任务
addInterval(jqueryDom);
}
</script> </script>
</html> </html>