mirror of
https://gitee.com/ulthon/ulthon_information.git
synced 2026-03-03 16:24:28 +08:00
优化性能和轮播图;
This commit is contained in:
@@ -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();
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -17,6 +17,7 @@ class Category extends Base
|
||||
|
||||
|
||||
public static $autoClearCache = [
|
||||
|
||||
[
|
||||
'name' => 'category_type_list',
|
||||
'field' => 'type'
|
||||
|
||||
@@ -17,7 +17,8 @@
|
||||
margin : 5px 20px;
|
||||
}
|
||||
|
||||
.nav-left-list a:hover, .nav-left-list a.current {
|
||||
.nav-left-list a:hover,
|
||||
.nav-left-list a.current {
|
||||
background-color: #6699CC;
|
||||
color : #fff;
|
||||
}
|
||||
@@ -87,7 +88,8 @@
|
||||
border-color: #6699CC;
|
||||
}
|
||||
|
||||
.post-item, .plus-post-item {
|
||||
.post-item,
|
||||
.plus-post-item {
|
||||
display : flex;
|
||||
justify-content: flex-start;
|
||||
align-items : center;
|
||||
@@ -100,7 +102,8 @@
|
||||
width: calc(100% - 160px);
|
||||
}
|
||||
|
||||
.post-item .poster, .plus-post-item .poster {
|
||||
.post-item .poster,
|
||||
.plus-post-item .poster {
|
||||
width : 160px;
|
||||
height : 100px;
|
||||
background-size : cover;
|
||||
@@ -161,7 +164,8 @@
|
||||
}
|
||||
|
||||
.content-container .info span {
|
||||
margin-right: 5px;;
|
||||
margin-right: 5px;
|
||||
;
|
||||
}
|
||||
|
||||
.content-container .desc {
|
||||
@@ -182,21 +186,27 @@
|
||||
.nav-left-list {
|
||||
text-align: left;
|
||||
}
|
||||
|
||||
.nav-left-list a {
|
||||
display: inline-block;
|
||||
margin : 5px;
|
||||
}
|
||||
.post-item .poster, .plus-post-item .poster {
|
||||
|
||||
.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;
|
||||
@@ -285,3 +295,45 @@ 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;
|
||||
}
|
||||
@@ -26,11 +26,16 @@
|
||||
{volist name='list_nav_slide' id='nav'}
|
||||
|
||||
<a href="{$nav.value|default='javascript:;'}" target="{$nav.target}">
|
||||
<img src="{$nav.img}">
|
||||
<div class="index-poster" style="background-image: url({$nav.img});">
|
||||
|
||||
</div>
|
||||
<div class="panel">
|
||||
<div class="panel-main">
|
||||
<p class="title">{$nav.title}</p>
|
||||
<p class="desc">{$nav.desc}</p>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
</a>
|
||||
{/volist}
|
||||
|
||||
@@ -42,13 +47,10 @@
|
||||
|
||||
{notempty name='$sub_category'}
|
||||
<div class="tab-list">
|
||||
<a href="{:url('Index/index',['category_id'=>$Request.param.category_id])}" {eq
|
||||
name='$Request.param.sub_category_id|default=0' value='0' } class="current" {/eq}>全部</a>
|
||||
<a href="{:url('Index/index',['category_id'=>$Request.param.category_id])}" {eq name='$Request.param.sub_category_id|default=0' value='0' } class="current" {/eq}>全部</a>
|
||||
{volist name='$sub_category' id='category'}
|
||||
|
||||
<a href="{:url('Index/index',['category_id'=>$Request.param.category_id,'sub_category_id'=>$category.id])}"
|
||||
{eq name='$Request.param.sub_category_id|default=0' value='$category.id' } class="current"
|
||||
{else/}{/eq}>{$category.title}</a>
|
||||
<a href="{:url('Index/index',['category_id'=>$Request.param.category_id,'sub_category_id'=>$category.id])}" {eq name='$Request.param.sub_category_id|default=0' value='$category.id' } class="current" {else/}{/eq}>{$category.title}</a>
|
||||
{/volist}
|
||||
</div>
|
||||
{/notempty}
|
||||
@@ -61,9 +63,7 @@
|
||||
<div class="post-list">
|
||||
{volist name='list_post' id='post'}
|
||||
|
||||
<a href="{:url('Post/read',['uid'=>$post.uid])}" class="post-item"
|
||||
onmouseover="$(this).find('.poster').addClass('layui-anim-scale')"
|
||||
onmouseout="$(this).find('.poster').removeClass('layui-anim-scale')">
|
||||
<a href="{:url('Post/read',['uid'=>$post.uid])}" class="post-item" onmouseover="$(this).find('.poster').addClass('layui-anim-scale')" onmouseout="$(this).find('.poster').removeClass('layui-anim-scale')">
|
||||
{notempty name='$post->getData("poster")'}
|
||||
|
||||
<div class="poster layui-anim" style="background-image: url('{$post.poster}');"></div>
|
||||
|
||||
Reference in New Issue
Block a user