From 350c8ef1622e7d018148fce9b4385f68a7d301de Mon Sep 17 00:00:00 2001 From: filesite Date: Wed, 10 Jul 2024 09:14:45 +0800 Subject: [PATCH] bug fix: get default readme from current directory --- themes/beauty/controller/ListController.php | 2 +- themes/beauty/controller/SiteController.php | 22 +++++++++------------ 2 files changed, 10 insertions(+), 14 deletions(-) diff --git a/themes/beauty/controller/ListController.php b/themes/beauty/controller/ListController.php index e56ecc5..7fc6474 100644 --- a/themes/beauty/controller/ListController.php +++ b/themes/beauty/controller/ListController.php @@ -96,7 +96,7 @@ Class ListController extends Controller { $breadcrumbs = $this->getBreadcrumbs($currentDir, $cachedParentData, $scanner); //获取当前目录下的readme - $cateReadmeFile = $scanner->getDefaultReadme($cateId); + $cateReadmeFile = $scanner->getDefaultReadme(); if (!empty($cateReadmeFile)) { $Parsedown = new Parsedown(); $content = file_get_contents($cateReadmeFile['realpath']); diff --git a/themes/beauty/controller/SiteController.php b/themes/beauty/controller/SiteController.php index 0954df5..ad73468 100644 --- a/themes/beauty/controller/SiteController.php +++ b/themes/beauty/controller/SiteController.php @@ -67,13 +67,6 @@ Class SiteController extends Controller { if (!empty($readmeFile['sort'])) { $menus_sorted = explode("\n", $readmeFile['sort']); } - - $titles = $scanner->getMDTitles($readmeFile['id']); - - $Parsedown = new Parsedown(); - $content = file_get_contents($readmeFile['realpath']); - $htmlReadme = $Parsedown->text($content); - $htmlReadme = $scanner->fixMDUrls($readmeFile['realpath'], $htmlReadme); } //排序 @@ -86,16 +79,19 @@ Class SiteController extends Controller { Common::saveCacheToFile($cacheKey, $menus); //保存目录数据 } + //获取联系方式 + $titles = array(); + $readmeFile = $scanner->getDefaultReadme(); + if (!empty($readmeFile)) { + $titles = $scanner->getMDTitles($readmeFile['id']); - //获取当前目录下的readme - $cateReadmeFile = $scanner->getDefaultReadme($defaultCateId); - if (!empty($cateReadmeFile)) { $Parsedown = new Parsedown(); - $content = file_get_contents($cateReadmeFile['realpath']); - $htmlCateReadme = $Parsedown->text($content); - $htmlCateReadme = $scanner->fixMDUrls($cateReadmeFile['realpath'], $htmlCateReadme); + $content = file_get_contents($readmeFile['realpath']); + $htmlReadme = $Parsedown->text($content); + $htmlReadme = $scanner->fixMDUrls($readmeFile['realpath'], $htmlReadme); } + //优先从缓存获取默认mp3文件 $cacheKey = $this->getCacheKey('root', 'mp3', $maxScanDeep); $mp3File = Common::getCacheFromFile($cacheKey);