用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();
$ret = $docs->AllTitle();
$this->JsonResp(200,$ret,"OK");
}
public function countAction(){
$docs = new Models\Doc();

View File

@ -18,6 +18,12 @@ class NewUi extends Controller
$firstpagedocs = [];
$typedocs = $docModel->getAllTypeDocs();
$titles = $docModel->AllTitle();
$groups = $docModel->getGroups();
$groupstype = $docModel->GetAllGroupType();
echo "<pre>";
echo "</pre>";
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
]);
}
}

View File

@ -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;
}
}

View File

@ -1,28 +1,94 @@
<!DOCTYPE html>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8"/>
<link href="/api/App/Views/blog/css/bootstrap-treeview.css" rel="stylesheet" type="text/css">
<link href="/api/App/Views/blog/css/default.css" rel="stylesheet" type="text/css">
<link href="https://cdn.bootcss.com/bootstrap/3.2.0/css/bootstrap.min.css" rel="stylesheet">
<link rel="stylesheet" href="https://cdn.staticfile.org/twitter-bootstrap/3.3.7/css/bootstrap.min.css">
<script src="https://cdn.staticfile.org/jquery/2.1.1/jquery.min.js"></script>
<script src="https://cdn.staticfile.org/twitter-bootstrap/3.3.7/js/bootstrap.min.js"></script>
</head>
<body style="background: #eee">
<div class="container">
<h1>Bootstrap Tree View</h1>
<br>
<div class="row">
<div class="col-sm-4">
<h2>Default</h2>
<div id="treeview1" class=""></div>
<ul id="myTab" class="nav nav-tabs">
<li class="active">
<a href="#home" data-toggle="tab">
文章
</a>
</li>
<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 class="tab-pane fade" id="ios">
<p>iOS 是一个由苹果公司开发和发布的手机操作系统。最初是于 2007 年首次发布 iPhone、iPod Touch 和 Apple
TV。iOS 派生自 OS X它们共享 Darwin 基础。OS X 操作系统是用在苹果电脑上iOS 是苹果的移动版本。</p>
</div>
</div>
<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 type="text/javascript">
globalposx = 0;
function startRequest()
{
if(globalposx > 250){
$('#grouptab').fadeOut(1000);
}
}
$(function() {
console.log("shit")
var defaultData = [
{
text: 'Parent 1',
@ -74,10 +140,18 @@
tags: ['0']
}
];
$('#treeview1').treeview({
data: defaultData
})});
})
setInterval("startRequest()",1000);
});
$(document).mousemove(function(e){
if(e.pageX < 250){
$('#grouptab').fadeIn(2000);
}
globalposx = e.pageX;
});
</script>
</body>
</html>

View File

@ -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",

View File

@ -10,7 +10,11 @@
<a href="#" id="arrow' + '">{{ key }}</a>
<ul class="subMenu" style="display: none;font-size: 25px;text-align: center;" >
{% 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 %}
</ul>
</li>
@ -27,11 +31,19 @@
<div class="title" style="font-size: 18px;font-weight: bold">
<p style="display: inline;margin-left: 5px;">2019-08-04 </p>
{% 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%}
<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 %}
<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 style="width: 100%;height: 220px;font-size: 14px;margin-top: 10px;" >
{{ doc.content | raw}}

View File

@ -76,9 +76,6 @@ class Router
public function match($url)
{
foreach ($this->routes as $route => $params) {
//echo "<pre>";
//print_r($route);
//echo "</pre>";
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);

View File

@ -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