修复缓存问题,开始使用scss重构

This commit is contained in:
2022-03-26 18:33:24 +08:00
parent e72f20a538
commit 9cb26e2cbf
8 changed files with 437 additions and 387 deletions

2
.gitignore vendored
View File

@@ -6,3 +6,5 @@
ul.db ul.db
composer.lock composer.lock
public/upload/* public/upload/*
/public/cdn/layui-ul.css
/public/cdn/layui-ul.css.map

View File

@@ -52,6 +52,8 @@ function get_system_config($name = '', $default = '')
try { try {
$list = SystemConfig::column('value', 'name'); $list = SystemConfig::column('value', 'name');
Cache::set('system_config', $list);
} catch (\Throwable $th) { } catch (\Throwable $th) {
return $default; return $default;
} }

View File

@@ -16,16 +16,19 @@ class Index extends Common
* *
* @return \think\Response * @return \think\Response
*/ */
public function index($post_id = 0) public function index($doc_name = '')
{ {
$list_post = Post::quickSelect(); $list_post = Post::quickSelect();
if (empty($post_id)) { if (empty($doc_name)) {
$model_post = $list_post->first()->post->first(); $model_post = $list_post->first()->post->first();
} else { } else {
$model_post = Post::quickFind($post_id); if (is_numeric($doc_name)) {
$model_post = Post::quickFind($doc_name);
} else {
$model_post = Post::quickFindByTplName($doc_name);
}
} }
View::assign('model_post', $model_post); View::assign('model_post', $model_post);
View::assign('list_post', $list_post); View::assign('list_post', $list_post);

View File

@@ -2,4 +2,4 @@
use think\facade\Route; use think\facade\Route;
Route::rule('doc/[:post_id]','Index/index'); Route::rule('doc/[:doc_name]','Index/index');

View File

@@ -6,6 +6,7 @@ namespace app\model;
use think\facade\App; use think\facade\App;
use think\facade\Cache; use think\facade\Cache;
use think\facade\Request;
use think\facade\View; use think\facade\View;
use think\Model; use think\Model;
use think\model\concern\SoftDelete; use think\model\concern\SoftDelete;
@@ -185,7 +186,7 @@ class Post extends Model
public static function quickFind($id, $clear = false) public static function quickFind($id, $clear = false)
{ {
$cache_key = 'post_' . $id; $cache_key = 'post_item_' . $id;
$model_post = Cache::get($cache_key); $model_post = Cache::get($cache_key);
@@ -196,4 +197,26 @@ class Post extends Model
return $model_post; return $model_post;
} }
public static function quickFindByTplName($tpl_name, $clear = false)
{
$cache_key = 'post_item_' . $tpl_name;
$model_post = Cache::get($cache_key);
if (empty($model_post) || $clear) {
$model_post = Post::where('tpl_name', $tpl_name)->find();
Cache::set($cache_key, $model_post, get_system_config('cache_expire_time'));
}
return $model_post;
}
public function getReadUrlAttr()
{
$domain = Request::domain();
$doc_name = $this->getData('tpl_name') ?: $this->getData('id');
return $domain . '/index/doc/' . $doc_name . '.html';
}
} }

View File

@@ -1,4 +1,5 @@
<?php <?php
use think\facade\Env; use think\facade\Env;
// +---------------------------------------------------------------------- // +----------------------------------------------------------------------
@@ -6,7 +7,7 @@ use think\facade\Env;
// +---------------------------------------------------------------------- // +----------------------------------------------------------------------
return [ return [
// 默认日志记录通道 // 默认日志记录通道
'default' => Env::get('log.channel', 'file'), 'default' => Env::get('log.channel', 'debug_mysql'),
// 日志记录级别 // 日志记录级别
'level' => [], 'level' => [],
// 日志类型记录的通道 ['error'=>'email',...] // 日志类型记录的通道 ['error'=>'email',...]
@@ -41,6 +42,26 @@ return [
'realtime_write' => false, 'realtime_write' => false,
], ],
// 其它日志通道配置 // 其它日志通道配置
// 其它日志通道配置
'debug_mysql' => [
'type' => 'DebugMysql',
// 服务器地址
'hostname' => Env::get('database.hostname', '127.0.0.1'),
// 数据库名
'database' => Env::get('database.database', ''),
// 用户名
'username' => Env::get('database.username', ''),
// 密码
'password' => Env::get('database.password', ''),
// 端口
'hostport' => Env::get('database.hostport', '3306'),
// 数据库连接参数
'params' => [],
// 数据库编码默认采用utf8
'charset' => Env::get('database.charset', 'utf8'),
// 数据库表前缀
'prefix' => Env::get('database.prefix', 'ul_'),
]
], ],
]; ];

View File

@@ -1,5 +1,4 @@
/* 列表开始 */ /* 列表开始 */
.ul-nav-tree {} .ul-nav-tree {}
.ul-nav-tree-group-title { .ul-nav-tree-group-title {

View File

@@ -38,7 +38,7 @@
</div> </div>
<div class="ul-nav-tree-group-main"> <div class="ul-nav-tree-group-main">
{volist name='category.post' id='post'} {volist name='category.post' id='post'}
<a href="{:url('Index/index',['post_id'=>$post.id])}" class="ul-nav-tree-item {eq name='post.id' value='$Request.param.post_id'}current{/eq}"> <a href="{$post.read_url}" class="ul-nav-tree-item {eq name='post.id' value='$model_post.id'}current{/eq}">
<div class="ul-nav-tree-item-title"> <div class="ul-nav-tree-item-title">
{$post.title} {$post.title}
</div> </div>