From 9a7c3233b6ad532e5a6e17d185595799129489b0 Mon Sep 17 00:00:00 2001 From: filesite Date: Tue, 7 May 2024 04:13:36 +0000 Subject: [PATCH] add index view for user --- themes/tajian/controller/ListController.php | 16 ---- themes/tajian/controller/SiteController.php | 25 ++++- themes/tajian/views/site/myindex.php | 100 ++++++++++++++++++++ www/css/tajian.css | 3 +- 4 files changed, 126 insertions(+), 18 deletions(-) create mode 100644 themes/tajian/views/site/myindex.php diff --git a/themes/tajian/controller/ListController.php b/themes/tajian/controller/ListController.php index 61a2e0b..d2c1844 100644 --- a/themes/tajian/controller/ListController.php +++ b/themes/tajian/controller/ListController.php @@ -85,20 +85,4 @@ Class ListController extends SiteController { return $breads; } - //根据tag的filenames获取它们的files数据,数据结构保持跟原file一致 - protected function getTagFiles($tag, $scanResults) { - $files = array(); - if (empty($tag['files'])) {return $files;} - - foreach($tag['files'] as $filename) { - foreach($scanResults as $id => $item) { - if (!empty($item['filename']) && $item['filename'] == $filename && $item['extension'] == 'url') { - $files[$id] = $item; - } - } - } - - return $files; - } - } diff --git a/themes/tajian/controller/SiteController.php b/themes/tajian/controller/SiteController.php index 2bd0ede..8382858 100644 --- a/themes/tajian/controller/SiteController.php +++ b/themes/tajian/controller/SiteController.php @@ -63,12 +63,19 @@ Class SiteController extends Controller { $tags = $this->sortTags($menus_sorted, $tags); } + //根据tag获取相关数据,并传给视图;调整视图兼容tag的数据结构 + if (!empty($tags)) { + foreach($tags as $id => $tag) { + $scanResults[$id]['files'] = $this->getTagFiles($tag, $scanResults); + } + } + //昵称支持 $nickname = $this->getNickname($readmeFile); $pageTitle = $defaultTitle = "{$nickname}的视频收藏夹 | " . FSC::$app['config']['site_name']; - $viewName = 'index'; + $viewName = 'myindex'; $params = compact( 'cateId', 'dirTree', 'scanResults', 'menus', 'htmlReadme', 'tags', 'nickname' @@ -145,6 +152,22 @@ Class SiteController extends Controller { return $sorted_tags; } + //根据tag的filenames获取它们的files数据,数据结构保持跟原file一致 + protected function getTagFiles($tag, $scanResults) { + $files = array(); + if (empty($tag['files'])) {return $files;} + + foreach($tag['files'] as $filename) { + foreach($scanResults as $id => $item) { + if (!empty($item['filename']) && $item['filename'] == $filename && $item['extension'] == 'url') { + $files[$id] = $item; + } + } + } + + return $files; + } + protected function getNickname($readmeFile) { $nickname = ''; diff --git a/themes/tajian/views/site/myindex.php b/themes/tajian/views/site/myindex.php new file mode 100644 index 0000000..097c28d --- /dev/null +++ b/themes/tajian/views/site/myindex.php @@ -0,0 +1,100 @@ + + 首页 >> +eof; + + foreach($breadcrumbs as $bread) { + if ($bread['id'] != $selectedId) { + echo <<{$bread['name']} / +eof; + }else { + echo <<{$bread['name']} +eof; + } + } + + echo << +eof; +} +?> + +
+
+ $item) { + + //输出分类名称 + echo << + >>更多 +

{$item['name']}

+
+
+eof; + + $category = $viewData['scanResults'][$item['id']]; + + if (!empty($category['files'])) { //一级目录支持,目录下直接存放视频文件 + + $cate_files = Html::sortFilesByCreateTime($category['files'], 'desc'); //按创建时间排序 + foreach($cate_files as $index => $file) { + //跳过非.url文件,且最多显示 8 个 + if (!in_array($file['extension'], $videoExts) || empty($file['shortcut']) || $index >= 8) { + continue; + } + + $snapshot = !empty($file['cover']) ? $imgPreffix . $file['cover'] : '/img/default.png'; + $title = !empty($file['title']) ? Html::mb_substr($file['title'], 0, 33, 'utf-8') : $file['filename']; + + $platform = Html::getShareVideosPlatform($file['shortcut']['url']); + + $pubDate = date('m/d', $file['fstat']['ctime']); + + $imgSrc = $index < 8 ? " src=\"{$snapshot}\"" : ''; + $imgAlt = $index < 8 ? " alt=\"{$title}\"" : ''; + + echo << +
+ + + +
+ +
+eof; + } + } + + echo << +eof; + + } +} +?> + +
diff --git a/www/css/tajian.css b/www/css/tajian.css index 02c9e86..a1276dc 100644 --- a/www/css/tajian.css +++ b/www/css/tajian.css @@ -88,7 +88,8 @@ a:link{text-decoration:none;} -webkit-line-clamp: 2; /* 这里是超出几行省略 */ overflow: hidden; } - +.tgroup{padding-right:5px;padding-top:10px} +.morelink{float:right;font-size:13px;margin-top:3px} /* 首页 end*/ /* 联系我们 */