diff --git a/App/Controllers/ArticleTree.php b/App/Controllers/ArticleTree.php index 1cd35e3..2cac629 100644 --- a/App/Controllers/ArticleTree.php +++ b/App/Controllers/ArticleTree.php @@ -108,7 +108,8 @@ class ArticleTree extends Controller $redis->connect('127.0.0.1', 6379); //查看服务是否运行 $commentModel = new Models\DocComment(); - $vertime = urldecode((string)$this->params[1]); + if(sizeof($this->params) > 1) + $vertime = urldecode((string)$this->params[1]); $doccoment = $commentModel->DocComments((int)$this->params[0]); if(sizeof($this->params) > 0){ @@ -121,25 +122,28 @@ class ArticleTree extends Controller $firstpagedocs = []; $child_docs = $docModel->getChildrenDocs($this->params[0]); $doc = []; - if($vertime != ""){ - $doc = $docModel->docHistoryTree((int)$this->params[0],$vertime); - $doc = array_merge($doc,$child_docs); - + if(sizeof($this->params) > 1){ + if(\strstr($vertime,"20") == 0){ + + $doc = $docModel->docHistoryTree((int)$this->params[0],$vertime); + $doc = array_merge($doc,$child_docs); + + }else{ + $doc = $docModel->docTree((int)$this->params[0]); + $doc = array_merge($doc,$child_docs); + } }else{ $doc = $docModel->docTree((int)$this->params[0]); $doc = array_merge($doc,$child_docs); } + $top5 = $docModel->top5Doc(); $markdowntoc = new \ParsedownToC(); $doc[0]['content'] = $markdowntoc->body($doc[0]['content']); $doc[0]['toc'] = $markdowntoc->contentsList(); // $doc_history = $docModel->doc_history((int)$this->params[0]); - if($vertime == ""){ - - }else{ - } $markdown = new Parsedown; foreach ($doc as $key => $value) { diff --git a/App/Models/Doc.php b/App/Models/Doc.php index c7bc0a2..13bc6a2 100644 --- a/App/Models/Doc.php +++ b/App/Models/Doc.php @@ -201,7 +201,7 @@ class Doc extends Model 'name' => $value['title'], 'id' =>$value['id'], 'isParent'=> false, - 'url' => \App\Config::Url() . "ArticleTree/article/" . $value['id']."/".$value['title'], + 'url' => \App\Config::Url() . "ArticleTree/article/" . $value['id'], 'father' => (int)$value['father'], 'level' => $value['level'] ); @@ -211,7 +211,7 @@ class Doc extends Model 'name' => $value['title'], 'id' =>$value['id'], 'isParent'=> false, - 'url' => \App\Config::Url() . "ArticleTree/article/" . $value['id']."/".$value['title'], + 'url' => \App\Config::Url() . "ArticleTree/article/" . $value['id'], 'father' => (int)$value['father'], 'level' => $value['level'], 'open' => true @@ -220,7 +220,6 @@ class Doc extends Model if($opendocid == $value['father']) $tmp['open'] = true; $mapforbuildtree[$value['id']] = $tmp; - } for($i = $max_level;$i >= 0;$i --){ foreach ($doc_all as $key => $value){ diff --git a/App/Views/blog/article.html b/App/Views/blog/article.html index 54ebaee..91ae762 100644 --- a/App/Views/blog/article.html +++ b/App/Views/blog/article.html @@ -82,7 +82,7 @@ 最新文章 {% for doc in topdoc %} - {{doc.title}} + {{doc.title}} {% endfor %} @@ -217,7 +217,7 @@ function expandNode(e) {