diff --git a/themes/beauty/controller/SiteController.php b/themes/beauty/controller/SiteController.php index 6fb669b..7345c3e 100644 --- a/themes/beauty/controller/SiteController.php +++ b/themes/beauty/controller/SiteController.php @@ -128,15 +128,22 @@ Class SiteController extends Controller { //TODO: 清空所有缓存 public function actionCleancache() { - $prefix = FSC::$app['config']['theme']; - $cacheKey = "{$prefix}_allFilesTree"; - Common::cleanFileCache($cacheKey); - - $cacheKey = "{$prefix}_allFilesData"; - Common::cleanFileCache($cacheKey); - $code = 1; $msg = 'OK'; + + try { + $cacheDir = __DIR__ . '/../../../runtime/cache/'; + $files = scandir($cacheDir); + foreach($files as $file) { + if (!preg_match('/\.json$/i', $file)) {continue;} + + unlink("{$cacheDir}{$file}"); + } + }catch(Exception $e) { + $code = 0; + $msg = '缓存清空失败:' . $e->getMessage(); + } + return $this->renderJson(compact('code', 'msg')); } diff --git a/themes/beauty/views/site/index.php b/themes/beauty/views/site/index.php index 945ac15..f610376 100644 --- a/themes/beauty/views/site/index.php +++ b/themes/beauty/views/site/index.php @@ -86,7 +86,7 @@ eof; //如果没有选中任何目录,则把所有目录显示出来 - if (empty($category) && !empty($viewData['menus'])) { + if (empty($selectedId) && !empty($viewData['menus'])) { foreach ($viewData['menus'] as $index => $dir) { echo << diff --git a/www/js/beauty.js b/www/js/beauty.js index c09599b..35d5c07 100644 --- a/www/js/beauty.js +++ b/www/js/beauty.js @@ -141,7 +141,7 @@ if ($('#image_site').get(0)) { method: 'POST' }).done(function(data) { if (data.code == 1) { - location.reload(); + location.href = '/'; }else { alert('缓存清空失败,请稍后重试,错误信息:' + data.msg); }