From dd242b773e4b538495ead70b2e4527747f3e33c5 Mon Sep 17 00:00:00 2001 From: "DESKTOP-4RNDQIC\\29019" <290198252@qq.com> Date: Sun, 12 Jul 2020 00:51:00 +0800 Subject: [PATCH] =?UTF-8?q?=E7=94=A8bootstrap+jQuery=E9=87=8D=E6=9E=84?= =?UTF-8?q?=E5=89=8D=E7=AB=AF=E7=95=8C=E9=9D=A2=E7=AC=A6=E5=90=88=E6=9C=AC?= =?UTF-8?q?=E4=B8=96=E7=BA=AA=E7=9A=84=E9=A3=8E=E6=A0=BC?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- App/Controllers/Doc.php | 1 - App/Controllers/NewUi.php | 10 +++ App/Models/Doc.php | 31 +++++++- App/Views/blog/index.html | 102 +++++++++++++++++++++++---- App/Views/blog/js/scripts.js | 3 + App/Views/blog/template/article.html | 20 ++++-- Core/Router.php | 5 +- public/index.php | 4 ++ 8 files changed, 152 insertions(+), 24 deletions(-) diff --git a/App/Controllers/Doc.php b/App/Controllers/Doc.php index 0278b13..7249303 100644 --- a/App/Controllers/Doc.php +++ b/App/Controllers/Doc.php @@ -32,7 +32,6 @@ class Doc extends \Core\Controller $docs = new Models\Doc(); $ret = $docs->AllTitle(); $this->JsonResp(200,$ret,"OK"); - } public function countAction(){ $docs = new Models\Doc(); diff --git a/App/Controllers/NewUi.php b/App/Controllers/NewUi.php index 91581b9..7441a84 100644 --- a/App/Controllers/NewUi.php +++ b/App/Controllers/NewUi.php @@ -18,6 +18,12 @@ class NewUi extends Controller $firstpagedocs = []; $typedocs = $docModel->getAllTypeDocs(); $titles = $docModel->AllTitle(); + $groups = $docModel->getGroups(); + $groupstype = $docModel->GetAllGroupType(); + echo "
";
+        echo  "
"; + + foreach ($fisrtpage as $key => $value) { $obj['title'] = $value['title']; $obj['id'] = $value['id']; @@ -38,6 +44,8 @@ class NewUi extends Controller 'debug'=>true, "typedocs" => $typedocs, "alltitle" => $titles, + "groups" => $groups, + "group_types"=>$groupstype ]); else{ View::renderTemplate("/blog/index.html",[ @@ -48,6 +56,8 @@ class NewUi extends Controller 'debug'=>false, "typedocs" => $typedocs, "alltitle" => $titles, + "groups" => $groups, + "group_types"=>$groupstype ]); } } diff --git a/App/Models/Doc.php b/App/Models/Doc.php index dc9bfbf..d8273db 100644 --- a/App/Models/Doc.php +++ b/App/Models/Doc.php @@ -32,14 +32,26 @@ class Doc extends Model $result = $stmt->fetchAll(PDO::FETCH_UNIQUE); return $result; } + public function getGroupType($group){ + $db = static::getDB(); + $stmt = $db->query('select * from doc_type where doc_type.group= '.strval($group)); + $result = $stmt->fetchAll(PDO::FETCH_UNIQUE); + return $result; + } public function getTypes(){ $db = static::getDB(); - $stmt = $db->query('select * from doc_type'); + $stmt = $db->query('select id,type_name from doc_type'); $result = $stmt->fetchAll(PDO::FETCH_KEY_PAIR); return $result; } + public function getGroups(){ + $db = static::getDB(); + $stmt = $db->query('select * from doc_group'); + $result = $stmt->fetchAll(PDO::FETCH_KEY_PAIR); + return $result; + } public function docs($id){ $result = []; if(is_integer($id)){ @@ -102,6 +114,7 @@ class Doc extends Model public function getAllTypeDocs(){ $typedocs = []; $doctypes = $this->getTypes(); + foreach ($doctypes as $key => $value){ $val = []; $typedoc = $this->getTypeDocs($key); @@ -111,5 +124,21 @@ class Doc extends Model } return $typedocs; } + public function getAllDocGroup(){ + $groups = $this->getGroups(); + return $groups; + } + public function GetAllGroupType(){ + $grouptype = []; + $groups = $this->getGroups(); + foreach ($groups as $key => $value){ + $val = []; + $typedoc = $this->getGroupType($key); + $val["arr"] = $typedoc; + $val["key"] = $key; + $grouptype[$key] = $val; + } + return $grouptype; + } } diff --git a/App/Views/blog/index.html b/App/Views/blog/index.html index 0a59497..a13493b 100644 --- a/App/Views/blog/index.html +++ b/App/Views/blog/index.html @@ -1,28 +1,94 @@ - - - - + + + -
-

Bootstrap Tree View

-
-
-
-

Default

-
+ +
+
+
+
+
+ +
+
+
+ {% for key,group_type in group_types %} +
+ +
+ {% endfor %} +
+
+
+
+ {% for key,typedoc in typedocs %} +
+ +
+ {% endfor %} +
+
+
+
+
+

iOS 是一个由苹果公司开发和发布的手机操作系统。最初是于 2007 年首次发布 iPhone、iPod Touch 和 Apple + TV。iOS 派生自 OS X,它们共享 Darwin 基础。OS X 操作系统是用在苹果电脑上,iOS 是苹果的移动版本。

+
+
+ diff --git a/App/Views/blog/js/scripts.js b/App/Views/blog/js/scripts.js index 6062007..12b8e82 100644 --- a/App/Views/blog/js/scripts.js +++ b/App/Views/blog/js/scripts.js @@ -51,6 +51,9 @@ $(document).ready( console.log(baseUrl); baseUrl = "https://www.testingcloud.club/wapi/"; } + if(domain == "192.168.3.100"){ + var baseUrl = 'http://192.168.3.100/api/public/'; + } $.ajax({ method: "POST", url: baseUrl + "Doc/count", diff --git a/App/Views/blog/template/article.html b/App/Views/blog/template/article.html index d15993b..ab3fe4f 100644 --- a/App/Views/blog/template/article.html +++ b/App/Views/blog/template/article.html @@ -10,7 +10,11 @@ {{ key }} @@ -27,11 +31,19 @@

2019-08-04

{% if debug == true %} -

{{doc.title}}

+

+ + {{doc.title}} + +

{%else%} -

{{doc.title}}

+

+ + {{doc.title}} + +

{% endif %} -

管理員

+

管理员

{{ doc.content | raw}} diff --git a/Core/Router.php b/Core/Router.php index a021f2c..5e9c312 100644 --- a/Core/Router.php +++ b/Core/Router.php @@ -76,9 +76,6 @@ class Router public function match($url) { foreach ($this->routes as $route => $params) { - //echo "
";
-            //print_r($route);
-            //echo "
"; if (preg_match($route, $url, $matches)) { // Get named capture group values foreach ($matches as $key => $match) { @@ -92,7 +89,6 @@ class Router } return false; } - /** * Get the currently matched parameters * @@ -115,6 +111,7 @@ class Router { $url = $this->removeQueryStringVariables($url); $url = str_replace($this->prefix,"",$url); + if ($this->match($url)) { $controller = $this->params['controller']; $controller = $this->convertToStudlyCaps($controller); diff --git a/public/index.php b/public/index.php index 8d6621a..1120f65 100644 --- a/public/index.php +++ b/public/index.php @@ -30,6 +30,10 @@ if($_SERVER['HTTP_HOST'] == '127.0.0.1'){ else{ $router->AddPrefix(\App\Config::ROUTE_PREFIX); } +if($_SERVER['HTTP_HOST'] == '192.168.3.100'){ + $router->AddPrefix(\App\Config::ROUTE_PREFIX_DEV); + \App\Config::$DEBUG = true; +} try{ //for prefight request