mirror of
https://gitee.com/ulthon/ulthon_information.git
synced 2026-03-04 00:24:29 +08:00
优化网站性能;
This commit is contained in:
@@ -1,6 +1,6 @@
|
|||||||
<?php
|
<?php
|
||||||
|
|
||||||
return [
|
return [
|
||||||
'\app\middleware\PermissionRecord',
|
// '\app\middleware\PermissionRecord',
|
||||||
'\app\middleware\AdminLog',
|
// '\app\middleware\AdminLog',
|
||||||
];
|
];
|
||||||
@@ -36,7 +36,6 @@ function json_message($data = [], $code = 0, $msg = '')
|
|||||||
$msg = $data;
|
$msg = $data;
|
||||||
$data = [];
|
$data = [];
|
||||||
}
|
}
|
||||||
|
|
||||||
} else if ($data instanceof Url) {
|
} else if ($data instanceof Url) {
|
||||||
$data = [
|
$data = [
|
||||||
'jump_to_url' => (string)$data
|
'jump_to_url' => (string)$data
|
||||||
|
|||||||
@@ -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 think\facade\Cache;
|
||||||
use think\facade\Session;
|
use think\facade\Session;
|
||||||
use think\facade\View;
|
use think\facade\View;
|
||||||
use think\Request;
|
use think\Request;
|
||||||
@@ -18,6 +19,17 @@ class Index extends Common
|
|||||||
*/
|
*/
|
||||||
public function index()
|
public function index()
|
||||||
{
|
{
|
||||||
|
|
||||||
|
|
||||||
|
$page_cache_key = md5($this->request->url());
|
||||||
|
|
||||||
|
|
||||||
|
$content = Cache::get($page_cache_key);
|
||||||
|
|
||||||
|
if (!empty($content)) {
|
||||||
|
return $content;
|
||||||
|
}
|
||||||
|
|
||||||
//
|
//
|
||||||
$sub_category = [];
|
$sub_category = [];
|
||||||
$current_category = [];
|
$current_category = [];
|
||||||
@@ -52,7 +64,8 @@ class Index extends Common
|
|||||||
|
|
||||||
$list_post = $model_post->paginate([
|
$list_post = $model_post->paginate([
|
||||||
'url' => 'Index/index',
|
'url' => 'Index/index',
|
||||||
'query' => $this->request->get()
|
'query' => $this->request->get(),
|
||||||
|
'list_rows' => 10
|
||||||
]);
|
]);
|
||||||
|
|
||||||
View::assign('current_category', $current_category);
|
View::assign('current_category', $current_category);
|
||||||
@@ -60,7 +73,9 @@ class Index extends Common
|
|||||||
|
|
||||||
View::assign('list_post', $list_post);
|
View::assign('list_post', $list_post);
|
||||||
|
|
||||||
return View::fetch();
|
$content = View::fetch();
|
||||||
|
|
||||||
|
Cache::tag('page_cache')->set($page_cache_key, $content);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -20,7 +20,11 @@ class Category extends Base
|
|||||||
[
|
[
|
||||||
'name' => 'category_type_list',
|
'name' => 'category_type_list',
|
||||||
'field' => 'type'
|
'field' => 'type'
|
||||||
]
|
],
|
||||||
|
[
|
||||||
|
'type' => 'tag',
|
||||||
|
'name' => 'page_cache'
|
||||||
|
],
|
||||||
];
|
];
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -18,7 +18,11 @@ class Nav extends Base
|
|||||||
'type' => 'key',
|
'type' => 'key',
|
||||||
'name' => 'type_list',
|
'name' => 'type_list',
|
||||||
'field' => 'type'
|
'field' => 'type'
|
||||||
]
|
],
|
||||||
|
[
|
||||||
|
'type' => 'tag',
|
||||||
|
'name' => 'page_cache'
|
||||||
|
],
|
||||||
];
|
];
|
||||||
|
|
||||||
public static $statusName = [
|
public static $statusName = [
|
||||||
|
|||||||
@@ -4,6 +4,7 @@ declare(strict_types=1);
|
|||||||
|
|
||||||
namespace app\model;
|
namespace app\model;
|
||||||
|
|
||||||
|
use app\common\model\Base;
|
||||||
use think\facade\Cache;
|
use think\facade\Cache;
|
||||||
use think\facade\Request;
|
use think\facade\Request;
|
||||||
use think\Model;
|
use think\Model;
|
||||||
@@ -13,10 +14,20 @@ use think\Paginator;
|
|||||||
/**
|
/**
|
||||||
* @mixin think\Model
|
* @mixin think\Model
|
||||||
*/
|
*/
|
||||||
class Post extends Model
|
class Post extends Base
|
||||||
{
|
{
|
||||||
//
|
//
|
||||||
|
|
||||||
|
public static $autoClearCache = [
|
||||||
|
[
|
||||||
|
'name' => 'top_post'
|
||||||
|
],
|
||||||
|
[
|
||||||
|
'type' => 'tag',
|
||||||
|
'name' => 'page_cache'
|
||||||
|
],
|
||||||
|
];
|
||||||
|
|
||||||
public static $stausNameList = [
|
public static $stausNameList = [
|
||||||
0 => '不发布',
|
0 => '不发布',
|
||||||
1 => '发布'
|
1 => '发布'
|
||||||
|
|||||||
Reference in New Issue
Block a user