用bootstrap+jQuery重构前端界面符合本世纪的风格

deploy
DESKTOP-4RNDQIC\29019 2020-07-12 00:51:00 +08:00
parent bac3e15bc1
commit dd242b773e
8 changed files with 152 additions and 24 deletions

View File

@ -32,7 +32,6 @@ class Doc extends \Core\Controller
$docs = new Models\Doc(); $docs = new Models\Doc();
$ret = $docs->AllTitle(); $ret = $docs->AllTitle();
$this->JsonResp(200,$ret,"OK"); $this->JsonResp(200,$ret,"OK");
} }
public function countAction(){ public function countAction(){
$docs = new Models\Doc(); $docs = new Models\Doc();

View File

@ -18,6 +18,12 @@ class NewUi extends Controller
$firstpagedocs = []; $firstpagedocs = [];
$typedocs = $docModel->getAllTypeDocs(); $typedocs = $docModel->getAllTypeDocs();
$titles = $docModel->AllTitle(); $titles = $docModel->AllTitle();
$groups = $docModel->getGroups();
$groupstype = $docModel->GetAllGroupType();
echo "<pre>";
echo "</pre>";
foreach ($fisrtpage as $key => $value) { foreach ($fisrtpage as $key => $value) {
$obj['title'] = $value['title']; $obj['title'] = $value['title'];
$obj['id'] = $value['id']; $obj['id'] = $value['id'];
@ -38,6 +44,8 @@ class NewUi extends Controller
'debug'=>true, 'debug'=>true,
"typedocs" => $typedocs, "typedocs" => $typedocs,
"alltitle" => $titles, "alltitle" => $titles,
"groups" => $groups,
"group_types"=>$groupstype
]); ]);
else{ else{
View::renderTemplate("/blog/index.html",[ View::renderTemplate("/blog/index.html",[
@ -48,6 +56,8 @@ class NewUi extends Controller
'debug'=>false, 'debug'=>false,
"typedocs" => $typedocs, "typedocs" => $typedocs,
"alltitle" => $titles, "alltitle" => $titles,
"groups" => $groups,
"group_types"=>$groupstype
]); ]);
} }
} }

View File

@ -32,14 +32,26 @@ class Doc extends Model
$result = $stmt->fetchAll(PDO::FETCH_UNIQUE); $result = $stmt->fetchAll(PDO::FETCH_UNIQUE);
return $result; 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(){ public function getTypes(){
$db = static::getDB(); $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); $result = $stmt->fetchAll(PDO::FETCH_KEY_PAIR);
return $result; 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){ public function docs($id){
$result = []; $result = [];
if(is_integer($id)){ if(is_integer($id)){
@ -102,6 +114,7 @@ class Doc extends Model
public function getAllTypeDocs(){ public function getAllTypeDocs(){
$typedocs = []; $typedocs = [];
$doctypes = $this->getTypes(); $doctypes = $this->getTypes();
foreach ($doctypes as $key => $value){ foreach ($doctypes as $key => $value){
$val = []; $val = [];
$typedoc = $this->getTypeDocs($key); $typedoc = $this->getTypeDocs($key);
@ -111,5 +124,21 @@ class Doc extends Model
} }
return $typedocs; 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;
}
} }

View File

@ -1,28 +1,94 @@
<!DOCTYPE html> <!DOCTYPE html>
<html> <html>
<head> <head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8"/> <link rel="stylesheet" href="https://cdn.staticfile.org/twitter-bootstrap/3.3.7/css/bootstrap.min.css">
<link href="/api/App/Views/blog/css/bootstrap-treeview.css" rel="stylesheet" type="text/css"> <script src="https://cdn.staticfile.org/jquery/2.1.1/jquery.min.js"></script>
<link href="/api/App/Views/blog/css/default.css" rel="stylesheet" type="text/css"> <script src="https://cdn.staticfile.org/twitter-bootstrap/3.3.7/js/bootstrap.min.js"></script>
<link href="https://cdn.bootcss.com/bootstrap/3.2.0/css/bootstrap.min.css" rel="stylesheet">
</head> </head>
<body style="background: #eee"> <body style="background: #eee">
<div class="container"> <ul id="myTab" class="nav nav-tabs">
<h1>Bootstrap Tree View</h1> <li class="active">
<br> <a href="#home" data-toggle="tab">
<div class="row"> 文章
<div class="col-sm-4"> </a>
<h2>Default</h2> </li>
<div id="treeview1" class=""></div> <li>
<a href="#ios" data-toggle="tab">
备忘录
</a>
</li>
</ul>
<div id="myTabContent" class="tab-content">
<div class="tab-pane fade in active" id="home">
<div class="container" style="padding: 5px; margin: 0px">
<div class="row">
<div id="grouptab" class="col-md-1" style="background: #bbbbbb; text-align: center;padding: 10px;">
<ul class="nav nav-tabs" style="font-size: 12px;">
{% for key,group in groups %}
<li >
<a href="#group_key_{{key}}" data-toggle="tab">
{{group}}
</a>
</li>
{% endfor %}
</ul>
</div>
<div id="doctype" class="col-md-2" style="background: #d4ccb0;padding: 0px;">
<div id="grouptabContent" class="tab-content">
{% for key,group_type in group_types %}
<div id="group_key_{{key}}" class="tab-pane" style="background:#d4ccb0;" >
<ul class="nav nav-tabs">
{% for keys,types in group_type.arr %}
<li style="width: 100%; background:#d4ccb0;">
<a style="background:#d4ccb0;" href="#doc_type_{{ keys }}" data-toggle="tab">
{{ keys }} {{types.type_name}}
</a>
</li>
{% endfor %}
</ul>
</div>
{% endfor %}
</div>
</div>
<div class="col-md-2" style="padding: 0px;" >
<div id="typedocContent" class="tab-content">
{% for key,typedoc in typedocs %}
<div id="doc_type_{{typedoc.key}}" class="tab-pane" style="background:#d4ccb0; padding: 0px;" >
<ul class="nav nav-tabs">
{% for docid,doc in typedoc.arr %}
<li class="active" style="width: 100%; background:#d4ccb0;">
<a style="background:#d4ccb0;">
{{doc.title}}
</a></li>
{% endfor %}
</ul>
</div>
{% endfor %}
</div>
</div>
</div>
</div> </div>
</div> </div>
<div class="tab-pane fade" id="ios">
<p>iOS 是一个由苹果公司开发和发布的手机操作系统。最初是于 2007 年首次发布 iPhone、iPod Touch 和 Apple
TV。iOS 派生自 OS X它们共享 Darwin 基础。OS X 操作系统是用在苹果电脑上iOS 是苹果的移动版本。</p>
</div>
</div> </div>
<script src="/api/App/Views/blog/js//jquery-2.1.0.min.js"></script> <script src="/api/App/Views/blog/js//jquery-2.1.0.min.js"></script>
<script src="/api/App/Views/blog/js//bootstrap-treeview.js"></script> <script src="/api/App/Views/blog/js//bootstrap-treeview.js"></script>
<script type="text/javascript"> <script type="text/javascript">
globalposx = 0;
function startRequest()
{
if(globalposx > 250){
$('#grouptab').fadeOut(1000);
}
}
$(function() { $(function() {
console.log("shit")
var defaultData = [ var defaultData = [
{ {
text: 'Parent 1', text: 'Parent 1',
@ -74,10 +140,18 @@
tags: ['0'] tags: ['0']
} }
]; ];
$('#treeview1').treeview({ $('#treeview1').treeview({
data: defaultData data: defaultData
})}); })
setInterval("startRequest()",1000);
});
$(document).mousemove(function(e){
if(e.pageX < 250){
$('#grouptab').fadeIn(2000);
}
globalposx = e.pageX;
});
</script> </script>
</body> </body>
</html> </html>

View File

@ -51,6 +51,9 @@ $(document).ready(
console.log(baseUrl); console.log(baseUrl);
baseUrl = "https://www.testingcloud.club/wapi/"; baseUrl = "https://www.testingcloud.club/wapi/";
} }
if(domain == "192.168.3.100"){
var baseUrl = 'http://192.168.3.100/api/public/';
}
$.ajax({ $.ajax({
method: "POST", method: "POST",
url: baseUrl + "Doc/count", url: baseUrl + "Doc/count",

View File

@ -10,7 +10,11 @@
<a href="#" id="arrow' + '">{{ key }}</a> <a href="#" id="arrow' + '">{{ key }}</a>
<ul class="subMenu" style="display: none;font-size: 25px;text-align: center;" > <ul class="subMenu" style="display: none;font-size: 25px;text-align: center;" >
{% for doc in docs.arr %} {% for doc in docs.arr %}
<li><a href="https://www.testingcloud.club/wapi/Blog/article?title={{doc.title}}&type={{ docs.key }}"> {{ doc.title }}</a></li> <li>
<a href="https://www.testingcloud.club/wapi/Blog/article?title={{doc.title}}&type={{ docs.key }}">
{{ doc.title }}
</a>
</li>
{% endfor %} {% endfor %}
</ul> </ul>
</li> </li>
@ -27,11 +31,19 @@
<div class="title" style="font-size: 18px;font-weight: bold"> <div class="title" style="font-size: 18px;font-weight: bold">
<p style="display: inline;margin-left: 5px;">2019-08-04 </p> <p style="display: inline;margin-left: 5px;">2019-08-04 </p>
{% if debug == true %} {% if debug == true %}
<p style="display: inline;margin-left: 5px;"><a href="/api/public/Blog/article?title={{doc.title}}&type={{doc.type}}">{{doc.title}}</a></p> <p style="display: inline;margin-left: 5px;">
<a href="/api/public/Blog/article?title={{doc.title}}&type={{doc.type}}">
{{doc.title}}
</a>
</p>
{%else%} {%else%}
<p style="display: inline;margin-left: 5px;"><a href="/wapi/Blog/article?title={{doc.title}}&type={{doc.type}}">{{doc.title}}</a></p> <p style="display: inline;margin-left: 5px;">
<a href="/wapi/Blog/article?title={{doc.title}}&type={{doc.type}}">
{{doc.title}}
</a>
</p>
{% endif %} {% endif %}
<p style="display: inline;margin:0px;float: right; margin-right: 20px">管理員</p> <p style="display: inline;margin:0px;float: right; margin-right: 20px">管理</p>
</div> </div>
<div style="width: 100%;height: 220px;font-size: 14px;margin-top: 10px;" > <div style="width: 100%;height: 220px;font-size: 14px;margin-top: 10px;" >
{{ doc.content | raw}} {{ doc.content | raw}}

View File

@ -76,9 +76,6 @@ class Router
public function match($url) public function match($url)
{ {
foreach ($this->routes as $route => $params) { foreach ($this->routes as $route => $params) {
//echo "<pre>";
//print_r($route);
//echo "</pre>";
if (preg_match($route, $url, $matches)) { if (preg_match($route, $url, $matches)) {
// Get named capture group values // Get named capture group values
foreach ($matches as $key => $match) { foreach ($matches as $key => $match) {
@ -92,7 +89,6 @@ class Router
} }
return false; return false;
} }
/** /**
* Get the currently matched parameters * Get the currently matched parameters
* *
@ -115,6 +111,7 @@ class Router
{ {
$url = $this->removeQueryStringVariables($url); $url = $this->removeQueryStringVariables($url);
$url = str_replace($this->prefix,"",$url); $url = str_replace($this->prefix,"",$url);
if ($this->match($url)) { if ($this->match($url)) {
$controller = $this->params['controller']; $controller = $this->params['controller'];
$controller = $this->convertToStudlyCaps($controller); $controller = $this->convertToStudlyCaps($controller);

View File

@ -30,6 +30,10 @@ if($_SERVER['HTTP_HOST'] == '127.0.0.1'){
else{ else{
$router->AddPrefix(\App\Config::ROUTE_PREFIX); $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{ try{
//for prefight request //for prefight request