diff --git a/themes/beauty/controller/CommandController.php b/themes/beauty/controller/CommandController.php index 52e816f..ffccdb9 100644 --- a/themes/beauty/controller/CommandController.php +++ b/themes/beauty/controller/CommandController.php @@ -133,7 +133,6 @@ eof; //缓存所有目录的文件数量 $this->saveDirCounter(); - //TODO: 保存所有目录下文件数量统计 //按年、月保存文件数据,以便按年、月显示 //while (true) { @@ -150,6 +149,8 @@ eof; Common::setCache($this->dateIndexCacheKey, array()); Common::setCache($this->noOriginalCtimeFilesCacheKey, array()); Common::setCache($this->allFilesCacheKey, array()); + Common::setCache($this->dirCounterCacheKey, array()); + Common::setCache($this->allDirTreeCacheKey, array()); } protected function getParentDir($dirpath) { @@ -217,7 +218,15 @@ eof; foreach ($scanResults as $id => $item) { $hadScanedDirs = Common::getCache($cacheKey); - if (!empty($item['filename'])) { + //忽略.txt描述文件 + if ( + !empty($item['filename']) && !empty($item['extension']) + && ( + in_array($item['extension'], $supportedImageExts) + || in_array($item['extension'], $supportedVideoExts) + || in_array($item['extension'], $supportedAudioExts) + ) + ) { //保存所有文件到索引 $this->updateAllFilesCache($item); //更新年份、月份时间索引 @@ -367,6 +376,10 @@ eof; $indexKeys = []; foreach ($cacheData as $year => $item) { $indexKeys[$year] = array_keys($item); + $indexKeys[$year]['total'] = 0; + foreach($item as $month => $ids) { + $indexKeys[$year]['total'] += count($ids); + } } Common::saveCacheToFile("{$cacheKey}_keys", $indexKeys, $cacheDir); diff --git a/themes/beauty/controller/ListController.php b/themes/beauty/controller/ListController.php index f7a75c3..05bb10a 100644 --- a/themes/beauty/controller/ListController.php +++ b/themes/beauty/controller/ListController.php @@ -501,7 +501,7 @@ Class ListController extends Controller { //只显示有数据的月份 $monthsByType = []; foreach($cacheData as $month => $arr) { - if (!empty($arr)) { + if ($month != 'total' && !empty($arr)) { array_push($monthsByType, $month); } } @@ -521,7 +521,9 @@ Class ListController extends Controller { //把所有文件拼接到一个数组里 $allFiles = []; foreach($cacheData as $month => $files) { - $allFiles = array_merge($allFiles, $files); + if (is_array($files)) { + $allFiles = array_merge($allFiles, $files); + } } diff --git a/themes/beauty/views/list/bydate.php b/themes/beauty/views/list/bydate.php index 73816a0..d946292 100644 --- a/themes/beauty/views/list/bydate.php +++ b/themes/beauty/views/list/bydate.php @@ -23,6 +23,7 @@ if (!empty($viewData['para_month'])) { $selectedId = $viewData['para_month']; } +$cacheData = !empty($viewData['cacheData']) ? $viewData['cacheData'] : []; ?>