mirror of
https://github.com/201206030/novel-plus.git
synced 2025-04-26 17:20:52 +00:00
bug修复
This commit is contained in:
parent
4d5cd12b92
commit
610389b5d3
@ -53,6 +53,7 @@ public class StarterListener implements ServletContextListener {
|
||||
//这里只做老书更新
|
||||
book.setCrawlLastTime(currentDate);
|
||||
book.setId(needUpdateBook.getId());
|
||||
book.setPicUrl(needUpdateBook.getPicUrl());
|
||||
//查询已存在的章节
|
||||
Map<Integer, BookIndex> existBookIndexMap = bookService.queryExistBookIndexMap(needUpdateBook.getId());
|
||||
//解析章节目录
|
||||
|
@ -6,7 +6,9 @@ import com.java2nb.novel.entity.BookContent;
|
||||
import com.java2nb.novel.entity.BookIndex;
|
||||
import com.java2nb.novel.mapper.*;
|
||||
import com.java2nb.novel.service.BookService;
|
||||
import com.java2nb.novel.utils.Constants;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import org.mybatis.dynamic.sql.Constant;
|
||||
import org.mybatis.dynamic.sql.render.RenderingStrategies;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
@ -20,6 +22,7 @@ import java.util.stream.Collectors;
|
||||
|
||||
import static com.java2nb.novel.mapper.BookDynamicSqlSupport.crawlBookId;
|
||||
import static com.java2nb.novel.mapper.BookDynamicSqlSupport.crawlSourceId;
|
||||
import static com.java2nb.novel.mapper.BookDynamicSqlSupport.picUrl;
|
||||
import static com.java2nb.novel.mapper.CrawlSourceDynamicSqlSupport.id;
|
||||
import static org.mybatis.dynamic.sql.SqlBuilder.*;
|
||||
import static org.mybatis.dynamic.sql.select.SelectDSL.select;
|
||||
@ -165,6 +168,10 @@ public class BookServiceImpl implements BookService {
|
||||
book.setUpdateTime(currentDate);
|
||||
book.setBookName(null);
|
||||
book.setAuthorName(null);
|
||||
if(book.getPicUrl()!=null && book.getPicUrl().startsWith(Constants.LOCAL_PIC_PREFIX)) {
|
||||
//本地图片则不更新
|
||||
book.setPicUrl(null);
|
||||
}
|
||||
bookMapper.updateByPrimaryKeySelective(book);
|
||||
|
||||
}
|
||||
|
@ -0,0 +1,12 @@
|
||||
package com.java2nb.novel.utils;
|
||||
|
||||
/**
|
||||
* @author Administrator
|
||||
*/
|
||||
public class Constants {
|
||||
|
||||
/**
|
||||
* 本地图片保存前缀
|
||||
* */
|
||||
public static final String LOCAL_PIC_PREFIX = "/localPic/";
|
||||
}
|
@ -5,7 +5,7 @@
|
||||
|
||||
<select id="queryNeedUpdateBook" resultType="com.java2nb.novel.entity.Book">
|
||||
|
||||
select id,crawl_source_id,crawl_book_id,crawl_last_time
|
||||
select id,crawl_source_id,crawl_book_id,crawl_last_time,pic_url
|
||||
from book where last_index_update_time > #{startDate}
|
||||
order by crawl_last_time
|
||||
limit ${limit}
|
||||
|
@ -29,202 +29,6 @@
|
||||
<script th:fragment="js" src="/mobile/js/jquery-1.9.1.js"></script>
|
||||
<script th:fragment="js" src="/mobile/layui/layui.all.js"></script>
|
||||
</div>
|
||||
<script>
|
||||
var isShowKey = "isShowKey";
|
||||
// 弹幕定时器
|
||||
var timers = [];
|
||||
|
||||
|
||||
function showOrHiddenBullet() {
|
||||
var isShow = eval(localStorage.getItem(isShowKey));//eval方法动态将参数运算成一个字符串,然后自动判断了字符串的类型,true被认为是boolean类型的变量.javascript的弱类型机制.通过eval运算可以动态获取运算后参数的类型.
|
||||
if (isShow) {
|
||||
$(".bullet").css("display", "none");
|
||||
$(".screen_toolbar").css("display", "none");
|
||||
$("[lay-skin='_switch']").removeClass("layui-form-onswitch");
|
||||
localStorage.setItem(isShowKey, false);
|
||||
$(".bullet").remove();
|
||||
setTimeout(function () {
|
||||
$(".bullet").remove();
|
||||
},1000)
|
||||
} else {
|
||||
$(".bullet").css("display", "block");
|
||||
$(".screen_toolbar").css("display", "block");
|
||||
$("[lay-skin='_switch']").addClass("layui-form-onswitch");
|
||||
localStorage.setItem(isShowKey, true);
|
||||
loadBullet();
|
||||
}
|
||||
}
|
||||
|
||||
// 新建一个弹幕
|
||||
function createScreenbullet(text) {
|
||||
var jqueryDom = $("<div class='bullet'>" + text + "</div>");
|
||||
var fontColor = "rgb(" + Math.floor(Math.random() * 256) + "," + Math.floor(Math.random() * 256) + "," + Math.floor(Math.random()) + ")";
|
||||
var fontSize = Math.floor((Math.random() + 1) * 18) + "px";
|
||||
var left = $(".screen_container").width() + "px";
|
||||
var windowHeight = $(window).height();
|
||||
var top = windowHeight/2 + Math.floor(Math.random() * (windowHeight/2-100));
|
||||
//top = parseInt(top) > windowHeight - 100 ? (windowHeight - 100) + "px" : top + "px";
|
||||
jqueryDom.css({
|
||||
"position": 'fixed',
|
||||
"color": fontColor,
|
||||
"font-size": fontSize,
|
||||
"left": left,
|
||||
"top": top
|
||||
});
|
||||
$(".screen_container").append(jqueryDom);
|
||||
return jqueryDom;
|
||||
}
|
||||
|
||||
// 为弹幕添加定时任务
|
||||
function addInterval(jqueryDom) {
|
||||
var left = jqueryDom.offset().left - $(".screen_container").offset().left;
|
||||
var timer = setInterval(function () {
|
||||
left--;
|
||||
jqueryDom.css("left", left + "px");
|
||||
if (jqueryDom.offset().left + jqueryDom.width() < $(".screen_container").offset().left) {
|
||||
jqueryDom.remove();
|
||||
clearInterval(timer);
|
||||
}
|
||||
}, 10);
|
||||
timers.push(timer);
|
||||
}
|
||||
|
||||
function loadBullet() {
|
||||
var contentId = $("#contentIdHidden").val();
|
||||
$.ajax({
|
||||
type: "POST",
|
||||
url: "/book/queryBullet",
|
||||
contentType: 'application/x-www-form-urlencoded;charset=utf-8',
|
||||
data: {contentId: contentId},
|
||||
dataType: "json",
|
||||
success: function (data) {
|
||||
var lastCreateTime ;
|
||||
var currentCreateTime;
|
||||
|
||||
var i = 0;
|
||||
var sllepTime = 0;
|
||||
if(data.length>0){
|
||||
var schedule = setInterval(function () {
|
||||
if(!eval(localStorage.getItem(isShowKey))){
|
||||
clearInterval(schedule);
|
||||
}
|
||||
if(data.length>i) {
|
||||
currentCreateTime = new Date(data[i].createTime).getTime();
|
||||
if (lastCreateTime && currentCreateTime - lastCreateTime > 60000 && sllepTime <= 3000) {
|
||||
if (sllepTime == 3000) {
|
||||
lastCreateTime = currentCreateTime;
|
||||
}
|
||||
sllepTime += 3000;
|
||||
} else {
|
||||
sllepTime = 0;
|
||||
var bullet = data[i].screenBullet;
|
||||
// 创建弹幕
|
||||
var jqueryDom = createScreenbullet(bullet);
|
||||
// 添加定时任务
|
||||
addInterval(jqueryDom);
|
||||
i++;
|
||||
lastCreateTime = currentCreateTime;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
}, 1000);
|
||||
}
|
||||
console.log(data);
|
||||
},
|
||||
error: function (e) {
|
||||
console.log(e);
|
||||
layer.alert("加载弹幕失败");
|
||||
return;
|
||||
}
|
||||
});
|
||||
|
||||
}
|
||||
|
||||
$(function () {
|
||||
// 控制弹幕显隐变量
|
||||
//监听键盘事件
|
||||
$("#screenBulletText").keypress(function (even) {
|
||||
if (even.which == 13) {
|
||||
//enter键按下
|
||||
sendBullet();
|
||||
}
|
||||
});
|
||||
// 监听发送按钮
|
||||
$(".send").on("click", function () {
|
||||
sendBullet();
|
||||
});
|
||||
// 监听关闭弹幕按钮
|
||||
$("[lay-skin='_switch']").click(function () {
|
||||
showOrHiddenBullet();
|
||||
});
|
||||
var isShow = eval(localStorage.getItem(isShowKey));
|
||||
if(isShow == undefined){
|
||||
isShow = true;//第一次使用,默认开启屏幕
|
||||
layer.open({
|
||||
content: '是否需要关闭小说弹幕,之后可通过右下角开关打开!'
|
||||
,btn: ['是', '否']
|
||||
,btn1: function(index, layero){
|
||||
showOrHiddenBullet();
|
||||
layer.close(index);
|
||||
}
|
||||
,btn2: function(index, layero){
|
||||
//按钮【按钮二】的回调
|
||||
|
||||
//return false 开启该代码可禁止点击该按钮关闭
|
||||
}
|
||||
|
||||
});
|
||||
}
|
||||
localStorage.setItem(isShowKey, !isShow);
|
||||
// showOrHiddenBullet();
|
||||
|
||||
|
||||
});
|
||||
|
||||
function sleep(n) {
|
||||
|
||||
var start = new Date().getTime();
|
||||
|
||||
while(true) if(new Date().getTime()-start > n) break;
|
||||
|
||||
}
|
||||
//发送弹幕
|
||||
function sendBullet(){
|
||||
var bullet = $("#screenBulletText").val().replace(/</g, "<").replace(/>/g, ">");
|
||||
var contentId = $("#contentIdHidden").val();
|
||||
if (bullet && contentId) {
|
||||
if(bullet.length > 100){
|
||||
layer.alert("发送内容过长");
|
||||
return;
|
||||
}
|
||||
$.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>
|
||||
|
||||
<style type="text/css">
|
||||
.line-limit-length {
|
||||
@ -398,9 +202,9 @@
|
||||
</p>
|
||||
<div class="indexDiv" style="height: 42px;line-height: 42px;text-align:center;background: #f2f2f2">
|
||||
|
||||
<a th:href="'/book/'+${book.id}+'/'+${preBookIndexId}+'.html'">上一章</a>
|
||||
<a th:href="${preBookIndexId!=0?'/book/'+book.id+'/'+preBookIndexId+'.html':'#'}">上一章</a>
|
||||
<a th:href="'/book/indexList-'+${book.id}+'.html'">目录</a>
|
||||
<a th:href="'/book/'+${book.id}+'/'+${nextBookIndexId}+'.html'">下一章</a>
|
||||
<a th:href="${nextBookIndexId!=0?'/book/'+book.id+'/'+nextBookIndexId+'.html':'#'}">下一章</a>
|
||||
</div>
|
||||
<!--<div id="screenInput" class="screen_toolbar" style="display: none">
|
||||
<div style="height: 5px" class="layui-col-xs2 layui-col-sm3 layui-col-md3 layui-col-lg3"></div>
|
||||
@ -431,9 +235,10 @@
|
||||
</div>
|
||||
<div class="indexDiv" style="height: 42px;line-height: 42px;text-align:center;background: #f2f2f2">
|
||||
|
||||
<a th:href="'/book/'+${book.id}+'/'+${preBookIndexId}+'.html'">上一章</a>
|
||||
<a th:href="${preBookIndexId!=0?'/book/'+book.id+'/'+preBookIndexId+'.html':'#'}">上一章</a>
|
||||
<a th:href="'/book/indexList-'+${book.id}+'.html'">目录</a>
|
||||
<a th:href="'/book/'+${book.id}+'/'+${nextBookIndexId}+'.html'">下一章</a>
|
||||
<a th:href="${nextBookIndexId!=0?'/book/'+book.id+'/'+nextBookIndexId+'.html':'#'}">下一章</a>
|
||||
|
||||
</div>
|
||||
|
||||
|
||||
|
@ -10,7 +10,7 @@ Target Server Type : MYSQL
|
||||
Target Server Version : 50624
|
||||
File Encoding : 65001
|
||||
|
||||
Date: 2020-05-02 14:49:24
|
||||
Date: 2020-05-02 20:34:24
|
||||
*/
|
||||
|
||||
SET FOREIGN_KEY_CHECKS=0;
|
||||
@ -34,35 +34,35 @@ CREATE TABLE `book_setting` (
|
||||
-- ----------------------------
|
||||
-- Records of book_setting
|
||||
-- ----------------------------
|
||||
INSERT INTO `book_setting` VALUES ('32', '1256426898110472192', '1', '0', '2020-04-27 15:45:58', null, '2020-04-27 15:46:03', null);
|
||||
INSERT INTO `book_setting` VALUES ('33', '1256428364971827200', '2', '0', '2020-04-27 15:46:21', null, '2020-04-27 15:46:24', null);
|
||||
INSERT INTO `book_setting` VALUES ('34', '1256427853342236672', '3', '0', '2020-04-27 15:47:06', null, '2020-04-27 15:47:09', null);
|
||||
INSERT INTO `book_setting` VALUES ('35', '1256429556376461312', '4', '0', '2020-04-27 15:47:24', null, '2020-04-27 15:47:27', null);
|
||||
INSERT INTO `book_setting` VALUES ('36', '1256434212276199424', '1', '1', null, null, null, null);
|
||||
INSERT INTO `book_setting` VALUES ('37', '1256427129677996032', '2', '1', null, null, null, null);
|
||||
INSERT INTO `book_setting` VALUES ('38', '1256432786909093888', '3', '1', null, null, null, null);
|
||||
INSERT INTO `book_setting` VALUES ('39', '1256428080056950784', '4', '1', null, null, null, null);
|
||||
INSERT INTO `book_setting` VALUES ('40', '1256474111985532928', '5', '1', null, null, null, null);
|
||||
INSERT INTO `book_setting` VALUES ('41', '1256474314285203456', '1', '2', null, null, null, null);
|
||||
INSERT INTO `book_setting` VALUES ('42', '1256474119514308608', '2', '2', null, null, null, null);
|
||||
INSERT INTO `book_setting` VALUES ('43', '1256473865536618496', '3', '2', null, null, null, null);
|
||||
INSERT INTO `book_setting` VALUES ('44', '1256473751132782592', '4', '2', null, null, null, null);
|
||||
INSERT INTO `book_setting` VALUES ('45', '1256473412258185216', '5', '2', null, null, null, null);
|
||||
INSERT INTO `book_setting` VALUES ('46', '1256473170368479232', '6', '2', null, null, null, null);
|
||||
INSERT INTO `book_setting` VALUES ('47', '1256473085719035904', '1', '3', null, null, null, null);
|
||||
INSERT INTO `book_setting` VALUES ('48', '1256472696558927872', '2', '3', null, null, null, null);
|
||||
INSERT INTO `book_setting` VALUES ('49', '1256474345134309376', '3', '3', null, null, null, null);
|
||||
INSERT INTO `book_setting` VALUES ('50', '1256432786909093888', '4', '3', null, null, null, null);
|
||||
INSERT INTO `book_setting` VALUES ('51', '1256427853342236672', '5', '3', null, null, null, null);
|
||||
INSERT INTO `book_setting` VALUES ('52', '1256474119514308608', '6', '3', null, null, null, null);
|
||||
INSERT INTO `book_setting` VALUES ('53', '1256427853342236672', '1', '4', null, null, null, null);
|
||||
INSERT INTO `book_setting` VALUES ('54', '1256473751132782592', '2', '4', null, null, null, null);
|
||||
INSERT INTO `book_setting` VALUES ('55', '1256428364971827200', '3', '4', null, null, null, null);
|
||||
INSERT INTO `book_setting` VALUES ('56', '1256432786909093888', '4', '4', null, null, null, null);
|
||||
INSERT INTO `book_setting` VALUES ('57', '1256427129677996032', '5', '4', null, null, null, null);
|
||||
INSERT INTO `book_setting` VALUES ('58', '1256474314285203456', '6', '4', null, null, null, null);
|
||||
INSERT INTO `book_setting` VALUES ('59', '1256474119514308608', '6', '1', null, null, null, null);
|
||||
INSERT INTO `book_setting` VALUES ('60', '1256434330693984256', '7', '1', null, null, null, null);
|
||||
INSERT INTO `book_setting` VALUES ('61', '1256471970466185216', '8', '1', null, null, null, null);
|
||||
INSERT INTO `book_setting` VALUES ('62', '1256472024757256192', '9', '1', null, null, null, null);
|
||||
INSERT INTO `book_setting` VALUES ('63', '1256472346489733120', '10', '1', null, null, null, null);
|
||||
INSERT INTO `book_setting` VALUES ('32', '1256508909831536640', '1', '0', '2020-04-27 15:45:58', null, '2020-04-27 15:46:03', null);
|
||||
INSERT INTO `book_setting` VALUES ('33', '1256509051074723840', '2', '0', '2020-04-27 15:46:21', null, '2020-04-27 15:46:24', null);
|
||||
INSERT INTO `book_setting` VALUES ('34', '1256509068665634816', '3', '0', '2020-04-27 15:47:06', null, '2020-04-27 15:47:09', null);
|
||||
INSERT INTO `book_setting` VALUES ('35', '1256509141025767424', '4', '0', '2020-04-27 15:47:24', null, '2020-04-27 15:47:27', null);
|
||||
INSERT INTO `book_setting` VALUES ('36', '1256509083035320320', '1', '1', null, null, null, null);
|
||||
INSERT INTO `book_setting` VALUES ('37', '1256509249888927744', '2', '1', null, null, null, null);
|
||||
INSERT INTO `book_setting` VALUES ('38', '1256509443724492800', '3', '1', null, null, null, null);
|
||||
INSERT INTO `book_setting` VALUES ('39', '1256509817709608960', '4', '1', null, null, null, null);
|
||||
INSERT INTO `book_setting` VALUES ('40', '1256509827104849920', '5', '1', null, null, null, null);
|
||||
INSERT INTO `book_setting` VALUES ('41', '1256510337291599872', '1', '2', null, null, null, null);
|
||||
INSERT INTO `book_setting` VALUES ('42', '1256510608612737024', '2', '2', null, null, null, null);
|
||||
INSERT INTO `book_setting` VALUES ('43', '1256510825391144960', '3', '2', null, null, null, null);
|
||||
INSERT INTO `book_setting` VALUES ('44', '1256509671097712640', '4', '2', null, null, null, null);
|
||||
INSERT INTO `book_setting` VALUES ('45', '1256509888920502272', '5', '2', null, null, null, null);
|
||||
INSERT INTO `book_setting` VALUES ('46', '1256512999282130944', '6', '2', null, null, null, null);
|
||||
INSERT INTO `book_setting` VALUES ('47', '1256512853504901120', '1', '3', null, null, null, null);
|
||||
INSERT INTO `book_setting` VALUES ('48', '1256512756742307840', '2', '3', null, null, null, null);
|
||||
INSERT INTO `book_setting` VALUES ('49', '1256512442035290112', '3', '3', null, null, null, null);
|
||||
INSERT INTO `book_setting` VALUES ('50', '1256560985525633024', '4', '3', null, null, null, null);
|
||||
INSERT INTO `book_setting` VALUES ('51', '1256560647057883136', '5', '3', null, null, null, null);
|
||||
INSERT INTO `book_setting` VALUES ('52', '1256554287595470848', '6', '3', null, null, null, null);
|
||||
INSERT INTO `book_setting` VALUES ('53', '1256554246860390400', '1', '4', null, null, null, null);
|
||||
INSERT INTO `book_setting` VALUES ('54', '1256554229982511104', '2', '4', null, null, null, null);
|
||||
INSERT INTO `book_setting` VALUES ('55', '1256553502908301312', '3', '4', null, null, null, null);
|
||||
INSERT INTO `book_setting` VALUES ('56', '1256553373446914048', '4', '4', null, null, null, null);
|
||||
INSERT INTO `book_setting` VALUES ('57', '1256553684441972737', '5', '4', null, null, null, null);
|
||||
INSERT INTO `book_setting` VALUES ('58', '1256553778306301952', '6', '4', null, null, null, null);
|
||||
INSERT INTO `book_setting` VALUES ('59', '1256550223910486016', '6', '1', null, null, null, null);
|
||||
INSERT INTO `book_setting` VALUES ('60', '1256550046172659712', '7', '1', null, null, null, null);
|
||||
INSERT INTO `book_setting` VALUES ('61', '1256550349009797120', '8', '1', null, null, null, null);
|
||||
INSERT INTO `book_setting` VALUES ('62', '1256548828624928768', '9', '1', null, null, null, null);
|
||||
INSERT INTO `book_setting` VALUES ('63', '1256508909831536640', '10', '1', null, null, null, null);
|
||||
|
Loading…
x
Reference in New Issue
Block a user