From ae1a78c697ec1a045fee6b3443407c7e7e6d7318 Mon Sep 17 00:00:00 2001 From: filesite Date: Wed, 10 Jul 2024 16:40:15 +0800 Subject: [PATCH] pagination improved --- plugins/Html.php | 9 +++------ themes/beauty/controller/ListController.php | 4 ++-- themes/beauty/views/site/index.php | 16 ++++++++++------ www/css/beauty.css | 1 + 4 files changed, 16 insertions(+), 14 deletions(-) diff --git a/plugins/Html.php b/plugins/Html.php index a589b83..9daa28a 100644 --- a/plugins/Html.php +++ b/plugins/Html.php @@ -216,10 +216,10 @@ eof; eof; } - //中间显示 10 页 + //包括当前页一共显示 10 页 $otherLinks = ''; - $startPage = $page > 5 ? $page - 5 : 1; - $endPage = $startPage + 10 < $maxPage ? $startPage + 10 : $maxPage; + $startPage = floor(($page-1) / 10)*10 + 1; + $endPage = $startPage + 9 < $maxPage ? $startPage + 9 : $maxPage; for ($i = $startPage; $i <= $endPage; $i ++) { $url = self::getPaginationLink($currentUrl, $i, $limit); if ($i != $page) { @@ -241,9 +241,6 @@ eof; {$previousLink} {$otherLinks} {$nextLink} -
  • - 总数 {$total} -
  • eof; diff --git a/themes/beauty/controller/ListController.php b/themes/beauty/controller/ListController.php index 96c0243..8a9749e 100644 --- a/themes/beauty/controller/ListController.php +++ b/themes/beauty/controller/ListController.php @@ -24,11 +24,11 @@ Class ListController extends Controller { $scanner = new DirScanner(); - //TODO: 根据参数cid获取id对应的目录realpath,从而只扫描这个目录 + //根据参数cid获取id对应的目录realpath,从而只扫描这个目录 $cacheSeconds = 3600; $cachedParentData = Common::getCacheFromFile($cacheParentDataId, $cacheSeconds); if (empty($cachedParentData)) { - throw new Exception("缓存已过期,请返回上一页重新进入!", 404); + return $this->redirect('/'); } $currentDir = $cachedParentData[$cateId]; diff --git a/themes/beauty/views/site/index.php b/themes/beauty/views/site/index.php index 1011432..08ed733 100644 --- a/themes/beauty/views/site/index.php +++ b/themes/beauty/views/site/index.php @@ -54,9 +54,19 @@ eof;
    + 总数 {$total} 当前位置: 首页 / eof; @@ -81,11 +91,6 @@ eof;