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 { @@ -11,7 +11,7 @@ Class SiteController extends Controller {
public function actionIndex() {
//获取数据
$menus = array(); //菜单,一级目录
$htmlReadme = ''; //Readme.md 内容,底部网站详细介绍
$htmlReadme = array(); //Readme.md 内容,底部网站详细介绍
$htmlCateReadme = ''; //当前目录下的Readme.md 内容
$menus_sorted = array(); //Readme_sort.txt 说明文件内容,一级目录菜单从上到下的排序
@ -92,9 +92,17 @@ Class SiteController extends Controller { @@ -92,9 +92,17 @@ Class SiteController extends Controller {
$htmlReadme = $Parsedown->text($content);
$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 {
$readmeFile = $cachedData;
$htmlReadme = $cachedData['htmlReadme'];
$titles = $cachedData['titles'];
}
@ -208,11 +216,22 @@ Class SiteController extends Controller { @@ -208,11 +216,22 @@ Class SiteController extends Controller {
$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 = "视频播放器";
$this->layout = 'player';
$viewName = 'player';
$params = compact(
'videoUrl', 'videoFilename'
'videoUrl', 'videoFilename', 'copyright'
);
return $this->render($viewName, $params, $pageTitle);
}

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

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

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

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

Loading…
Cancel
Save