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

View File

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