diff --git a/themes/beauty/controller/SiteController.php b/themes/beauty/controller/SiteController.php index 05d9e25..db693c4 100644 --- a/themes/beauty/controller/SiteController.php +++ b/themes/beauty/controller/SiteController.php @@ -107,4 +107,18 @@ Class SiteController extends Controller { return $this->render($viewName, $params, $pageTitle); } + //清空缓存 + public function actionCleancache() { + $prefix = FSC::$app['config']['theme']; + $cacheKey = "{$prefix}_allFilesTree"; + Common::cleanFileCache($cacheKey); + + $cacheKey = "{$prefix}_allFilesData"; + Common::cleanFileCache($cacheKey); + + $code = 1; + $msg = 'OK'; + return $this->renderJson(compact('code', 'msg')); + } + } diff --git a/www/js/beauty.js b/www/js/beauty.js index cafc968..e3926fb 100644 --- a/www/js/beauty.js +++ b/www/js/beauty.js @@ -109,6 +109,21 @@ if ($('#image_site').get(0)) { saveLanpnumToLocalstorage(lanpnum); }); + //刷新缓存 + $('.cleanCacheJS').click(function () { + $.ajax({ + url: '/site/cleancache', + dataType: 'json', + method: 'POST' + }).done(function(data) { + if (data.code == 1) { + location.reload(); + } + }).fail(function(jqXHR, textStatus, errorThrown) { + alert('请求失败,请稍后重试,错误信息:' + errorThrown); + }); + }); + // 音乐播放 if ($('#music_main').length > 0) { var musicState = 0;