修正路由错误

This commit is contained in:
yumo 2023-07-18 16:50:36 +08:00
parent a2ad5cb8bd
commit ad077237cd
19 changed files with 81 additions and 86 deletions

View File

@ -17,16 +17,6 @@ class Index extends AuthController
*/ */
public function index() public function index()
{ {
//判断后台统计配置是否开启 1 开启 return app("json")->success("获取成功", 'code');
if (web_config("web_statistics") == 1) {
//统计url
$this->urlrecord('网站首页');
}
//清除可能存在的栏目分类树id
cache(Data::CURR_CATEGORY_PATENT_ID, false);
//模板兼容性标签
$this->assign('id', false);
$this->assign('cid', false);
return $this->fetch();
} }
} }

View File

@ -17,6 +17,8 @@ use think\db\exception\ModelNotFoundException;
*/ */
class Tag extends BaseModel class Tag extends BaseModel
{ {
protected static $cache_key = 'index:tagList';
/** /**
* 列表 * 列表
* @param $where * @param $where
@ -66,9 +68,16 @@ class Tag extends BaseModel
'user_id' => $user_id, 'user_id' => $user_id,
]; ];
} }
$this->clearCache();
return $this->saveAll($saveAll); return $this->saveAll($saveAll);
} }
/**
* 清除缓存
*/
public function clearCache(){
cache()->delete(self::$cache_key);
}
/** /**
* 列表 * 列表
@ -82,7 +91,7 @@ class Tag extends BaseModel
*/ */
public static function getList($where): array public static function getList($where): array
{ {
$list = cache('index:tagList'); $list = cache(self::$cache_key);
if ($list) { if ($list) {
return json_decode($list, true); return json_decode($list, true);
} else { } else {
@ -95,7 +104,7 @@ class Tag extends BaseModel
$tag->href = url('/article/tag',["t"=>$tag["name"]],'html')->build(); $tag->href = url('/article/tag',["t"=>$tag["name"]],'html')->build();
})->toArray(); })->toArray();
if ($list) { if ($list) {
cache('index:tagList', json_encode($list), 24 * 60 * 60); cache(self::$cache_key, json_encode($list), 24 * 60 * 60);
} }
} }
return $list; return $list;

View File

@ -270,7 +270,8 @@ function get_document_category_by_parent($pid, $row)
/* /*
* 获取所有子集元素 * 获取所有子集元素
*/ */
function getSubs($categorys,$catId=0,$level=1){ function getSubs($categorys, $catId = 0, $level = 1)
{
$subs = array(); $subs = array();
foreach ($categorys as $item) { foreach ($categorys as $item) {
if ($item['pid'] == $catId) { if ($item['pid'] == $catId) {
@ -308,7 +309,7 @@ function get_document_category_all()
function tpl_get_prenext($get, $cid = false, $none) function tpl_get_prenext($get, $cid = false, $none)
{ {
//文档id //文档id
$id = input('id'); $id = request()->param('id');
if (!$get) { if (!$get) {
$get = 'next'; $get = 'next';
} }
@ -322,7 +323,7 @@ function tpl_get_prenext($get, $cid = false, $none)
$document = $document->field('id,title')->order($get == 'pre' ? 'id desc' : 'id asc')->find(); $document = $document->field('id,title')->order($get == 'pre' ? 'id desc' : 'id asc')->find();
if ($document) { if ($document) {
$document['url'] = url('article/detail?id=' . $document['id'])->build(); $document['url'] = url('/article/detail?id=' . $document['id'])->build();
} else { } else {
$document['id'] = false; $document['id'] = false;
$document['url'] = 'javascript:void(0)'; $document['url'] = 'javascript:void(0)';
@ -380,8 +381,8 @@ function tpl_get_list($orderBy, int $pageSize, $cid, $type, $table = 'article',
break; break;
case 'search': case 'search':
//获取关键字搜索的文章 //获取关键字搜索的文章
$kw = input('kw'); //搜索关键词 $kw = request()->param('kw'); //搜索关键词
$tid = input('cid');//文章分类Id $tid = request()->param('cid');//文章分类Id
if ($kw) { if ($kw) {
$documentListModel = $documentListModel->where('a.title', 'like', "%$kw%"); $documentListModel = $documentListModel->where('a.title', 'like', "%$kw%");
} }
@ -395,7 +396,7 @@ function tpl_get_list($orderBy, int $pageSize, $cid, $type, $table = 'article',
break; break;
case 'tag': case 'tag':
//读取指定tag的文章 //读取指定tag的文章
$tag = substr(input('t'), 0, strpos(input('t'), '.')); //搜索关键词 $tag = request()->param('t'); //标签
$tagModel = new Tag(); $tagModel = new Tag();
$tagList = $tagModel->where('name', $tag)->select()->toArray(); $tagList = $tagModel->where('name', $tag)->select()->toArray();
$documentListModel = $documentListModel->where('a.id', 'in', array_column($tagList, 'document_id')); $documentListModel = $documentListModel->where('a.id', 'in', array_column($tagList, 'document_id'));
@ -445,7 +446,7 @@ function get_route_query()
*/ */
function make_category_url($item) function make_category_url($item)
{ {
return url('article/detail', ['id'=>$item['alias']?:$item['id']])->build(); return url('/article/detail', ['id' => $item['alias'] ?: $item['id']])->build();
} }
/** /**
@ -637,7 +638,8 @@ function tpl_get_advert($type, int $row = 5)
* @author 木子的忧伤 * @author 木子的忧伤
* @date 2022-06-01 10:06 * @date 2022-06-01 10:06
*/ */
function tpl_get_archive_list($type,$format){ function tpl_get_archive_list($type, $format)
{
$list = cache(Data::DATA_ARCHIVE . '_' . $type); $list = cache(Data::DATA_ARCHIVE . '_' . $type);
$list = null; $list = null;
if ($list === null) { if ($list === null) {
@ -645,9 +647,6 @@ function tpl_get_archive_list($type,$format){
case "month": case "month":
$dateFormat = "LEFT(create_date,7)"; $dateFormat = "LEFT(create_date,7)";
break; break;
case "day":
$dateFormat = "create_date";
break;
case "year": case "year":
$dateFormat = "LEFT(create_date,4)"; $dateFormat = "LEFT(create_date,4)";
break; break;
@ -700,7 +699,7 @@ if (!function_exists('tpl_get_tags_list')) {
$tagTemp = []; $tagTemp = [];
foreach ($tagArr as $item) { foreach ($tagArr as $item) {
$data['title'] = $item; $data['title'] = $item;
$data['url'] = url('article/tag?t=' . urlencode($item)); $data['url'] = url('/article/tag', ["t" => $item])->build();
array_push($tagTemp, $data); array_push($tagTemp, $data);
} }
return $tagTemp; return $tagTemp;
@ -739,7 +738,7 @@ function get_comment_children($parentIds)
return $list; return $list;
} }
foreach ($list as &$item) { foreach ($list as &$item) {
$item['reply_url'] = url('article/create_comment?pid=' . $item['id'])->build(); $item['reply_url'] = url('/article/create_comment', ["pid" => $item['id']])->build();
} }
unset($item); unset($item);
return array_merge($list, get_comment_children(array_column($list, 'id'))); return array_merge($list, get_comment_children(array_column($list, 'id')));
@ -781,7 +780,7 @@ function tpl_get_comment_list($id, $type, $pageSize, $orderBy)
} }
$lists = []; $lists = [];
foreach ($commentModel as $key => $item) { foreach ($commentModel as $key => $item) {
$item['reply_url'] = url('article/create_comment?pid=' . $item['id'])->build(); $item['reply_url'] = url('/article/create_comment', ["id" => $item['id']])->build();
$lists[$key] = $item; $lists[$key] = $item;
} }
return [ return [
@ -829,11 +828,9 @@ function get_comment_count($documentId, $type = 'top')
*/ */
function tpl_get_relevant_list($documentId, $row, $table = 'article') function tpl_get_relevant_list($documentId, $row, $table = 'article')
{ {
$count = Document::where('type', $table) $count = Document::where('type', $table)->where('status', 1)->count(); //获取总记录数
->where('status', 1)->count(); //获取总记录数
$id = (new Document())->getPK(); $id = (new Document())->getPK();
$min = Document::where('type', $table) $min = Document::where('type', $table)->where('status', 1)->min($id); //统计某个字段最小数据
->where('status', 1)->min($id); //统计某个字段最小数据
if ($count < $row) { if ($count < $row) {
$row = $count; $row = $count;
} }
@ -850,8 +847,8 @@ function tpl_get_relevant_list($documentId, $row, $table = 'article')
} else { } else {
$i--; $i--;
} }
$i++;
} }
$i++;
} }
$relevantList = Document::where('type', $table) $relevantList = Document::where('type', $table)
->where('status', 1) ->where('status', 1)
@ -870,7 +867,7 @@ function tpl_get_relevant_list($documentId, $row, $table = 'article')
//获取顶级栏目名 //获取顶级栏目名
function GetTopTypename($id = false) function GetTopTypename($id = false)
{ {
$id = $id ? $id : input('id'); $id = $id ?: request()->param('id');
$dc = get_document_category($id); $dc = get_document_category($id);
if ((int)$dc['pid'] === 0) { if ((int)$dc['pid'] === 0) {
return $dc['title']; return $dc['title'];
@ -882,7 +879,7 @@ function GetTopTypename($id = false)
//获取顶级id //获取顶级id
function GetToptypeId($id = false) function GetToptypeId($id = false)
{ {
$id = $id ? $id : input('id'); $id = $id ?: request()->param('id');
$dc = get_document_category($id); $dc = get_document_category($id);
if ((int)$dc['pid'] === 0) { if ((int)$dc['pid'] === 0) {
return $dc['id']; return $dc['id'];
@ -894,7 +891,7 @@ function GetToptypeId($id = false)
//获取顶级栏目图片 //获取顶级栏目图片
function GetTopTypeimg($id = false) function GetTopTypeimg($id = false)
{ {
$id = $id ? $id : input('id'); $id = $id ?: request()->param('id');
$dc = get_document_category($id); $dc = get_document_category($id);
if ((int)$dc['pid'] === 0) { if ((int)$dc['pid'] === 0) {
return $dc['icon']; return $dc['icon'];
@ -905,7 +902,7 @@ function GetTopTypeimg($id = false)
//获取顶级栏目描述 //获取顶级栏目描述
function GetTopDescription($id = false) function GetTopDescription($id = false)
{ {
$id = $id ? $id : input('id'); $id = $id ?: request()->param('id');
$dc = get_document_category($id); $dc = get_document_category($id);
if ((int)$dc['pid'] === 0) { if ((int)$dc['pid'] === 0) {
return $dc['description']; return $dc['description'];
@ -917,7 +914,7 @@ function GetTopDescription($id = false)
//获取顶级英文名称 //获取顶级英文名称
function GetTopTypenameen($id = false) function GetTopTypenameen($id = false)
{ {
$id = $id ? $id : input('id'); $id = $id ?: request()->param('id');
$dc = get_document_category($id); $dc = get_document_category($id);
if ((int)$dc['pid'] === 0) { if ((int)$dc['pid'] === 0) {
return $dc['name']; return $dc['name'];

View File

@ -30,7 +30,6 @@ class Base extends BaseController
protected function initialize() protected function initialize()
{ {
parent::initialize(); parent::initialize();
$this->userInfo = Session::get(Data::SESSION_KEY_USER_INFO); $this->userInfo = Session::get(Data::SESSION_KEY_USER_INFO);
$this->userId = Session::get(Data::SESSION_KEY_USER_ID); $this->userId = Session::get(Data::SESSION_KEY_USER_ID);

View File

@ -40,7 +40,7 @@
<div class="post-info"> <div class="post-info">
<div class="post-info-left"> <div class="post-info-left">
<a class="nickname url fn j-user-card" data-user="1" <a class="nickname url fn j-user-card" data-user="1"
href="{:url('article/user')}?author={$apeField['author']}"><i class="fa fa-user" aria-hidden="true"></i>{$apeField['author']} href="{:url('/article/user')}?author={$apeField['author']}"><i class="fa fa-user" aria-hidden="true"></i>{$apeField['author']}
</a> </a>
<span class="dot"></span> <span class="dot"></span>
<time class="entry-date published" datetime="{$apeField['create_time']}" pubdate=""><i <time class="entry-date published" datetime="{$apeField['create_time']}" pubdate=""><i
@ -48,7 +48,7 @@
{$apeField['create_time']} {$apeField['create_time']}
</time> </time>
<span class="dot"></span><i class="fas fa-folder"></i> <span class="dot"></span><i class="fas fa-folder"></i>
<a href="{:url('article/lists')}?id={$apeField['category_id']}" rel="category tag"> {$apeField['category_title']}</a> <a href="{:url('/article/lists')}?id={$apeField['category_id']}" rel="category tag"> {$apeField['category_title']}</a>
<span class="dot"></span> <span class="dot"></span>
<span><i class="fa fa-eye" aria-hidden="true"></i>{$apeField['view']} 阅读</span> <span><i class="fa fa-eye" aria-hidden="true"></i>{$apeField['view']} 阅读</span>
</div> </div>
@ -305,7 +305,7 @@
<div class="hot-post-widget-item-meta"> <div class="hot-post-widget-item-meta">
<div>{$field['create_time']}</div> <div>{$field['create_time']}</div>
<div> <div>
<a href="{:url('article/lists')}?id={$field['category_id']}">{:cn_substr($field['category_title'],5)}</a> <a href="{:url('/article/lists')}?id={$field['category_id']}">{:cn_substr($field['category_title'],5)}</a>
</div> </div>
</div> </div>
</div> </div>

View File

@ -96,7 +96,7 @@
<div class="hot-post-widget-item-meta"> <div class="hot-post-widget-item-meta">
<div>{$field['create_time']}</div> <div>{$field['create_time']}</div>
<div> <div>
<a href="{:url('article/lists')}?id={$field['category_id']}">{:cn_substr($field['category_title'],5)}</a> <a href="{:url('/article/lists')}?id={$field['category_id']}">{:cn_substr($field['category_title'],5)}</a>
</div> </div>
</div> </div>
</div> </div>

View File

@ -96,7 +96,7 @@
<div class="hot-post-widget-item-meta"> <div class="hot-post-widget-item-meta">
<div>{$field['create_time']}</div> <div>{$field['create_time']}</div>
<div> <div>
<a href="{:url('article/lists')}?id={$field['category_id']}">{:cn_substr($field['category_title'],5)}</a> <a href="{:url('/article/lists')}?id={$field['category_id']}">{:cn_substr($field['category_title'],5)}</a>
</div> </div>
</div> </div>
</div> </div>

View File

@ -96,7 +96,7 @@
<div class="hot-post-widget-item-meta"> <div class="hot-post-widget-item-meta">
<div>{$field['create_time']}</div> <div>{$field['create_time']}</div>
<div> <div>
<a href="{:url('article/lists')}?id={$field['category_id']}">{:cn_substr($field['category_title'],5)}</a> <a href="{:url('/article/lists')}?id={$field['category_id']}">{:cn_substr($field['category_title'],5)}</a>
</div> </div>
</div> </div>
</div> </div>

View File

@ -96,7 +96,7 @@
<div class="hot-post-widget-item-meta"> <div class="hot-post-widget-item-meta">
<div>{$field['create_time']}</div> <div>{$field['create_time']}</div>
<div> <div>
<a href="{:url('article/lists')}?id={$field['category_id']}">{:cn_substr($field['category_title'],5)}</a> <a href="{:url('/article/lists')}?id={$field['category_id']}">{:cn_substr($field['category_title'],5)}</a>
</div> </div>
</div> </div>
</div> </div>

View File

@ -164,7 +164,7 @@
<div class="hot-post-widget-item-meta"> <div class="hot-post-widget-item-meta">
<div>{$field['create_time']}</div> <div>{$field['create_time']}</div>
<div> <div>
<a href="{:url('article/lists')}?id={$field['category_id']}">{:cn_substr($field['category_title'],5)}</a> <a href="{:url('/article/lists')}?id={$field['category_id']}">{:cn_substr($field['category_title'],5)}</a>
</div> </div>
</div> </div>
</div> </div>

View File

@ -172,7 +172,7 @@
<div class="hot-post-widget-item-meta"> <div class="hot-post-widget-item-meta">
<div>{$field['create_time']}</div> <div>{$field['create_time']}</div>
<div> <div>
<a href="{:url('article/lists')}?id={$field['category_id']}">{:cn_substr($field['category_title'],5)}</a> <a href="{:url('/article/lists')}?id={$field['category_id']}">{:cn_substr($field['category_title'],5)}</a>
</div> </div>
</div> </div>
</div> </div>
@ -190,7 +190,7 @@
<div class="hot-post-widget-item-meta"> <div class="hot-post-widget-item-meta">
<div>{$field['create_time']}</div> <div>{$field['create_time']}</div>
<div> <div>
<a href="{:url('article/lists')}?id={$field['category_id']}">{:cn_substr($field['category_title'],5)}</a> <a href="{:url('/article/lists')}?id={$field['category_id']}">{:cn_substr($field['category_title'],5)}</a>
</div> </div>
</div> </div>
</div> </div>

View File

@ -156,7 +156,7 @@
<div class="hot-post-widget-item-meta"> <div class="hot-post-widget-item-meta">
<div>{$field['create_time']}</div> <div>{$field['create_time']}</div>
<div> <div>
<a href="{:url('article/lists')}?id={$field['category_id']}">{:cn_substr($field['category_title'],5)}</a> <a href="{:url('/article/lists')}?id={$field['category_id']}">{:cn_substr($field['category_title'],5)}</a>
</div> </div>
</div> </div>
</div> </div>

View File

@ -40,7 +40,7 @@
<div class="post-info"> <div class="post-info">
<div class="post-info-left"> <div class="post-info-left">
<a class="nickname url fn j-user-card" data-user="1" <a class="nickname url fn j-user-card" data-user="1"
href="{:url('article/user')}?author={$apeField['author']}"><i class="fa fa-user" aria-hidden="true"></i>{$apeField['author']} href="{:url('/article/user')}?author={$apeField['author']}"><i class="fa fa-user" aria-hidden="true"></i>{$apeField['author']}
</a> </a>
<span class="dot"></span> <span class="dot"></span>
<time class="entry-date published" datetime="{$apeField['create_time']}" pubdate=""><i <time class="entry-date published" datetime="{$apeField['create_time']}" pubdate=""><i
@ -279,7 +279,7 @@
<div class="hot-post-widget-item-meta"> <div class="hot-post-widget-item-meta">
<div>{$field['create_time']}</div> <div>{$field['create_time']}</div>
<div> <div>
<a href="{:url('article/lists')}?id={$field['category_id']}">{:cn_substr($field['category_title'],5)}</a> <a href="{:url('/article/lists')}?id={$field['category_id']}">{:cn_substr($field['category_title'],5)}</a>
</div> </div>
</div> </div>
</div> </div>

View File

@ -49,7 +49,7 @@
"is_single": "", "is_single": "",
"is_page": "", "is_page": "",
"is_home": "0", "is_home": "0",
"ajaxurl": "{:url('/index/index')}", "ajaxurl": "{:url('/api/index/index')}",
"logourl": "{:web_config('logo')}", "logourl": "{:web_config('logo')}",
"imgurl": "__IMG__/", "imgurl": "__IMG__/",
"themeColor": "#409EFF", "themeColor": "#409EFF",

View File

@ -128,13 +128,13 @@
</a> </a>
<ul class="user-sub-menu sub-menu"> <ul class="user-sub-menu sub-menu">
<li> <li>
<a href="{:url('index/user/profile')}"><i class="fas fa-user-cog"></i> 账号设置</a> <a href="{:url('/user/profile')}"><i class="fas fa-user-cog"></i> 账号设置</a>
</li> </li>
<!-- <li>--> <!-- <li>-->
<!-- <a href="{:url('index/login/loginout')}"><i class="far fa-edit"></i>新建文章</a>--> <!-- <a href="{:url('/login/loginout')}"><i class="far fa-edit"></i>新建文章</a>-->
<!-- </li>--> <!-- </li>-->
<li> <li>
<a href="{:url('index/user/logout')}"><i class="fas fa-sign-out-alt"></i> 退出登录</a> <a href="{:url('/user/logout')}"><i class="fas fa-sign-out-alt"></i> 退出登录</a>
</li> </li>
</ul> </ul>
</li> </li>

View File

@ -10,7 +10,7 @@ return array(
'think\\composer\\' => array($vendorDir . '/topthink/think-installer/src'), 'think\\composer\\' => array($vendorDir . '/topthink/think-installer/src'),
'think\\captcha\\' => array($vendorDir . '/topthink/think-captcha/src'), 'think\\captcha\\' => array($vendorDir . '/topthink/think-captcha/src'),
'think\\app\\' => array($vendorDir . '/topthink/think-multi-app/src'), 'think\\app\\' => array($vendorDir . '/topthink/think-multi-app/src'),
'think\\' => array($vendorDir . '/topthink/think-filesystem/src', $vendorDir . '/topthink/think-helper/src', $vendorDir . '/topthink/think-orm/src', $vendorDir . '/topthink/think-template/src', $vendorDir . '/topthink/framework/src/think'), 'think\\' => array($vendorDir . '/topthink/framework/src/think', $vendorDir . '/topthink/think-filesystem/src', $vendorDir . '/topthink/think-helper/src', $vendorDir . '/topthink/think-orm/src', $vendorDir . '/topthink/think-template/src'),
'mailer\\' => array($vendorDir . '/yzh52521/think-mail/src/mailer'), 'mailer\\' => array($vendorDir . '/yzh52521/think-mail/src/mailer'),
'liliuwei\\social\\' => array($vendorDir . '/liliuwei/thinkphp-social/src'), 'liliuwei\\social\\' => array($vendorDir . '/liliuwei/thinkphp-social/src'),
'liliuwei\\sitemap\\' => array($vendorDir . '/liliuwei/php-sitemap/src'), 'liliuwei\\sitemap\\' => array($vendorDir . '/liliuwei/php-sitemap/src'),

View File

@ -107,11 +107,11 @@ class ComposerStaticInit4b57298e8d0e895486f3307a354a7e1a
), ),
'think\\' => 'think\\' =>
array ( array (
0 => __DIR__ . '/..' . '/topthink/think-filesystem/src', 0 => __DIR__ . '/..' . '/topthink/framework/src/think',
1 => __DIR__ . '/..' . '/topthink/think-helper/src', 1 => __DIR__ . '/..' . '/topthink/think-filesystem/src',
2 => __DIR__ . '/..' . '/topthink/think-orm/src', 2 => __DIR__ . '/..' . '/topthink/think-helper/src',
3 => __DIR__ . '/..' . '/topthink/think-template/src', 3 => __DIR__ . '/..' . '/topthink/think-orm/src',
4 => __DIR__ . '/..' . '/topthink/framework/src/think', 4 => __DIR__ . '/..' . '/topthink/think-template/src',
), ),
'mailer\\' => 'mailer\\' =>
array ( array (

View File

@ -3,7 +3,7 @@
'name' => 'topthink/think', 'name' => 'topthink/think',
'pretty_version' => 'dev-master', 'pretty_version' => 'dev-master',
'version' => 'dev-master', 'version' => 'dev-master',
'reference' => '042bd8eab43a51dd81405639a757e8b07aa84ce6', 'reference' => 'a2ad5cb8bd02b7c4e35edb13a3a18b968e4ae3ae',
'type' => 'project', 'type' => 'project',
'install_path' => __DIR__ . '/../../', 'install_path' => __DIR__ . '/../../',
'aliases' => array(), 'aliases' => array(),
@ -295,7 +295,7 @@
'topthink/think' => array( 'topthink/think' => array(
'pretty_version' => 'dev-master', 'pretty_version' => 'dev-master',
'version' => 'dev-master', 'version' => 'dev-master',
'reference' => '042bd8eab43a51dd81405639a757e8b07aa84ce6', 'reference' => 'a2ad5cb8bd02b7c4e35edb13a3a18b968e4ae3ae',
'type' => 'project', 'type' => 'project',
'install_path' => __DIR__ . '/../../', 'install_path' => __DIR__ . '/../../',
'aliases' => array(), 'aliases' => array(),

2
vendor/services.php vendored
View File

@ -1,5 +1,5 @@
<?php <?php
// This file is automatically generated at:2023-07-17 17:36:46 // This file is automatically generated at:2023-07-18 16:34:37
declare (strict_types = 1); declare (strict_types = 1);
return array ( return array (
0 => 'think\\captcha\\CaptchaService', 0 => 'think\\captcha\\CaptchaService',