mirror of
https://gitee.com/ulthon/ulthon_information.git
synced 2026-03-04 00:24:29 +08:00
增加访问记录列表
This commit is contained in:
@@ -5,6 +5,7 @@ namespace app\index\controller;
|
|||||||
use app\BaseController as AppBaseController;
|
use app\BaseController as AppBaseController;
|
||||||
use app\common\Bootstrap;
|
use app\common\Bootstrap;
|
||||||
use think\exception\HttpResponseException;
|
use think\exception\HttpResponseException;
|
||||||
|
use think\facade\Env;
|
||||||
use think\facade\Request;
|
use think\facade\Request;
|
||||||
use think\Paginator;
|
use think\Paginator;
|
||||||
|
|
||||||
@@ -18,12 +19,15 @@ class BaseController extends AppBaseController
|
|||||||
return new Bootstrap($items, $listRows, $currentPage, $total, $simple, $options);
|
return new Bootstrap($items, $listRows, $currentPage, $total, $simple, $options);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
$debug = Env::get('app_debug');
|
||||||
|
|
||||||
|
if (!$debug) {
|
||||||
|
// 调试模式不要跳转域名和协议
|
||||||
$main_domain = get_system_config('main_domain');
|
$main_domain = get_system_config('main_domain');
|
||||||
$url = Request::url();
|
$url = Request::url();
|
||||||
|
|
||||||
if (!empty($main_domain)) {
|
if (!empty($main_domain)) {
|
||||||
if (Request::host() != $main_domain) {
|
if (Request::host() != $main_domain) {
|
||||||
|
|
||||||
throw new HttpResponseException(redirect(Request::scheme() . '://' . $main_domain . '' . $url));
|
throw new HttpResponseException(redirect(Request::scheme() . '://' . $main_domain . '' . $url));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -36,4 +40,5 @@ class BaseController extends AppBaseController
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -5,6 +5,7 @@ namespace app\index\controller;
|
|||||||
use app\model\Category;
|
use app\model\Category;
|
||||||
use app\model\Post;
|
use app\model\Post;
|
||||||
use app\model\PostCategory;
|
use app\model\PostCategory;
|
||||||
|
use app\model\PostVisit;
|
||||||
use think\facade\Cache;
|
use think\facade\Cache;
|
||||||
use think\facade\Session;
|
use think\facade\Session;
|
||||||
use think\facade\View;
|
use think\facade\View;
|
||||||
@@ -98,6 +99,28 @@ class Index extends Common
|
|||||||
return $content;
|
return $content;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function visit()
|
||||||
|
{
|
||||||
|
$post_id = $this->request->param('post_id');
|
||||||
|
|
||||||
|
$model_list_visit = PostVisit::with(['post'])->order('id desc');
|
||||||
|
|
||||||
|
if(!empty($post_id)) {
|
||||||
|
$model_list_visit->where('post_id', $post_id);
|
||||||
|
}
|
||||||
|
|
||||||
|
$list_visit = $model_list_visit->paginate([
|
||||||
|
'url' => 'Index/visit',
|
||||||
|
'list_rows' => 20,
|
||||||
|
'query' => [
|
||||||
|
'post_id' => $post_id,
|
||||||
|
],
|
||||||
|
]);
|
||||||
|
View::assign('list_visit', $list_visit);
|
||||||
|
|
||||||
|
return View::fetch();
|
||||||
|
}
|
||||||
|
|
||||||
public function logout()
|
public function logout()
|
||||||
{
|
{
|
||||||
Session::clear();
|
Session::clear();
|
||||||
|
|||||||
@@ -39,6 +39,7 @@
|
|||||||
<div class="session border">
|
<div class="session border">
|
||||||
<div class="header">
|
<div class="header">
|
||||||
<span>最近浏览</span>
|
<span>最近浏览</span>
|
||||||
|
|
||||||
<span style="font-size: 12px;">
|
<span style="font-size: 12px;">
|
||||||
{empty name='Request.session.user_uid'}
|
{empty name='Request.session.user_uid'}
|
||||||
<a href="{$login_url|default=''}">点击登录</a>
|
<a href="{$login_url|default=''}">点击登录</a>
|
||||||
@@ -64,6 +65,9 @@
|
|||||||
</div>
|
</div>
|
||||||
{/volist}
|
{/volist}
|
||||||
</div>
|
</div>
|
||||||
|
<div style="text-align: right;">
|
||||||
|
<a href="{:url('Index/visit')}" style="font-size: 12px;" title="">更多记录,大家在看什么?</a>
|
||||||
|
</div>
|
||||||
<div>累计浏览次数:{$total_hits}</div>
|
<div>累计浏览次数:{$total_hits}</div>
|
||||||
<div>一周浏览次数:{$total_week_hits}</div>
|
<div>一周浏览次数:{$total_week_hits}</div>
|
||||||
<div>今日浏览次数:{$total_day_hits}</div>
|
<div>今日浏览次数:{$total_day_hits}</div>
|
||||||
|
|||||||
41
view/index/index/visit.html
Normal file
41
view/index/index/visit.html
Normal file
@@ -0,0 +1,41 @@
|
|||||||
|
<!DOCTYPE html>
|
||||||
|
<html lang="zh-CN">
|
||||||
|
|
||||||
|
<head>
|
||||||
|
<meta charset="UTF-8">
|
||||||
|
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
||||||
|
<title>访问记录-{:get_system_config('site_name')}</title>
|
||||||
|
{include file='common/_require'/}
|
||||||
|
</head>
|
||||||
|
|
||||||
|
<body>
|
||||||
|
<div class="layui-container main-container">
|
||||||
|
<div class="layui-row layui-col-space12">
|
||||||
|
{include file='common/_left'/}
|
||||||
|
<div class="layui-col-md7">
|
||||||
|
<div class="main-container">
|
||||||
|
<div class="ul-avatar-sidebar-list">
|
||||||
|
{volist name='list_visit' id='vo'}
|
||||||
|
<div class="ul-avatar-sidebar-list-item" style="width: 100%;margin-bottom: 6px;">
|
||||||
|
<div class="ul-avatar-sidebar-list-item-img" style="background-image: url({$vo.avatar_src});"></div>
|
||||||
|
<div class="ul-avatar-sidebar-list-item-info">
|
||||||
|
<div class="ul-avatar-sidebar-list-item-title">{$vo.nickname_title}</div>
|
||||||
|
<div class="ul-avatar-sidebar-list-item-intro" style="color: #000;">
|
||||||
|
<span>{$vo.create_time_title}</span>
|
||||||
|
<a href="{$vo.post.read_url}" title="{$vo.post.title}">《{$vo.post.title}》</a>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
{/volist}
|
||||||
|
</div>
|
||||||
|
{$list_visit->render()|raw}
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
{include file='common/_right'/}
|
||||||
|
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
</body>
|
||||||
|
|
||||||
|
</html>
|
||||||
@@ -154,7 +154,10 @@
|
|||||||
</div>
|
</div>
|
||||||
{/volist}
|
{/volist}
|
||||||
</div>
|
</div>
|
||||||
<div class="layui-word-aux" >累计浏览次数:{$post->hits_title}</div>
|
<div style="text-align: right;">
|
||||||
|
<a href="{:url('Index/visit',['post_id'=>$post.id])}">更多记录,还有谁在看?</a>
|
||||||
|
</div>
|
||||||
|
<div class="layui-word-aux">累计浏览次数:{$post->hits_title}</div>
|
||||||
</div>
|
</div>
|
||||||
</fieldset>
|
</fieldset>
|
||||||
</div>
|
</div>
|
||||||
|
|||||||
Reference in New Issue
Block a user