diff --git a/app/index/controller/BaseController.php b/app/index/controller/BaseController.php index e441826..87bd2c6 100644 --- a/app/index/controller/BaseController.php +++ b/app/index/controller/BaseController.php @@ -5,6 +5,7 @@ namespace app\index\controller; use app\BaseController as AppBaseController; use app\common\Bootstrap; use think\exception\HttpResponseException; +use think\facade\Env; use think\facade\Request; use think\Paginator; @@ -18,21 +19,25 @@ class BaseController extends AppBaseController return new Bootstrap($items, $listRows, $currentPage, $total, $simple, $options); }); - $main_domain = get_system_config('main_domain'); - $url = Request::url(); + $debug = Env::get('app_debug'); - if (!empty($main_domain)) { - if (Request::host() != $main_domain) { + if (!$debug) { + // 调试模式不要跳转域名和协议 + $main_domain = get_system_config('main_domain'); + $url = Request::url(); - throw new HttpResponseException(redirect(Request::scheme() . '://' . $main_domain . '' . $url)); + if (!empty($main_domain)) { + if (Request::host() != $main_domain) { + throw new HttpResponseException(redirect(Request::scheme() . '://' . $main_domain . '' . $url)); + } } - } - $is_jump_https = get_system_config('is_jump_https', 0); + $is_jump_https = get_system_config('is_jump_https', 0); - if ($is_jump_https == 1) { - if (Request::scheme() != 'https') { - throw new HttpResponseException(redirect('https://' . Request::host() . '' . $url)); + if ($is_jump_https == 1) { + if (Request::scheme() != 'https') { + throw new HttpResponseException(redirect('https://' . Request::host() . '' . $url)); + } } } } diff --git a/app/index/controller/Index.php b/app/index/controller/Index.php index b67489b..11dc92c 100644 --- a/app/index/controller/Index.php +++ b/app/index/controller/Index.php @@ -5,6 +5,7 @@ namespace app\index\controller; use app\model\Category; use app\model\Post; use app\model\PostCategory; +use app\model\PostVisit; use think\facade\Cache; use think\facade\Session; use think\facade\View; @@ -98,6 +99,28 @@ class Index extends Common 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() { Session::clear(); diff --git a/view/index/common/_right.html b/view/index/common/_right.html index dca7991..6783467 100644 --- a/view/index/common/_right.html +++ b/view/index/common/_right.html @@ -39,6 +39,7 @@