mirror of
https://github.com/netcccyun/dnsmgr.git
synced 2026-07-13 19:16:55 +08:00
优化持久化分页大小功能
This commit is contained in:
@@ -96,11 +96,6 @@ abstract class BaseController
|
||||
return $v->failException(true)->check($data);
|
||||
}
|
||||
|
||||
protected function validateLimit(int $limit, int $default = 15): int
|
||||
{
|
||||
$validSizes = [10, 15, 20, 30, 50, 100, 200, 300, 500];
|
||||
return in_array($limit, $validSizes) ? $limit : $default;
|
||||
}
|
||||
|
||||
protected function alert($code, $msg = '', $url = null, $wait = 3)
|
||||
{
|
||||
|
||||
@@ -33,7 +33,6 @@ class Cert extends BaseController
|
||||
$kw = $this->request->post('kw', null, 'trim');
|
||||
$offset = input('post.offset/d');
|
||||
$limit = input('post.limit/d');
|
||||
$limit = $this->validateLimit($limit);
|
||||
|
||||
$select = Db::name('cert_account')->where('deploy', $deploy);
|
||||
if (!empty($kw)) {
|
||||
@@ -217,7 +216,6 @@ class Cert extends BaseController
|
||||
$status = input('post.status', null, 'trim');
|
||||
$offset = input('post.offset/d');
|
||||
$limit = input('post.limit/d');
|
||||
$limit = $this->validateLimit($limit);
|
||||
|
||||
$select = Db::name('cert_order')->alias('A')->leftJoin('cert_account B', 'A.aid = B.id');
|
||||
if (!empty($id)) {
|
||||
@@ -652,7 +650,6 @@ class Cert extends BaseController
|
||||
$remark = input('post.remark', null, 'trim');
|
||||
$offset = input('post.offset/d');
|
||||
$limit = input('post.limit/d');
|
||||
$limit = $this->validateLimit($limit);
|
||||
|
||||
$select = Db::name('cert_deploy')->alias('A')->leftJoin('cert_account B', 'A.aid = B.id')->leftJoin('cert_order C', 'A.oid = C.id')->leftJoin('cert_account D', 'C.aid = D.id');
|
||||
if (!empty($oid)) {
|
||||
@@ -865,7 +862,6 @@ class Cert extends BaseController
|
||||
$kw = $this->request->post('kw', null, 'trim');
|
||||
$offset = input('post.offset/d');
|
||||
$limit = input('post.limit/d');
|
||||
$limit = $this->validateLimit($limit);
|
||||
|
||||
$select = Db::name('cert_cname')->alias('A')->leftJoin('domain B', 'A.did = B.id');
|
||||
if (!empty($kw)) {
|
||||
|
||||
@@ -43,7 +43,6 @@ class Dmonitor extends BaseController
|
||||
$kw = input('post.kw', null, 'trim');
|
||||
$offset = input('post.offset/d');
|
||||
$limit = input('post.limit/d');
|
||||
$limit = $this->validateLimit($limit);
|
||||
|
||||
$select = Db::name('dmtask')->alias('A')->join('domain B', 'A.did = B.id');
|
||||
if (!empty($kw)) {
|
||||
@@ -234,7 +233,6 @@ class Dmonitor extends BaseController
|
||||
$taskid = input('param.id/d');
|
||||
$offset = input('post.offset/d');
|
||||
$limit = input('post.limit/d');
|
||||
$limit = $this->validateLimit($limit);
|
||||
$action = input('post.action/d', 0);
|
||||
|
||||
$select = Db::name('dmlog')->where('taskid', $taskid);
|
||||
|
||||
@@ -26,7 +26,6 @@ class Domain extends BaseController
|
||||
$kw = $this->request->post('kw', null, 'trim');
|
||||
$offset = input('post.offset/d');
|
||||
$limit = input('post.limit/d');
|
||||
$limit = $this->validateLimit($limit);
|
||||
|
||||
$select = Db::name('account');
|
||||
if (!empty($kw)) {
|
||||
@@ -196,7 +195,6 @@ class Domain extends BaseController
|
||||
$order = input('post.order', null, 'trim');
|
||||
$offset = input('post.offset/d', 0);
|
||||
$limit = input('post.limit/d', 10);
|
||||
$limit = $this->validateLimit($limit);
|
||||
$id = input('post.id');
|
||||
$aid = input('post.aid', null, 'trim');
|
||||
|
||||
@@ -383,7 +381,6 @@ class Domain extends BaseController
|
||||
$kw = input('post.kw', null, 'trim');
|
||||
$page = input('?post.page') ? input('post.page/d') : 1;
|
||||
$pagesize = input('?post.pagesize') ? input('post.pagesize/d') : 10;
|
||||
$pagesize = $this->validateLimit($pagesize);
|
||||
$dns = DnsHelper::getModel($aid);
|
||||
$result = $dns->getDomainList($kw, $page, $pagesize);
|
||||
if (!$result) return json(['code' => -1, 'msg' => '获取域名列表失败,' . $dns->getError()]);
|
||||
@@ -489,7 +486,6 @@ class Domain extends BaseController
|
||||
$status = input('post.status', null, 'trim');
|
||||
$offset = input('post.offset/d', 0);
|
||||
$limit = input('post.limit/d', 10);
|
||||
$limit = $this->validateLimit($limit);
|
||||
if ($limit == 0) {
|
||||
$page = 1;
|
||||
} else {
|
||||
@@ -1020,7 +1016,6 @@ class Domain extends BaseController
|
||||
if (request()->isPost()) {
|
||||
$offset = input('post.offset/d');
|
||||
$limit = input('post.limit/d');
|
||||
$limit = $this->validateLimit($limit);
|
||||
$page = $offset / $limit + 1;
|
||||
$dns = DnsHelper::getModel($drow['aid'], $drow['name'], $drow['thirdid']);
|
||||
$domainRecords = $dns->getDomainRecordLog($page, $limit);
|
||||
@@ -1215,7 +1210,6 @@ class Domain extends BaseController
|
||||
$keyword = input('post.keyword', null, 'trim');
|
||||
$offset = input('post.offset/d');
|
||||
$limit = input('post.limit/d');
|
||||
$limit = $this->validateLimit($limit);
|
||||
if ($limit == 0) {
|
||||
$page = 1;
|
||||
} else {
|
||||
@@ -1398,7 +1392,6 @@ class Domain extends BaseController
|
||||
if (!checkPermission(2)) return json(['total' => 0, 'rows' => []]);
|
||||
$offset = input('post.offset/d', 0);
|
||||
$limit = input('post.limit/d', 10);
|
||||
$limit = $this->validateLimit($limit);
|
||||
|
||||
$select = Db::name('domain_category');
|
||||
$total = $select->count();
|
||||
|
||||
@@ -45,7 +45,6 @@ class Optimizeip extends BaseController
|
||||
$status = input('post.status', null);
|
||||
$offset = input('post.offset/d');
|
||||
$limit = input('post.limit/d');
|
||||
$limit = $this->validateLimit($limit);
|
||||
|
||||
$select = Db::name('optimizeip')->alias('A')->join('domain B', 'A.did = B.id');
|
||||
if (!empty($kw)) {
|
||||
|
||||
@@ -24,7 +24,6 @@ class Schedule extends BaseController
|
||||
$stype = input('post.stype', null);
|
||||
$offset = input('post.offset/d');
|
||||
$limit = input('post.limit/d');
|
||||
$limit = $this->validateLimit($limit);
|
||||
|
||||
$select = Db::name('sctask')->alias('A')->join('domain B', 'A.did = B.id');
|
||||
if (!empty($kw)) {
|
||||
|
||||
@@ -28,7 +28,6 @@ class User extends BaseController
|
||||
$kw = input('post.kw', null, 'trim');
|
||||
$offset = input('post.offset/d');
|
||||
$limit = input('post.limit/d');
|
||||
$limit = $this->validateLimit($limit);
|
||||
|
||||
$select = Db::name('user');
|
||||
if (!empty($kw)) {
|
||||
@@ -166,7 +165,6 @@ class User extends BaseController
|
||||
$domain = input('post.domain', null, 'trim');
|
||||
$offset = input('post.offset/d');
|
||||
$limit = input('post.limit/d');
|
||||
$limit = $this->validateLimit($limit);
|
||||
|
||||
$select = Db::name('log');
|
||||
if ($this->request->user['type'] == 'domain') {
|
||||
|
||||
@@ -61,7 +61,7 @@ $(document).ready(function(){
|
||||
updateToolbar();
|
||||
const pageSizeKey = 'certorder_pagesize';
|
||||
const pageNumber = typeof window.$_GET['pageNumber'] != 'undefined' ? parseInt(window.$_GET['pageNumber']) : 1;
|
||||
const pageSize = getStoredPageSize(pageSizeKey);
|
||||
const pageSize = getStoredPageSize(pageSizeKey, 10);
|
||||
|
||||
$("#listTable").bootstrapTable({
|
||||
url: '/cert/order/data',
|
||||
|
||||
@@ -60,7 +60,7 @@ $(document).ready(function(){
|
||||
updateToolbar();
|
||||
const pageSizeKey = 'deploytask_pagesize';
|
||||
const pageNumber = typeof window.$_GET['pageNumber'] != 'undefined' ? parseInt(window.$_GET['pageNumber']) : 1;
|
||||
const pageSize = getStoredPageSize(pageSizeKey);
|
||||
const pageSize = getStoredPageSize(pageSizeKey, 10);
|
||||
|
||||
$("#listTable").bootstrapTable({
|
||||
url: '/cert/deploy/data',
|
||||
|
||||
@@ -254,32 +254,6 @@
|
||||
}
|
||||
}, false);
|
||||
|
||||
</script>
|
||||
<script>
|
||||
var VALID_PAGE_SIZES = [10, 15, 20, 30, 50, 100, 200, 300, 500];
|
||||
var DEFAULT_PAGE_SIZE = 15;
|
||||
|
||||
function getStoredPageSize(key) {
|
||||
var urlSize = typeof window.$_GET['pageSize'] != 'undefined' ? parseInt(window.$_GET['pageSize']) : null;
|
||||
if (urlSize && VALID_PAGE_SIZES.indexOf(urlSize) !== -1) {
|
||||
return urlSize;
|
||||
}
|
||||
var stored = localStorage.getItem(key);
|
||||
if (stored) {
|
||||
var storedSize = parseInt(stored);
|
||||
if (VALID_PAGE_SIZES.indexOf(storedSize) !== -1) {
|
||||
return storedSize;
|
||||
}
|
||||
}
|
||||
return DEFAULT_PAGE_SIZE;
|
||||
}
|
||||
|
||||
function setStoredPageSize(key, size) {
|
||||
var intSize = parseInt(size);
|
||||
if (VALID_PAGE_SIZES.indexOf(intSize) !== -1) {
|
||||
localStorage.setItem(key, intSize);
|
||||
}
|
||||
}
|
||||
</script>
|
||||
{block name="script"}{/block}
|
||||
</body>
|
||||
|
||||
@@ -229,7 +229,6 @@ td{overflow: hidden;text-overflow: ellipsis;white-space: nowrap;max-width:360px;
|
||||
<script src="/static/js/vue-2.7.16.min.js"></script>
|
||||
<script src="/static/js/layer/layer.js"></script>
|
||||
<script src="/static/js/bootstrapValidator.min.js"></script>
|
||||
<script src="/static/js/custom.js?v=1006"></script>
|
||||
<script>
|
||||
var recordLine = {$recordLine|json_encode|raw};
|
||||
var dnsconfig = {$dnsconfig|json_encode|raw};
|
||||
@@ -257,7 +256,7 @@ new Vue({
|
||||
keyword: '',
|
||||
total: 0,
|
||||
offset: 0,
|
||||
limit: getStoredPageSize('qingcloud_pagesize'),
|
||||
limit: 10,
|
||||
parents: [],
|
||||
expandedMap: {}, // {pid: true/false}
|
||||
loadingMap: {}, // {pid: true/false}
|
||||
|
||||
@@ -56,6 +56,9 @@ function updateQueryStr(obj){
|
||||
history.replaceState({}, null, '?'+arr.join("&"));
|
||||
}
|
||||
|
||||
var VALID_PAGE_SIZES = [10, 15, 20, 30, 50, 100, 200, 300, 500];
|
||||
var DEFAULT_PAGE_SIZE = 15;
|
||||
|
||||
if (typeof $.fn.bootstrapTable !== "undefined") {
|
||||
$.fn.bootstrapTable.custom = {
|
||||
method: 'post',
|
||||
@@ -65,7 +68,7 @@ if (typeof $.fn.bootstrapTable !== "undefined") {
|
||||
sidePagination: 'server',
|
||||
pageNumber: 1,
|
||||
pageSize: 15,
|
||||
pageList: VALID_PAGE_SIZES,
|
||||
pageList: [10, 15, 20, 30, 50, 100, 200, 300, 500],
|
||||
loadingFontSize: '18px',
|
||||
toolbar: '#searchToolbar',
|
||||
showColumns: true,
|
||||
@@ -173,7 +176,8 @@ function delCookie(name)
|
||||
}
|
||||
}
|
||||
|
||||
function getStoredPageSize(key) {
|
||||
function getStoredPageSize(key, defaultSize) {
|
||||
defaultSize = defaultSize || DEFAULT_PAGE_SIZE;
|
||||
var urlSize = typeof window.$_GET['pageSize'] != 'undefined' ? parseInt(window.$_GET['pageSize']) : null;
|
||||
if (urlSize && VALID_PAGE_SIZES.indexOf(urlSize) !== -1) {
|
||||
return urlSize;
|
||||
@@ -185,7 +189,7 @@ function getStoredPageSize(key) {
|
||||
return storedSize;
|
||||
}
|
||||
}
|
||||
return DEFAULT_PAGE_SIZE;
|
||||
return defaultSize;
|
||||
}
|
||||
|
||||
function setStoredPageSize(key, size) {
|
||||
|
||||
Reference in New Issue
Block a user