Browse Source

get cache data of date index

master
filesite 2 days ago
parent
commit
6f0cb24fff
  1. 3
      themes/beauty/controller/CommandController.php
  2. 8
      themes/beauty/controller/ListController.php
  3. 2
      themes/beauty/controller/SiteController.php
  4. 15
      themes/beauty/views/site/index.php
  5. 4
      www/img/beauty/calendar.svg

3
themes/beauty/controller/CommandController.php

@ -156,6 +156,9 @@ eof; @@ -156,6 +156,9 @@ eof;
$scanner->setWebRoot(FSC::$app['config']['content_directory']);
$scanner->setRootDir($dirpath);
//尝试使用exiftool来获取视频的拍摄时间
$scanner->exiftoolSupported = true;
$maxScanDeep = 0; //最大扫描目录级数
$dirTree = $scanner->scan($dirpath, $maxScanDeep);
$scanResults = $scanner->getScanResults();

8
themes/beauty/controller/ListController.php

@ -8,6 +8,8 @@ require_once __DIR__ . '/../../../plugins/Common.php'; @@ -8,6 +8,8 @@ require_once __DIR__ . '/../../../plugins/Common.php';
require_once __DIR__ . '/../../../plugins/Html.php';
Class ListController extends Controller {
protected $dateIndexCacheKey = 'MainBotDateIndex';
protected $noOriginalCtimeFilesCacheKey = 'MainBotNoOriginalCtimeFiles';
public function actionIndex() {
$cateId = $this->get('id', '');
@ -300,10 +302,14 @@ Class ListController extends Controller { @@ -300,10 +302,14 @@ Class ListController extends Controller {
$isAdminIp = Common::isAdminIp($this->getUserIp()); //判断是否拥有管理权限
//从缓存文件获取按年份、月份归类的索引数据
$cacheDataByDate = Common::getCacheFromFile($this->dateIndexCacheKey, 86400*365);
$viewName = '//site/index'; //共享视图
$params = compact(
'cateId', 'dirTree', 'scanResults', 'menus', 'htmlReadme', 'breadcrumbs', 'htmlCateReadme',
'mp3File', 'page', 'pageSize', 'cacheDataId', 'copyright', 'showType', 'isAdminIp', 'allFiles'
'mp3File', 'page', 'pageSize', 'cacheDataId', 'copyright', 'showType', 'isAdminIp', 'allFiles',
'cacheDataByDate'
);
return $this->render($viewName, $params, $pageTitle);
}

2
themes/beauty/controller/SiteController.php

@ -261,7 +261,7 @@ Class SiteController extends Controller { @@ -261,7 +261,7 @@ Class SiteController extends Controller {
//从缓存文件获取按年份、月份归类的索引数据
$cacheDataByDate = Common::getCache($this->dateIndexCacheKey);
$cacheDataByDate = Common::getCacheFromFile($this->dateIndexCacheKey, 86400*365);
$viewName = 'index';
$params = compact(

15
themes/beauty/views/site/index.php

@ -61,15 +61,22 @@ $main_view_cls = $menu_ext_status == 'opened' ? '' : 'full'; @@ -61,15 +61,22 @@ $main_view_cls = $menu_ext_status == 'opened' ? '' : 'full';
<li class="menu-title">按年月归类</li>
<?php
if (!empty($viewData['cacheDataByDate'])) {
print_r($viewData['cacheDataByDate']);
foreach($viewData['cacheDataByDate'] as $year => $ids) {
$intYear = str_replace('y', '', $year);
echo <<<eof
<li><a href="###"><img src="/img/beauty/calendar.svg" alt="calendar" width="17" class="menu-icon"> {$intYear}年</a></li>
eof;
}
}else {
echo <<<eof
<li>还没有按年月归类的索引数据,点击马上生成</li>
<li class="text-center">
还没有索引数据!
<button class="btnStartScan btn btn-xs btn-primary disabled">点我开始扫描</button>
</li>
eof;
}
?>
<li class="menu-title">目录</li>
<li class="menu-title mt-1">目录</li>
<?php
$breadcrumbs = !empty($viewData['breadcrumbs']) ? $viewData['breadcrumbs'] : [];
if (!empty($viewData['menus'])) { //只显示第一级目录

4
www/img/beauty/calendar.svg

@ -0,0 +1,4 @@ @@ -0,0 +1,4 @@
<?xml version="1.0" encoding="UTF-8"?>
<svg xmlns="http://www.w3.org/2000/svg" width="16" height="16" fill="currentColor" class="bi bi-calendar" viewBox="0 0 16 16">
<path d="M3.5 0a.5.5 0 0 1 .5.5V1h8V.5a.5.5 0 0 1 1 0V1h1a2 2 0 0 1 2 2v11a2 2 0 0 1-2 2H2a2 2 0 0 1-2-2V3a2 2 0 0 1 2-2h1V.5a.5.5 0 0 1 .5-.5M1 4v10a1 1 0 0 0 1 1h12a1 1 0 0 0 1-1V4z"/>
</svg>

After

Width:  |  Height:  |  Size: 362 B

Loading…
Cancel
Save