From 37c20ae14108b2086617bb22cde705880aae129c Mon Sep 17 00:00:00 2001 From: augushong Date: Wed, 28 Jun 2023 16:09:53 +0800 Subject: [PATCH] =?UTF-8?q?=E6=96=B0=E5=A2=9E=E6=96=87=E7=AB=A0=E7=BB=9F?= =?UTF-8?q?=E8=AE=A1=EF=BC=9B=E6=96=B0=E5=A2=9E=E6=B5=8F=E8=A7=88=E6=96=87?= =?UTF-8?q?=E7=AB=A0=E6=9F=A5=E7=9C=8B?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/index/controller/Common.php | 10 ++++++++-- app/model/PostVisit.php | 5 +++++ view/index/common/_right.html | 16 ++++++++++------ 3 files changed, 23 insertions(+), 8 deletions(-) diff --git a/app/index/controller/Common.php b/app/index/controller/Common.php index e289d35..13f6b45 100644 --- a/app/index/controller/Common.php +++ b/app/index/controller/Common.php @@ -44,8 +44,8 @@ class Common extends BaseController $top_posts = Post::where('is_top', 1)->limit(8)->where('type', 3)->cacheAlways('top_post')->select(); View::assign('top_posts', $top_posts); - $list_site_last_visit = PostVisit::order('id desc') - ->group('ip,uid') + $list_site_last_visit = PostVisit::with(['post'])->order('id desc') + ->group('post_id,ip,uid') ->limit(6) ->cache(60) ->select(); @@ -59,6 +59,12 @@ class Common extends BaseController View::assign('total_week_hits', $total_week_hits); View::assign('total_day_hits', $total_day_hits); + $total_post_count = Post::cache(60)->where('status', 1)->where('type', 3)->count(); + View::assign('total_post_count', $total_post_count); + + $total_month_post_count = Post::cache(60)->where('status', 1)->where('type', 3)->where('publish_time', '>', strtotime(date('Y-m-1 00:00:00')))->count(); + View::assign('total_month_post_count', $total_month_post_count); + $this->userHubLogin(); } diff --git a/app/model/PostVisit.php b/app/model/PostVisit.php index 614c6b5..8adaeb3 100644 --- a/app/model/PostVisit.php +++ b/app/model/PostVisit.php @@ -14,6 +14,11 @@ class PostVisit extends Model { // + public function post() + { + return $this->belongsTo(Post::class, 'post_id'); + } + public function getAvatarSrcAttr() { $value = $this->getAttr('avatar'); diff --git a/view/index/common/_right.html b/view/index/common/_right.html index 48a65f4..dca7991 100644 --- a/view/index/common/_right.html +++ b/view/index/common/_right.html @@ -32,12 +32,13 @@ {/volist} - +
全站文章:{$total_post_count}
+
本月发表:{$total_month_post_count}
- 最近文章浏览 + 最近浏览 {empty name='Request.session.user_uid'} 点击登录 @@ -55,14 +56,17 @@
{$vo.nickname_title}
-
{$vo.create_time_title}
+
+ {$vo.create_time_title} + 《{$vo.post.title}》 +
{/volist}
-
累计文章浏览次数:{$total_hits}
-
一周文章浏览次数:{$total_week_hits}
-
今日文章浏览次数:{$total_day_hits}
+
累计浏览次数:{$total_hits}
+
一周浏览次数:{$total_week_hits}
+
今日浏览次数:{$total_day_hits}