diff --git a/themes/beauty/controller/SiteController.php b/themes/beauty/controller/SiteController.php index 50d0271..7871818 100644 --- a/themes/beauty/controller/SiteController.php +++ b/themes/beauty/controller/SiteController.php @@ -296,7 +296,7 @@ Class SiteController extends Controller { $url = $cachedData['snapshot']; $cacheSubDir = 'dir'; $size = 'vm'; - Common::saveCacheToFile($cacheKey, compact('url', 'img_id', 'size'), $cacheSubDir); + Common::saveCacheToFile($cacheKey, compact('url', 'size'), $cacheSubDir); } } }else { @@ -310,15 +310,19 @@ Class SiteController extends Controller { $expireSeconds = FSC::$app['config']['screenshot_expire_seconds']; //有效期3650天 $cacheSubDir = 'image'; $cachedData = Common::getCacheFromFile($cacheKey_smimg, $expireSeconds, $cacheSubDir); - if (!empty($cachedData)) { + if (!empty($cachedData)) { //已经有缩略图 $url = $cachedData; - $img_id = ''; //无需再次生成小尺寸图片 $size = 'small'; + + //当前目录有缩略图的时候才缓存 + $cacheSubDir = 'dir'; + Common::saveCacheToFile($cacheKey, compact('url', 'size'), $cacheSubDir); } + }else if (empty(FSC::$app['config']['enableSmallImage']) || FSC::$app['config']['enableSmallImage'] === 'false') { + //如果关闭了缩略图功能则缓存原图 + $cacheSubDir = 'dir'; + Common::saveCacheToFile($cacheKey, compact('url', 'size'), $cacheSubDir); } - - $cacheSubDir = 'dir'; - Common::saveCacheToFile($cacheKey, compact('url', 'img_id', 'size'), $cacheSubDir); } }else { $code = 0; @@ -326,11 +330,10 @@ Class SiteController extends Controller { } }else { $url = $cachedData['url']; - $img_id = $cachedData['img_id']; } } - return $this->renderJson(compact('code', 'msg', 'url', 'img_id')); + return $this->renderJson(compact('code', 'msg', 'url')); } //保存目录封面图到缓存 diff --git a/www/js/beauty.js b/www/js/beauty.js index 300d334..9da2e1a 100644 --- a/www/js/beauty.js +++ b/www/js/beauty.js @@ -311,15 +311,6 @@ $('.dir_item').each(function(index, el) { } imgHtml += ' class="bor_radius im_img">'; $(el).find('.im_img_title').before(imgHtml); - - if (data.img_id) { - setTimeout(function() { - var imgs = $(el).find('.im_img'); - if (imgs.length > 0) { - saveSmallImg(imgs[0], id); - } - }, 100); - } }else { //console.warn('目录 %s 里没有任何图片', id); var imgHtml = '';