修正一些bug

This commit is contained in:
liyukun 2021-06-27 23:40:14 +08:00
parent 6c8d67387e
commit c440d9561a
9 changed files with 55 additions and 58 deletions

View File

@ -110,10 +110,14 @@ class Category extends AuthController
*/
public function add($pid ='')
{
$systemConfig = cache('systemConfig');
$themeInfoFile = public_path('template'.DIRECTORY_SEPARATOR.$systemConfig['web_template']).'info.json';
$themeInfo = json_decode(file_get_contents($themeInfoFile),true);
$themeList = $themeInfo['category_list'];
$templatePath = system_config('web_template');
$themeInfoFile = public_path('template'.DIRECTORY_SEPARATOR.$templatePath).'info.json';
if (file_exists($themeInfoFile)){
$themeInfo = json_decode(file_get_contents($themeInfoFile),true);
$themeList = $themeInfo['category_list'];
}else{
$themeList = [];
}
$where = Util::postMore([
'name' => '',
'status' => '',
@ -135,10 +139,14 @@ class Category extends AuthController
*/
public function edit(Request $request)
{
$systemConfig = cache('systemConfig');
$themeInfoFile = public_path('template'.DIRECTORY_SEPARATOR.$systemConfig['web_template']).'info.json';
$themeInfo = json_decode(file_get_contents($themeInfoFile),true);
$themeList = $themeInfo['category_list'];
$templatePath = system_config('web_template');
$themeInfoFile = public_path('template'.DIRECTORY_SEPARATOR.$templatePath).'info.json';
if (file_exists($themeInfoFile)){
$themeInfo = json_decode(file_get_contents($themeInfoFile),true);
$themeList = $themeInfo['category_list'];
}else{
$themeList = [];
}
$where = Util::postMore([
'name' => '',
'status' => '',

View File

@ -15,7 +15,7 @@ if (!function_exists('system_config_more'))
{
$systemConfig = cache('systemConfig');
if (empty($systemConfig)){
$systemConfig = \app\admin\model\SystemConfig::getSystemConfigValues();
$systemConfig = \app\common\model\SystemConfig::getSystemConfigValues();
cache('systemConfig',$systemConfig);
}
$data = [];
@ -75,7 +75,7 @@ if (!function_exists('system_config'))
{
$systemConfig = cache('systemConfig');
if (empty($systemConfig)){
$systemConfig = \app\admin\model\SystemConfig::getSystemConfigValues();
$systemConfig = \app\common\model\SystemConfig::getSystemConfigValues();
cache('systemConfig',$systemConfig);
}
return $systemConfig[$formName]??'';

View File

@ -43,8 +43,7 @@ class PvLog extends BaseModel {
$pvData['view'] = 1;
$pvData['date'] = $date_data;
$pvData['time'] = $hour;
$pvData['create_time'] = time();
$this->insertGetId($pvData);
$this->save($pvData);
}
//uv表
$uvLogModel=new UvLogModel();
@ -61,8 +60,7 @@ class PvLog extends BaseModel {
$uvData['ip'] = $ipData;
$uvData['time'] = $hour;
$uvData['date'] = $date_data;
$uvData['create_time'] = time();
$uvLogModel->insertGetId($uvData);
$uvLogModel->save($uvData);
}
}

View File

@ -25,7 +25,6 @@ class UrlLog extends BaseModel {
$dataUrl['pv'] = 1;
$dataUrl['title'] = $title;
$dataUrl['date'] = $date_data;
$dataUrl['create_time'] = time();
$this->insertGetId($dataUrl);
}
}

View File

@ -136,7 +136,6 @@ class Zz extends TagLib{
$where=isset($tag['where'])?$tag['where']:'';
$display=isset($tag['display'])?$tag['display']:1;
$display=$display==1?1:0;
$parse = '<?php ';
$parse .= '$__FUN__ ='."tpl_get_list(\"$orderby\",$pagesize,$typeid,\"$type\",\"$model\",\"$where\",$display);";
$parse .= '$__LIST__ =$__FUN__["lists"];$pager = $__FUN__["model"]->render();';

View File

@ -286,7 +286,7 @@ function tpl_get_prenext($get,$cid=false,$none){
*/
function tpl_get_list($orderby,$pagesize,$cid,$type,$table='article',$where=false,$display=1){
$docmentListModel=Db::name('document')
$documentListModel= (new \app\common\model\Document())
->alias('a')
->join(config('database.prefix').'document_category b','a.category_id=b.id','LEFT')
->join(config('database.prefix')."document_$table c",'a.id=c.id','LEFT')
@ -294,12 +294,9 @@ function tpl_get_list($orderby,$pagesize,$cid,$type,$table='article',$where=fals
->where('a.status',1)
->where('b.status',1)
->field('a.*,b.title as category_title,c.*');
if($display){
$docmentListModel=$docmentListModel->where('a.display',1);
$documentListModel=$documentListModel->where('a.display',1);
}
//判断当前是否搜索页面
if(request()->action()=='search'){
$type='search';
@ -310,58 +307,55 @@ function tpl_get_list($orderby,$pagesize,$cid,$type,$table='article',$where=fals
$dc=get_document_category($cid);
$child=$dc['child'];
if($child){
$docmentListModel=$docmentListModel->where('a.category_id','in',"$cid,$child");
$documentListModel=$documentListModel->where('a.category_id','in',"$cid,$child");
}
else{
$docmentListModel=$docmentListModel->where('a.category_id',$cid);
$documentListModel=$documentListModel->where('a.category_id',$cid);
}
break;
case 'son':
//获取栏目下文章
$docmentListModel=$docmentListModel->where('a.category_id',$cid);
$documentListModel=$documentListModel->where('a.category_id',$cid);
break;
case 'search':
//获取关键字搜索的文章
$kw=input('kw'); //搜索关键词
$tid=input('cid');//文章分类Id
if($kw){
$docmentListModel=$docmentListModel->where('a.title','like',"%$kw%");
$documentListModel=$documentListModel->where('a.title','like',"%$kw%");
}
if($tid){
$docmentListModel=$docmentListModel->where('a.category_id',$tid);
$documentListModel=$documentListModel->where('a.category_id',$tid);
}
break;
case 'where':
//根据自定义条件获取文章where语句
$docmentListModel=$docmentListModel->where($where);
$documentListModel=$documentListModel->where($where);
break;
case 'tag':
//读取指定tag的文章
$docmentListModel=$docmentListModel->where('a.keywords','like',"%$where%");
$documentListModel=$documentListModel->where('a.keywords','like',"%$where%");
break;
}
$docmentListModel=$docmentListModel->order($orderby);
$documentListModel=$documentListModel->order($orderby);
//获取当前请求的请求参数,以确定分页是否要带上这些请求参数
$query=request()->query();
if($query){
$docmentListModel=$docmentListModel->paginate($pagesize,false,['query' => getRouteQuery()]);
$documentListModel=$documentListModel->paginate($pagesize,false,['query' => getRouteQuery()]);
}
else{
$docmentListModel=$docmentListModel->paginate($pagesize);
$documentListModel=$documentListModel->paginate($pagesize);
}
$lists=[];
foreach ($docmentListModel as $key=>$item){
foreach ($documentListModel as $key=>$item){
//生成文章url
$item['url']=aurl($item);
$lists[$key]=$item;
}
$re=[
'model'=>$docmentListModel,
'model'=>$documentListModel,
'lists'=>$lists
];
return $re;
}
@ -439,7 +433,7 @@ function tpl_get_article($id,$table){
*/
function tpl_get_article_list($cid,$row,$orderby,$table='article',$type='son',$where=false,$display=1,$ids=''){
$docmentListModel=Db::name('document')
$documentListModel=Db::name('document')
->alias('a')
->join(config('database.prefix').'document_category b','a.category_id=b.id','LEFT')
->join(config('database.prefix')."document_$table c",'a.id=c.id','RIGHT')
@ -448,7 +442,7 @@ function tpl_get_article_list($cid,$row,$orderby,$table='article',$type='son',$w
->field('a.*,b.title as category_title,c.*');
if($display){
$docmentListModel=$docmentListModel->where('a.display',1);
$documentListModel=$documentListModel->where('a.display',1);
}
switch ($type){
@ -457,33 +451,33 @@ function tpl_get_article_list($cid,$row,$orderby,$table='article',$type='son',$w
$dc=get_document_category($cid);
$child=$dc['child'];
if($child){
$docmentListModel=$docmentListModel->where('a.category_id','in',"$cid,$child");
$documentListModel=$documentListModel->where('a.category_id','in',"$cid,$child");
}
else{
$docmentListModel=$docmentListModel->where('a.category_id',$cid);
$documentListModel=$documentListModel->where('a.category_id',$cid);
}
break;
case 'son':
//获取栏目下文章
$docmentListModel=$docmentListModel->where('a.category_id',$cid);
$documentListModel=$documentListModel->where('a.category_id',$cid);
break;
case 'where':
//根据自定义条件获取文章where语句
$docmentListModel=$docmentListModel->where($where);
$documentListModel=$documentListModel->where($where);
break;
case 'ids':
//读取指定id的文章
$docmentListModel=$docmentListModel->where('a.id','in',$ids);
$documentListModel=$documentListModel->where('a.id','in',$ids);
break;
case 'tag':
//读取指定tag的文章
$docmentListModel=$docmentListModel->where('a.keywords','like',"%$where%");
$documentListModel=$documentListModel->where('a.keywords','like',"%$where%");
break;
}
$docmentListModel=$docmentListModel->order($orderby)->select();
$documentListModel=$documentListModel->order($orderby)->select();
$lists=[];
foreach ($docmentListModel as $key=>$item){
foreach ($documentListModel as $key=>$item){
//生成文章url
$item['url']=aurl($item);
$lists[$key]=$item;

View File

@ -5,7 +5,6 @@ namespace app\index\controller;
use app\BaseController;
use app\common\model\PvLog;
use app\common\model\UrlLog;
use app\common\model\UvLog;
use app\common\model\SystemConfig;
/**
@ -32,15 +31,14 @@ class Base extends BaseController
}
//判断后台统计配置是否开启 1 开启
if ($systemConfig["web_statistics"] == 1) {
//增加pv信息
(new PvLog())->addLog();
//增加uv信息
(new UvLog())->addLog();
//pv表 zz_pv_log 栏目存在 点击进入页面后
$pvLogModel=new PvLog();
$pvLogModel->set_view();
}
//判断是否开启了伪静态
if ($systemConfig['web_rewrite']) {
if ($systemConfig['web_rewrite']=='0') {
$this->request->setRoot('/?s=');
} elseif(web_config('WEB_REWRITE')=='1') {
} elseif($systemConfig['web_rewrite']=='1') {
$this->request->setRoot('/');
} else {
$this->request->setRoot('/index.php');
@ -55,6 +53,9 @@ class Base extends BaseController
*/
protected function urlrecord($title)
{
(new UrlLog())->addLog($title);
$urlLogModel=new UrlLog();
//获取url
$urlInfo = $this->request->url(true);
$urlLogModel->set_url($title,$urlInfo);
}
}

View File

@ -22,8 +22,6 @@ return [
'app_express' => true,
// 默认时区
'default_timezone' => 'Asia/Shanghai',
// 快捷访问
'app_express' => true,
// 自动多应用模式
'auto_multi_app' => true,
// 应用映射(自动多应用模式有效)

View File

@ -57,7 +57,7 @@
</style>
<div class="index-top-postcard-plane">
<div class="index-top-postcard-body">
{zz:list orderby="create_time desc"}
{zz:list orderby="create_time desc" type="where"}
<div class="index-top-postcard-item">
<div class="index-top-postcard-main">
<div class="post-item-thumbnail">
@ -81,7 +81,7 @@
</div>
</div>
<ul class="post-list">
{zz:list orderby="create_time desc"}
{zz:list orderby="create_time desc" type="where"}
<li class="post-item ">
<div class="post-item-container">
<div class="post-item-thumbnail">