Browse Source

bug fix: get page title and copyright failed when has cache data

master
filesite 4 months ago
parent
commit
25416c7ad9
  1. 25
      themes/beauty/controller/SiteController.php
  2. 8
      themes/beauty/views/layout/player.php
  3. 2
      themes/beauty/views/site/player.php

25
themes/beauty/controller/SiteController.php

@ -11,7 +11,7 @@ Class SiteController extends Controller {
public function actionIndex() { public function actionIndex() {
//获取数据 //获取数据
$menus = array(); //菜单,一级目录 $menus = array(); //菜单,一级目录
$htmlReadme = ''; //Readme.md 内容,底部网站详细介绍 $htmlReadme = array(); //Readme.md 内容,底部网站详细介绍
$htmlCateReadme = ''; //当前目录下的Readme.md 内容 $htmlCateReadme = ''; //当前目录下的Readme.md 内容
$menus_sorted = array(); //Readme_sort.txt 说明文件内容,一级目录菜单从上到下的排序 $menus_sorted = array(); //Readme_sort.txt 说明文件内容,一级目录菜单从上到下的排序
@ -92,9 +92,17 @@ Class SiteController extends Controller {
$htmlReadme = $Parsedown->text($content); $htmlReadme = $Parsedown->text($content);
$htmlReadme = $scanner->fixMDUrls($readmeFile['realpath'], $htmlReadme); $htmlReadme = $scanner->fixMDUrls($readmeFile['realpath'], $htmlReadme);
Common::saveCacheToFile($cacheKey, array('htmlReadme' => $htmlReadme, 'titles' => $titles)); $title = !empty($readmeFile['title']) ? $readmeFile['title'] : '';
$copyright = !empty($readmeFile['copyright']) ? $readmeFile['copyright'] : '';
Common::saveCacheToFile($cacheKey, array(
'htmlReadme' => $htmlReadme,
'titles' => $titles,
'title' => $title,
'copyright' => $copyright,
));
} }
}else { }else {
$readmeFile = $cachedData;
$htmlReadme = $cachedData['htmlReadme']; $htmlReadme = $cachedData['htmlReadme'];
$titles = $cachedData['titles']; $titles = $cachedData['titles'];
} }
@ -208,11 +216,22 @@ Class SiteController extends Controller {
$videoFilename = basename($arr['path']); $videoFilename = basename($arr['path']);
//获取联系方式
$maxScanDeep = 0; //最大扫描目录级数
$cacheKey = $this->getCacheKey('root', 'readme', $maxScanDeep);
$readmeFile = Common::getCacheFromFile($cacheKey);
//底部版权申明配置支持
$copyright = '';
if (!empty($readmeFile['copyright'])) {
$copyright = $readmeFile['copyright'];
}
$pageTitle = "视频播放器"; $pageTitle = "视频播放器";
$this->layout = 'player'; $this->layout = 'player';
$viewName = 'player'; $viewName = 'player';
$params = compact( $params = compact(
'videoUrl', 'videoFilename' 'videoUrl', 'videoFilename', 'copyright'
); );
return $this->render($viewName, $params, $pageTitle); return $this->render($viewName, $params, $pageTitle);
} }

8
themes/beauty/views/layout/player.php

@ -33,7 +33,12 @@ require_once __DIR__ . '/../../../../plugins/Html.php';
<p>用手机扫码打开</p> <p>用手机扫码打开</p>
<div id="qrimg"></div> <div id="qrimg"></div>
</div> </div>
<p> <p class="copyright">
<?php
if (!empty($viewData['copyright'])) {
echo $viewData['copyright'];
}else {
?>
<span>&copy;2022 - <?=date('Y')?></span> <span>&copy;2022 - <?=date('Y')?></span>
by <a href="https://filesite.io/" target="_blank">FileSite.io</a> by <a href="https://filesite.io/" target="_blank">FileSite.io</a>
<br> <br>
@ -42,6 +47,7 @@ require_once __DIR__ . '/../../../../plugins/Html.php';
- 执行耗时: {page_time_cost} ms - 执行耗时: {page_time_cost} ms
<?php } ?> <?php } ?>
<br>友情链接:<a href="https://tajian.tv" target="_blank">Ta荐 - 你的聚宝盆</a> <br>友情链接:<a href="https://tajian.tv" target="_blank">Ta荐 - 你的聚宝盆</a>
<?php } ?>
</p> </p>
</footer> </footer>
</div> </div>

2
themes/beauty/views/site/player.php

@ -12,7 +12,7 @@
</div> </div>
<a class="navbar-brand" href="/"> <a class="navbar-brand" href="/">
<span class="verMiddle">家庭相册</span> <span class="verMiddle"><?php echo $pageTitle; ?></span>
</a> </a>
<span class="navbar-text videotitle"><?php echo $viewData['videoFilename']; ?></span> <span class="navbar-text videotitle"><?php echo $viewData['videoFilename']; ?></span>
</div> </div>

Loading…
Cancel
Save