From 8d6d918ace6122e91b4868b20dd957a488157058 Mon Sep 17 00:00:00 2001 From: filesite Date: Sun, 8 Dec 2024 15:39:32 +0800 Subject: [PATCH] link of year and month update --- themes/beauty/controller/CommandController.php | 4 +++- themes/beauty/controller/ListController.php | 11 ++++++++++- themes/beauty/views/list/bydate.php | 14 +++++++++++--- 3 files changed, 24 insertions(+), 5 deletions(-) diff --git a/themes/beauty/controller/CommandController.php b/themes/beauty/controller/CommandController.php index fb44fec..eb0c25e 100644 --- a/themes/beauty/controller/CommandController.php +++ b/themes/beauty/controller/CommandController.php @@ -388,7 +388,9 @@ eof; $filesByFirstChar = $this->getFilesByFirstCharcter($cacheData, $dirNum); $cacheDir = 'index'; for ($i=1;$i<=$dirNum;$i++) { - Common::saveCacheToFile("{$cacheKey}_{$i}", $filesByFirstChar[$i-1], $cacheDir); + if (!empty($filesByFirstChar[$i-1])) { + Common::saveCacheToFile("{$cacheKey}_{$i}", $filesByFirstChar[$i-1], $cacheDir); + } } //保存文件总数,以及分批数量,以便前端根据id来索引数据 diff --git a/themes/beauty/controller/ListController.php b/themes/beauty/controller/ListController.php index 2033a33..4e254ca 100644 --- a/themes/beauty/controller/ListController.php +++ b/themes/beauty/controller/ListController.php @@ -495,6 +495,15 @@ Class ListController extends Controller { } } + //只显示有数据的月份 + $monthsByType = []; + foreach($cacheData as $month => $arr) { + if (!empty($arr)) { + array_push($monthsByType, $month); + } + } + sort($monthsByType); + //按月份筛选数据 if (!empty($para_month)) { $newData = []; @@ -612,7 +621,7 @@ Class ListController extends Controller { 'page', 'pageSize', 'showType', 'allFiles', 'cacheData', - 'cacheData_keys', + 'cacheData_keys', 'monthsByType', 'para_year', 'para_month' ); return $this->render($viewName, $params, $pageTitle); diff --git a/themes/beauty/views/list/bydate.php b/themes/beauty/views/list/bydate.php index ca0cff0..6bf9f20 100644 --- a/themes/beauty/views/list/bydate.php +++ b/themes/beauty/views/list/bydate.php @@ -168,7 +168,11 @@ eof; echo '