diff --git a/app/admin/controller/Post.php b/app/admin/controller/Post.php index 9118593..2a3576c 100644 --- a/app/admin/controller/Post.php +++ b/app/admin/controller/Post.php @@ -4,7 +4,6 @@ declare(strict_types=1); namespace app\admin\controller; -use app\model\Nav; use app\model\Post as ModelPost; use app\model\PostCategory; use app\model\PostTag; @@ -43,6 +42,21 @@ class Post extends Common return View::fetch(); } + public function indexOutput() + { + $model_list = ModelPost::with(['categorys.category', 'tags.tag']) + ->where('type', $this->request->param('type', 1)) + ->order('id desc'); + + $list = $model_list->paginate([ + 'query' => $this->request->get(), + ]); + + View::assign('list', $list); + + return View::fetch(); + } + /** * 显示创建资源表单页. * @@ -151,7 +165,7 @@ class Post extends Common public function output($id) { $model_post = ModelPost::find($id); - $list_post_platform = Nav::where('type', 12)->order('sort asc')->select(); + $list_post_platform = list_post_platform(); foreach ($list_post_platform as $model_platform) { $platform_info = explode("\n", $model_platform->desc); diff --git a/app/common.php b/app/common.php index 7278c69..fd9820a 100644 --- a/app/common.php +++ b/app/common.php @@ -14,6 +14,7 @@ use app\model\Admin; use app\model\AdminPermission; +use app\model\Nav; use app\model\SystemConfig; use app\model\UploadFiles; use League\Flysystem\Util\MimeType; @@ -317,3 +318,8 @@ function show_time_ago($timestamp) return $result; } + +function list_post_platform() +{ + return Nav::where('type', 12)->order('sort asc')->cache(30)->select(); +} diff --git a/view/admin/common/left_post.html b/view/admin/common/left_post.html index 41ec6fa..513578e 100644 --- a/view/admin/common/left_post.html +++ b/view/admin/common/left_post.html @@ -3,10 +3,7 @@
-