更新缓存使用8个并发

ct-mobile-first
LMR 5 years ago
parent 80a208e707
commit c3a2b84ed3

@ -1,85 +1,128 @@
<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title>更新静态页-v1.0a</title>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<link href="//int.mycht.cn/bootstrap/css/bootstrap.min.css" rel="stylesheet"/>
<script type="text/javascript" src="//int.mycht.cn/js/jquery.js"></script>
<script type="text/javascript" src="//int.mycht.cn/bootstrap/js/bootstrap.min.js"></script>
<style type="text/css">
.show-grid {padding: 15px; background: #efefef; border-radius: 5px;}
.mr10 {margin-right: 10px;}
.nav {margin-bottom: 5px;}
.pic {display: none;}
.msg {color: #07c;}
.mt12 {margin-top: 12px;}
.msg_wait {color: #999;}
.none {display: none;}
.form-search {display: inline-block;margin:0 0 0 5px !important;}
.input-medium.search-query {width: 250px;}
#search,#insert,#update {margin-top: 2px;float: right;}
</style>
<script type="text/javascript">
$(function() {
//更新静态页,异步请求队列(setp_set个)
var setp_set = 6;
$('#update').on('click', function() {
var $data = $('.data');
for(var i=0; i<setp_set; i++) {
dg_ajax($data, i, setp_set);
<title>更新静态页-v1.0a</title>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<link href="//int.mycht.cn/bootstrap/css/bootstrap.min.css" rel="stylesheet" />
<script type="text/javascript" src="//int.mycht.cn/js/jquery.js"></script>
<script type="text/javascript" src="//int.mycht.cn/bootstrap/js/bootstrap.min.js"></script>
<style type="text/css">
.show-grid {
padding: 15px;
background: #efefef;
border-radius: 5px;
}
});
//下拉选站点
$('a.sss').on('click', function() {
var site = $(this).html();
location.href = '/info.php/login/change_site/'+site+'/?url=/cache/update/';
});
//递归ajax
function dg_ajax(dom, star, step) {
var current = dom.eq(star);
if (current.length) {
var file = current.find('.file').attr('title');
//file = encodeURI(file);
current.find('.msg_wait').css('color','red').html('更新中');
$.ajax({
url : '<?php echo($cache_api);?>',
dataType : 'json',
type : 'POST',
data : {'<?php echo($post_para);?>':file},
success : function(data) {
star = star + step;
current.find('.msg_wait').css('color','blue').html('成功');
count_num(num_zero);
//console.log(star+''+file);
dg_ajax(dom, star, step);
},
error : function() {
current.find('.msg_wait').css('color','red').html('重试');
dg_ajax(dom, star, step);
.mr10 {
margin-right: 10px;
}
.nav {
margin-bottom: 5px;
}
.pic {
display: none;
}
.msg {
color: #07c;
}
.mt12 {
margin-top: 12px;
}
.msg_wait {
color: #999;
}
.none {
display: none;
}
.form-search {
display: inline-block;
margin: 0 0 0 5px !important;
}
.input-medium.search-query {
width: 250px;
}
#search,
#insert,
#update {
margin-top: 2px;
float: right;
}
</style>
<script type="text/javascript">
$(function() {
//更新静态页,异步请求队列(setp_set个)
var setp_set = 8;
$('#update').on('click', function() {
var $data = $('.data');
for (var i = 0; i < setp_set; i++) {
dg_ajax($data, i, setp_set);
}
});
}
}
//计数显示
var num_zero = 1;
function count_num(num) {
$('#count_num').html('已更新'+num+'个页面 进度'+(Math.ceil(num*100/<?php echo(count($file));?>))+'% ').show();
num_zero++;
}
});
</script>
//下拉选站点
$('a.sss').on('click', function() {
var site = $(this).html();
location.href = '/info.php/login/change_site/' + site + '/?url=/cache/update/';
});
//递归ajax
function dg_ajax(dom, star, step) {
var current = dom.eq(star);
if (current.length) {
var file = current.find('.file').attr('title');
//file = encodeURI(file);
current.find('.msg_wait').css('color', 'red').html('更新中');
$.ajax({
url: '<?php echo ($cache_api); ?>',
dataType: 'json',
type: 'POST',
data: {
'<?php echo ($post_para); ?>': file
},
success: function(data) {
star = star + step;
current.find('.msg_wait').css('color', 'blue').html('成功');
count_num(num_zero);
//console.log(star+''+file);
dg_ajax(dom, star, step);
},
error: function() {
current.find('.msg_wait').css('color', 'red').html('重试');
dg_ajax(dom, star, step);
}
});
}
}
//计数显示
var num_zero = 1;
function count_num(num) {
$('#count_num').html('已更新' + num + '个页面 进度' + (Math.ceil(num * 100 / <?php echo (count($file)); ?>)) + '% ').show();
num_zero++;
}
});
</script>
</head>
<body>
<div class="container">
<div class="row show-grid">
<ul class="nav nav-pills">
<li class="active dropdown mr10">
<a class="dropdown-toggle" data-toggle="dropdown" href="#">
站点:<?php echo($this->config->item('site_code'));?>
站点:<?php echo ($this->config->item('site_code')); ?>
<b class="caret"></b>
</a>
<ul class="dropdown-menu">
@ -103,11 +146,13 @@ $(function() {
</li>
</ul>
</li>
<span class="mt12 label label-success">缓存目录<?php echo(count($path));?></span>
<span class="mt12 label label-info">含文件<?php echo(count($file));?></span>
<span class="mt12 label label-success">缓存目录<?php echo (count($path)); ?></span>
<span class="mt12 label label-info">含文件<?php echo (count($file)); ?></span>
<span class="mt12 label label-important none" id="count_num">已更新0个页面 进度0%</span>
<form class="form-search" id="path_search" action="#" method="post">
<input type="text" placeholder="输入路径删选,例如:/tours/。" value="<?php if(isset($_POST['p'])) {echo($_POST['p']);}?>" class="input-medium search-query" name="p"/>
<input type="text" placeholder="输入路径删选,例如:/tours/。" value="<?php if (isset($_POST['p'])) {
echo ($_POST['p']);
} ?>" class="input-medium search-query" name="p" />
<button type="submit" class="btn">筛选</button>
</form>
<a id="update" class="btn mr10 btn-info">更新</a>
@ -117,31 +162,32 @@ $(function() {
<table class="table table-hover">
<thead>
<tr>
<th>#SN</th>
<th>文件名</th>
<th>更新日期</th>
<th>更新状态</th>
<th>#SN</th>
<th>文件名</th>
<th>更新日期</th>
<th>更新状态</th>
</tr>
</thead>
<tbody class="data_group">
<?php foreach($file as $key=>$it) {
$encode = mb_detect_encoding($it, array('ASCII','GBK','ISO-8859-1','UTF-8'));
<?php foreach ($file as $key => $it) {
$encode = mb_detect_encoding($it, array('ASCII', 'GBK', 'ISO-8859-1', 'UTF-8'));
$_it = mb_convert_encoding($it, 'UTF8', $encode);
?>
<tr class="data">
<td><?php echo($key+1);?></td>
<?php if (strlen($_it)>100) { ?>
<td class="file" title="<?php echo($_it);?>"><?php echo(substr($_it, 0, 40));?>..........<?php echo(substr($_it, -35));?></td>
<?php } else { ?>
<td class="file" title="<?php echo($_it);?>"><?php echo($_it);?></td>
<?php } ?>
<td><?php echo($file_time[$it]); ?></td>
<td class="msg_wait">无操作</td>
</tr>
<tr class="data">
<td><?php echo ($key + 1); ?></td>
<?php if (strlen($_it) > 100) { ?>
<td class="file" title="<?php echo ($_it); ?>"><?php echo (substr($_it, 0, 40)); ?>..........<?php echo (substr($_it, -35)); ?></td>
<?php } else { ?>
<td class="file" title="<?php echo ($_it); ?>"><?php echo ($_it); ?></td>
<?php } ?>
<td><?php echo ($file_time[$it]); ?></td>
<td class="msg_wait">无操作</td>
</tr>
<?php } ?>
</tbody>
</table>
</div>
</div>
</body>
</html>
Loading…
Cancel
Save