From 10338abb653a0cbab4b863bb73bbfa29b170efb5 Mon Sep 17 00:00:00 2001 From: filesite Date: Mon, 8 Jul 2024 08:16:04 +0800 Subject: [PATCH] bug fix for cache data not rootDir --- lib/DirScanner.php | 5 +++++ plugins/Common.php | 2 +- themes/beauty/controller/ListController.php | 1 + themes/beauty/controller/SiteController.php | 1 + themes/beauty/views/site/index.php | 6 ++++-- themes/tajian/controller/ListController.php | 1 + themes/tajian/controller/SiteController.php | 2 ++ www/img/beauty/refresh.svg | 4 ++++ www/js/beauty.js | 2 +- 9 files changed, 20 insertions(+), 4 deletions(-) create mode 100644 www/img/beauty/refresh.svg diff --git a/lib/DirScanner.php b/lib/DirScanner.php index 3531a0e..7cdd69b 100644 --- a/lib/DirScanner.php +++ b/lib/DirScanner.php @@ -535,6 +535,11 @@ Class DirScanner { return $this->webRoot; } + //设置扫描绝对根目录 + public function setRootDir($dir) { + $this->rootDir = realpath($dir); + } + //获取是否开启防盗链 public function isSecureOn() { return $this->nginxSecureOn; diff --git a/plugins/Common.php b/plugins/Common.php index 6767b83..957b950 100644 --- a/plugins/Common.php +++ b/plugins/Common.php @@ -535,7 +535,7 @@ Class Common { "ctime" => time(), "data" => $data, ); - $jsonData = json_encode($cacheData); + $jsonData = json_encode($cacheData, JSON_UNESCAPED_SLASHES | JSON_UNESCAPED_UNICODE); $cacheDir = __DIR__ . '/../runtime/cache/'; if (!is_dir($cacheDir)) { diff --git a/themes/beauty/controller/ListController.php b/themes/beauty/controller/ListController.php index 6668a98..1021b79 100644 --- a/themes/beauty/controller/ListController.php +++ b/themes/beauty/controller/ListController.php @@ -17,6 +17,7 @@ Class ListController extends Controller { $scanner = new DirScanner(); $scanner->setWebRoot(FSC::$app['config']['content_directory']); + $scanner->setRootDir(__DIR__ . '/../../../www/' . FSC::$app['config']['content_directory']); //优先从缓存读取数据 $prefix = FSC::$app['config']['theme']; diff --git a/themes/beauty/controller/SiteController.php b/themes/beauty/controller/SiteController.php index f0482ed..05d9e25 100644 --- a/themes/beauty/controller/SiteController.php +++ b/themes/beauty/controller/SiteController.php @@ -17,6 +17,7 @@ Class SiteController extends Controller { $scanner = new DirScanner(); $scanner->setWebRoot(FSC::$app['config']['content_directory']); + $scanner->setRootDir(__DIR__ . '/../../../www/' . FSC::$app['config']['content_directory']); //优先从缓存读取数据 $prefix = FSC::$app['config']['theme']; diff --git a/themes/beauty/views/site/index.php b/themes/beauty/views/site/index.php index a8502f9..8a0de13 100644 --- a/themes/beauty/views/site/index.php +++ b/themes/beauty/views/site/index.php @@ -4,8 +4,9 @@