Browse Source

bug fix, no directory show, cache clean improved

master
filesite 5 months ago
parent
commit
eede56903c
  1. 21
      themes/beauty/controller/SiteController.php
  2. 2
      themes/beauty/views/site/index.php
  3. 2
      www/js/beauty.js

21
themes/beauty/controller/SiteController.php

@ -128,15 +128,22 @@ Class SiteController extends Controller {
//TODO: 清空所有缓存 //TODO: 清空所有缓存
public function actionCleancache() { public function actionCleancache() {
$prefix = FSC::$app['config']['theme'];
$cacheKey = "{$prefix}_allFilesTree";
Common::cleanFileCache($cacheKey);
$cacheKey = "{$prefix}_allFilesData";
Common::cleanFileCache($cacheKey);
$code = 1; $code = 1;
$msg = 'OK'; $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')); return $this->renderJson(compact('code', 'msg'));
} }

2
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) { foreach ($viewData['menus'] as $index => $dir) {
echo <<<eof echo <<<eof
<div class="im_item bor_radius col-xs-6 col-sm-4 col-md-3 col-lg-2"> <div class="im_item bor_radius col-xs-6 col-sm-4 col-md-3 col-lg-2">

2
www/js/beauty.js

@ -141,7 +141,7 @@ if ($('#image_site').get(0)) {
method: 'POST' method: 'POST'
}).done(function(data) { }).done(function(data) {
if (data.code == 1) { if (data.code == 1) {
location.reload(); location.href = '/';
}else { }else {
alert('缓存清空失败,请稍后重试,错误信息:' + data.msg); alert('缓存清空失败,请稍后重试,错误信息:' + data.msg);
} }

Loading…
Cancel
Save