From 4fda375028d56c5874a9fce4b8e6737e9a38ee4e Mon Sep 17 00:00:00 2001 From: augushong Date: Sat, 19 Mar 2022 00:18:31 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BC=98=E5=8C=96=E6=80=A7=E8=83=BD=E5=92=8C?= =?UTF-8?q?=E8=BD=AE=E6=92=AD=E5=9B=BE;?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/index/controller/Common.php | 12 +- app/index/controller/Index.php | 20 +- app/model/Category.php | 1 + public/static/css/index.articles.css | 286 ++++++++++++++++----------- view/index/index/index.html | 174 ++++++++-------- 5 files changed, 274 insertions(+), 219 deletions(-) diff --git a/app/index/controller/Common.php b/app/index/controller/Common.php index 5163b2c..f883d3b 100644 --- a/app/index/controller/Common.php +++ b/app/index/controller/Common.php @@ -18,22 +18,22 @@ class Common extends BaseController parent::initialize(); - $list_nav_slide = Nav::where('type', 3)->cache('type_list_3')->order('sort asc')->where('status', 1)->select(); + $list_nav_slide = Nav::where('type', 3)->cacheAlways('type_list_3')->order('sort asc')->where('status', 1)->select(); View::assign('list_nav_slide', $list_nav_slide); - $list_nav_friend_url = Nav::where('type', 2)->cache('type_list_2')->order('sort asc')->where('status', 1)->select(); + $list_nav_friend_url = Nav::where('type', 2)->cacheAlways('type_list_2')->order('sort asc')->where('status', 1)->select(); View::assign('list_nav_friend_url', $list_nav_friend_url); - $list_header_nav = Nav::where('type', 11)->cache('type_list_11')->order('sort asc')->where('status', 1)->select(); + $list_header_nav = Nav::where('type', 11)->cacheAlways('type_list_11')->order('sort asc')->where('status', 1)->select(); View::assign('list_header_nav', $list_header_nav); - $list_category_first_level = Category::where('level', 1)->where('status', 1)->where('type', 3)->cache('category_type_list_3')->order('sort asc')->select(); + $list_category_first_level = Category::where('level', 1)->where('status', 1)->where('type', 3)->cacheAlways('category_type_list_3')->order('sort asc')->select(); View::assign('list_category_first_level', $list_category_first_level); - $list_nav_more = Nav::where('type', 8)->cache('type_list_8')->order('sort asc')->where('status', 1)->select(); + $list_nav_more = Nav::where('type', 8)->cacheAlways('type_list_8')->order('sort asc')->where('status', 1)->select(); View::assign('list_nav_more', $list_nav_more); - $top_posts = Post::where('is_top', 1)->limit(8)->where('type', 3)->cache('top_post')->select(); + $top_posts = Post::where('is_top', 1)->limit(8)->where('type', 3)->cacheAlways('top_post')->select(); View::assign('top_posts', $top_posts); $this->userHubLogin(); diff --git a/app/index/controller/Index.php b/app/index/controller/Index.php index 0f08d46..82cb526 100644 --- a/app/index/controller/Index.php +++ b/app/index/controller/Index.php @@ -20,13 +20,11 @@ class Index extends Common public function index() { - $page_cache_key = md5($this->request->url()); - $content = Cache::get($page_cache_key); - if (!empty($content)) { + if (!env('app_debug') && !empty($content)) { return $content; } @@ -34,13 +32,15 @@ class Index extends Common $sub_category = []; $current_category = []; - if (!empty($this->request->param('category_id'))) { - $sub_category = Category::where('pid', $this->request->param('category_id'))->where('type', 3)->order('sort asc')->select(); - $current_category = Category::find($this->request->param('category_id')); - if (empty($this->request->param('sub_category_id'))) { - $categorys = [$this->request->param('category_id')]; + $category_id = $this->request->param('category_id'); - $categorys = array_merge($categorys, array_column((array)Category::getListLevel($this->request->param('category_id')), 3)); + if (!empty($category_id)) { + $sub_category = Category::where('pid', $category_id)->where('type', 3)->order('sort asc')->select(); + $current_category = Category::find($category_id); + if (empty($this->request->param('sub_category_id'))) { + $categorys = [$category_id]; + + $categorys = array_merge($categorys, array_column((array)Category::getListLevel($category_id), 3)); $categorys_where = PostCategory::whereIn('category_id', $categorys); @@ -76,6 +76,8 @@ class Index extends Common $content = View::fetch(); Cache::tag('page_cache')->set($page_cache_key, $content); + + return $content; } diff --git a/app/model/Category.php b/app/model/Category.php index d05d5a7..04a8f07 100644 --- a/app/model/Category.php +++ b/app/model/Category.php @@ -17,6 +17,7 @@ class Category extends Base public static $autoClearCache = [ + [ 'name' => 'category_type_list', 'field' => 'type' diff --git a/public/static/css/index.articles.css b/public/static/css/index.articles.css index 7a014fb..23ebba2 100644 --- a/public/static/css/index.articles.css +++ b/public/static/css/index.articles.css @@ -1,220 +1,230 @@ .main-container { - margin-top: 15px; + margin-top: 15px; } .nav-left-container { - margin-top: 15px; + margin-top: 15px; } .nav-left-list { - text-align: center; + text-align: center; } .nav-left-list a { - display: block; - padding: 10px 15px; - border-radius: 5px; - margin: 5px 20px; + display : block; + padding : 10px 15px; + border-radius: 5px; + margin : 5px 20px; } -.nav-left-list a:hover, .nav-left-list a.current { - background-color: #6699CC; - color: #fff; +.nav-left-list a:hover, +.nav-left-list a.current { + background-color: #6699CC; + color : #fff; } .logo { - text-align: center; + text-align: center; } .logo img { - max-width: 60%; + max-width: 60%; } .session { - margin-top: 15px; - background-color: #99CCFF; - padding: 15px; + margin-top : 15px; + background-color: #99CCFF; + padding : 15px; } .session.border { - border-top: 2px solid #6699CC; + border-top: 2px solid #6699CC; } .session .header { - font-size: 18px; - font-weight: 600; - color: #036; + font-size : 18px; + font-weight: 600; + color : #036; } .search-container { - display: flex; + display: flex; } .layui-btn { - background-color: #6699CC; + background-color: #6699CC; } .nav-more-list a { - display: inline-block; - white-space: nowrap; - color: #036; - margin-right: 15px; - margin-top: 15px; + display : inline-block; + white-space : nowrap; + color : #036; + margin-right: 15px; + margin-top : 15px; } .session .info p { - margin: 5px 0; + margin: 5px 0; } #banner img { - width: 100%; + width: 100%; } .tab-list { - border-bottom: 1px solid #ddd; - margin-top: 15px; - font-size: 16px; + border-bottom: 1px solid #ddd; + margin-top : 15px; + font-size : 16px; } .tab-list a { - margin-right: 15px; - border-bottom: 2px solid transparent; - padding-bottom: 10px; - display: inline-block; + margin-right : 15px; + border-bottom : 2px solid transparent; + padding-bottom: 10px; + display : inline-block; } .tab-list a.current { - border-color: #6699CC; + border-color: #6699CC; } -.post-item, .plus-post-item { - display: flex; - justify-content: flex-start; - align-items: center; - margin-top: 15px; - padding-bottom: 15px; - border-bottom: 1px solid #ddd; +.post-item, +.plus-post-item { + display : flex; + justify-content: flex-start; + align-items : center; + margin-top : 15px; + padding-bottom : 15px; + border-bottom : 1px solid #ddd; } .post-item>div:nth-child(2) { - width: calc(100% - 160px); + width: calc(100% - 160px); } -.post-item .poster, .plus-post-item .poster { - width: 160px; - height: 100px; - background-size: cover; - background-position: center; - background-repeat: no-repeat; - margin-right: 15px; +.post-item .poster, +.plus-post-item .poster { + width : 160px; + height : 100px; + background-size : cover; + background-position: center; + background-repeat : no-repeat; + margin-right : 15px; } .plus-post-item .poster { - width: 60px; - height: 60px; + width : 60px; + height: 60px; } .plus-post-item .title { - font-size: 14px; + font-size: 14px; } .post-item .info .title { - font-size: 20px; - line-height: 1.3; - margin-bottom: 4px; - font-weight: 700; - max-height: 52px; - display: -webkit-box; - -webkit-line-clamp: 2; - overflow: hidden; - text-overflow: ellipsis; + font-size : 20px; + line-height : 1.3; + margin-bottom : 4px; + font-weight : 700; + max-height : 52px; + display : -webkit-box; + -webkit-line-clamp: 2; + overflow : hidden; + text-overflow : ellipsis; } .post-item .info .desc { - margin: 0 0 8px; - font-size: 13px; - line-height: 24px; - color: #999; + margin : 0 0 8px; + font-size : 13px; + line-height: 24px; + color : #999; } .post-item .info .plus-info { - margin-top: 5px; + margin-top: 5px; } .nodata { - margin: 60px auto; - display: block; - width: 40%; + margin : 60px auto; + display: block; + width : 40%; } .content-container .title { - font-size: 34px; - font-weight: 700; - line-height: 44px; - color: #222; + font-size : 34px; + font-weight: 700; + line-height: 44px; + color : #222; } .content-container .info { - margin-top: 12px; - font-size: 13px; - color: #777; + margin-top: 12px; + font-size : 13px; + color : #777; } -.content-container .info span{ - margin-right: 5px;; +.content-container .info span { + margin-right: 5px; + ; } .content-container .desc { - margin: 0 0 8px; - font-size: 13px; - line-height: 24px; - color: #999; - margin-top: 15px; + margin : 0 0 8px; + font-size : 13px; + line-height: 24px; + color : #999; + margin-top : 15px; } .content-container .jump-container { - margin-top: 15px; + margin-top: 15px; } @media screen and (max-width: 768px) { - .nav-left-list { - text-align: left; - } - .nav-left-list a { - display: inline-block; - margin: 5px; - } - .post-item .poster, .plus-post-item .poster { - width: 80px; - height: 60px; - } - .post-item>div:nth-child(2) { - width: calc(100% - 80px); - } - .post-item .info .title { - font-weight: 500; - font-size: 14px; - } - .content-container .title { - font-size: 18px; - line-height: 28px; - } + .nav-left-list { + text-align: left; + } + + .nav-left-list a { + display: inline-block; + margin : 5px; + } + + .post-item .poster, + .plus-post-item .poster { + width : 80px; + height: 60px; + } + + .post-item>div:nth-child(2) { + width: calc(100% - 80px); + } + + .post-item .info .title { + font-weight: 500; + font-size : 14px; + } + + .content-container .title { + font-size : 18px; + line-height: 28px; + } } @media screen and (min-width:1200px) { - .layui-container { - width: 1280px; - } + .layui-container { + width: 1280px; + } } -a.post-item:visited{ - color: #bbb; +a.post-item:visited { + color: #bbb; } -.ul-content p{ +.ul-content p { margin: 15px 0; } @@ -229,8 +239,8 @@ a.post-item:visited{ } -.ul-content h2{ - margin:20px 0 +.ul-content h2 { + margin: 20px 0 } /* 表格 */ @@ -268,7 +278,7 @@ a.post-item:visited{ margin: 10px 0 10px 20px; } -.ul-content ul li{ +.ul-content ul li { list-style: inherit; } @@ -284,4 +294,46 @@ a.post-item:visited{ .ul-content img { max-width: 100%; +} + +.index-poster { + height: 100%; + filter: blur(2px); +} + +#banner .panel { + display : flex; + align-items : center; + justify-content: center; + text-align : center; + text-shadow : 0 0 2px #333; + color : #fff; + z-index : 99; + height : 100%; + position : absolute; + top : 0; + left : 0; + width : 100%; +} + +#banner .index-poster { + height : 100%; + width : 100%; + background-size : cover; + background-position: center; + position : absolute; + z-index : 0; +} + +#banner .title { + font-size: 28px; + +} + +#banner .layui-carousel-arrow { + z-index: 999; +} + +#banner .layui-carousel-ind { + z-index: 999; } \ No newline at end of file diff --git a/view/index/index/index.html b/view/index/index/index.html index 10774df..cf91a95 100644 --- a/view/index/index/index.html +++ b/view/index/index/index.html @@ -2,115 +2,115 @@ - - - {$current_category.title|default='全部文章'}|{:get_system_config('site_name')} - - - {include file='common/_require'/} + + + {$current_category.title|default='全部文章'}|{:get_system_config('site_name')} + + + {include file='common/_require'/} -
-
- {include file='common/_left'/} -
-
+
+
+ {include file='common/_left'/} +
+
- {eq name='$Request.param.category_id|default="0"' value='0'} - {if count($list_nav_slide) > 0 } + {eq name='$Request.param.category_id|default="0"' value='0'} + {if count($list_nav_slide) > 0 } -
- - {$list_post->render()|raw} -
+ {include file='common/_right'/} +
-
- {include file='common/_right'/} -
-
- + \ No newline at end of file