diff --git a/lib/DirScanner.php b/lib/DirScanner.php index b9a903f..14de123 100644 --- a/lib/DirScanner.php +++ b/lib/DirScanner.php @@ -163,14 +163,31 @@ Class DirScanner { 'directory' => basename($realpath), 'realpath' => $realpath, 'path' => $this->getDirPath($id), - 'files' => $files, ]; + $sub_dirs = []; + $sub_files = []; + //try to merge description data if (!empty($files[$id])) { $data = array_merge($data, $files[$id]); unset($files[$id]); - $data['files'] = $files; + } + + //区分目录和文件 + foreach ($files as $id => $item) { + if (!empty($item['directory'])) { + $sub_dirs[$id] = $item; + }else { + $sub_files[$id] = $item; + } + } + + if (!empty($sub_dirs)) { + $data['directories'] = $sub_dirs; + } + if (!empty($sub_files)) { + $data['files'] = $sub_files; } return $data; diff --git a/themes/googleimage/controller/SiteController.php b/themes/googleimage/controller/SiteController.php index 5d5f58f..f35af74 100644 --- a/themes/googleimage/controller/SiteController.php +++ b/themes/googleimage/controller/SiteController.php @@ -8,6 +8,8 @@ require_once __DIR__ . '/../../../plugins/Parsedown.php'; Class SiteController extends Controller { public function actionIndex() { + $cateId = $this->get('id', ''); + //获取数据 $scanner = new DirScanner(); $scanner->setWebRoot(FSC::$app['config']['content_directory']); @@ -31,7 +33,7 @@ Class SiteController extends Controller { $pageTitle = !empty($titles) ? $titles[0]['name'] : "FileSite.io - 无数据库、基于文件和目录的Markdown文档、网址导航、图书、图片、视频网站PHP开源系统"; $viewName = 'index'; - $params = compact('dirTree', 'scanResults', 'menus', 'html'); + $params = compact('cateId', 'dirTree', 'scanResults', 'menus', 'html'); return $this->render($viewName, $params, $pageTitle); } diff --git a/themes/googleimage/views/site/index.php b/themes/googleimage/views/site/index.php index e685336..aab5b88 100644 --- a/themes/googleimage/views/site/index.php +++ b/themes/googleimage/views/site/index.php @@ -1,11 +1,11 @@