perf(novel-crawl): 优化采集监控页异常提示体验

在爬虫采集监控页面,针对网络或服务异常情况,避免频繁弹窗提示,提升用户体验。
This commit is contained in:
xiongxiaoyang
2025-10-25 19:19:45 +08:00
parent 6b72d4856d
commit 3d1b952e1a
2 changed files with 24 additions and 11 deletions

View File

@@ -118,9 +118,10 @@
<script language="javascript" type="text/javascript">
let curr = 1;
let limit = 10;
let isUpdate = false;
search();
setInterval(function(){
setInterval(function () {
search();
}, 10000);
@@ -185,6 +186,7 @@
if (!first) {
curr = obj.curr;
limit = obj.limit;
isUpdate = false;
search();
} else {
@@ -196,13 +198,21 @@
}
} else {
} else if (data.code == 1001) {
//未登录
location.href = '/user/login.html?originUrl=' + encodeURIComponent(location.href);
} else if (!isUpdate) {
layer.alert(data.msg);
}
isUpdate = true;
},
error: function () {
layer.alert('网络异常');
if (!isUpdate) {
layer.alert('网络异常');
}
isUpdate = true;
}
})

View File

@@ -116,14 +116,13 @@
<script language="javascript" type="text/javascript">
let curr = 1;
let limit = 10;
let isUpdate = false;
search();
setInterval(function(){
setInterval(function () {
search();
}, 10000);
var pageCrawlSourceList = null;
function search() {
$.ajax({
@@ -134,7 +133,6 @@
success: function (data) {
if (data.code == 200) {
var crawlSourceList = data.data.list;
pageCrawlSourceList = data.data.list;
if (crawlSourceList.length > 0) {
var crawlSourceListHtml = "";
for (var i = 0; i < crawlSourceList.length; i++) {
@@ -182,6 +180,7 @@
if (!first) {
curr = obj.curr;
limit = obj.limit;
isUpdate = false;
search();
} else {
@@ -197,13 +196,17 @@
//未登录
location.href = '/user/login.html?originUrl=' + encodeURIComponent(location.href);
} else {
} else if (!isUpdate) {
layer.alert(data.msg);
}
isUpdate = true;
},
error: function () {
layer.alert('网络异常');
if (!isUpdate) {
layer.alert('网络异常');
}
isUpdate = true;
}
})
@@ -229,11 +232,11 @@
if (status == 0) {
//开启
$("#sourceStatus" + sourceId).html("正在运行");
$("#opt" + sourceId).html("<a href='javascript:openOrStopCrawl(" + sourceId + "," + 1 + ")'>关闭 </a>"+"<a href='javascript:updateCrawlSource(" + sourceId + ")'>修改 </a>");
$("#opt" + sourceId).html("<a href='javascript:openOrStopCrawl(" + sourceId + "," + 1 + ")'>关闭 </a>" + "<a href='javascript:updateCrawlSource(" + sourceId + ")'>修改 </a>");
} else {
//关闭
$("#sourceStatus" + sourceId).html("停止运行");
$("#opt" + sourceId).html("<a href='javascript:openOrStopCrawl(" + sourceId + "," + 0 + ")'>开启 </a>"+"<a href='javascript:updateCrawlSource(" + sourceId + ")'>修改 </a>");
$("#opt" + sourceId).html("<a href='javascript:openOrStopCrawl(" + sourceId + "," + 0 + ")'>开启 </a>" + "<a href='javascript:updateCrawlSource(" + sourceId + ")'>修改 </a>");
}