添加后端渲染博客页面

deploy
a74589669 2019-08-28 20:48:45 +08:00
parent d45de82ad0
commit b055cf6947
4 changed files with 26 additions and 11 deletions

View File

@ -26,10 +26,9 @@ class Blog extends Controller
View::renderTemplate("/blog/basic.html",['docs'=>$docs,'index'=>false]);
}
function articleAction(){
View::renderTemplate("/blog/basic.html",['docs'=>null,'index'=>false]);
}
function jsAction(){
print_r($_SERVER);
}
}

View File

@ -133,6 +133,10 @@
<p style="vertical-align: bottom;font-size: 12px;">read more</p>
</div>
{% endfor %}
{% else %}
{% if title != '' %}
{% endif %}
{% endif %}
</div>
</div>

View File

@ -35,7 +35,6 @@ $(function() {
});
$(document).ready(
function () {
console.log("test");
htmlobj = $.ajax({
method: "POST",
url: "http://127.0.0.1/api/public/Doc/docType",
@ -48,7 +47,6 @@ $(document).ready(
// 获取每种分类
if (data['code'] == 200) {
obj = JSON.parse(data['data']);
console.log(obj);
Object.keys(obj).forEach(function (key) {
//$("#navMenu").style.border = "3px solid green";
$("#navMenu").append('<li id="doc_type_' + key + '"><a href="#" id="arrow' + '">' + obj[key] + '</a></li>');
@ -70,14 +68,29 @@ $(document).ready(
$("#doc_type_" + key).append('<ul class="subMenu" id = "type_id_' + key
+ '" style="display: none"></ul>');
Object.keys(objs).forEach(function (doc_id) {
$("#type_id_" + key).append('<li><a>'+ objs[doc_id].title + '</a></li>');
let rand = parseInt(Math.random() * 10000 %10000);
$("#type_id_" + key).append('<li><a ' + 'id=' + rand + '>'+ objs[doc_id].title + '</a></li>');
console.log(doc_id,objs[doc_id].title);
// 注册回调s
// console.log("#type_id_0 li a #" + rand);
$("#" + rand).on("click",(function () {
$.ajax({
method: "GET",
url: "http://127.0.0.1/api/public/Blog/article?title=" + rand,
async: false,
dataType: "json",
beforeSend: function (xhr) {
},
success:function(data){
console.log(data);
}
});
console.log($("#" + rand).html());
console.log(rand);
}));
})
console.log($("#type_id_0 li a").html());
// 注册回调s
$("#type_id_0 li a").click(function () {
console.log("shit");
})
}
}
}

View File

@ -29,7 +29,6 @@ abstract class Controller
*/
public function __construct($route_params)
{
switch($_SERVER['CONTENT_TYPE']){
case 'application/json':
$this->body = file_get_contents('php://input');