精简docs的json文件提升加载速度
This commit is contained in:
parent
ea1ae75251
commit
6e15cc8437
13
Gmeek.py
13
Gmeek.py
@ -315,8 +315,17 @@ listFile.write(json.dumps(blog.blogBase))
|
|||||||
listFile.close()
|
listFile.close()
|
||||||
# shutil.copy("blogBase.json",blog.root_dir)
|
# shutil.copy("blogBase.json",blog.root_dir)
|
||||||
|
|
||||||
blog.blogBase["postListJson"]=dict(sorted(self.blogBase["postListJson"].items(),key=lambda x:x[1]["createdAt"],reverse=True))#使列表由时间排序
|
blog.blogBase["postListJson"]=dict(sorted(blog.blogBase["postListJson"].items(),key=lambda x:x[1]["createdAt"],reverse=True))#使列表由时间排序
|
||||||
|
for i in blog.blogBase["postListJson"]:
|
||||||
|
del blog.blogBase["postListJson"][i]["description"]
|
||||||
|
del blog.blogBase["postListJson"][i]["postSourceUrl"]
|
||||||
|
del blog.blogBase["postListJson"][i]["htmlDir"]
|
||||||
|
del blog.blogBase["postListJson"][i]["createdAt"]
|
||||||
|
del blog.blogBase["postListJson"][i]["script"]
|
||||||
|
del blog.blogBase["postListJson"][i]["style"]
|
||||||
|
del blog.blogBase["postListJson"][i]["top"]
|
||||||
|
|
||||||
docListFile=open(blog.root_dir+"postList.json","w")
|
docListFile=open(blog.root_dir+"postList.json","w")
|
||||||
docListFile.write(json.dumps(blog.blogBase))
|
docListFile.write(json.dumps(blog.blogBase["postListJson"]))
|
||||||
docListFile.close()
|
docListFile.close()
|
||||||
######################################################################################
|
######################################################################################
|
||||||
|
|||||||
@ -92,22 +92,22 @@ function showList(){
|
|||||||
showLabels.setAttribute("onclick","javascript:updateShowTag('All');");
|
showLabels.setAttribute("onclick","javascript:updateShowTag('All');");
|
||||||
tagLable.appendChild(showLabels);
|
tagLable.appendChild(showLabels);
|
||||||
}
|
}
|
||||||
for(i in jsonData["postListJson"]){
|
for(i in jsonData){
|
||||||
if(!(tagList.includes(jsonData["postListJson"][i]['label']))){
|
if(!(tagList.includes(jsonData[i]['label']))){
|
||||||
tagList.push(jsonData["postListJson"][i]['label']);
|
tagList.push(jsonData[i]['label']);
|
||||||
let showLabels=document.createElement("button");
|
let showLabels=document.createElement("button");
|
||||||
showLabels.setAttribute("class","Label");
|
showLabels.setAttribute("class","Label");
|
||||||
showLabels.setAttribute("style","background-color:"+jsonData["postListJson"][i]['labelColor']);
|
showLabels.setAttribute("style","background-color:"+jsonData[i]['labelColor']);
|
||||||
showLabels.innerHTML=jsonData["postListJson"][i]['label'];
|
showLabels.innerHTML=jsonData[i]['label'];
|
||||||
showLabels.setAttribute("onclick","javascript:updateShowTag('"+jsonData["postListJson"][i]['label']+"');");
|
showLabels.setAttribute("onclick","javascript:updateShowTag('"+jsonData[i]['label']+"');");
|
||||||
tagLable.appendChild(showLabels);
|
tagLable.appendChild(showLabels);
|
||||||
}
|
}
|
||||||
|
|
||||||
let div=document.createElement("div");
|
let div=document.createElement("div");
|
||||||
div.setAttribute("class","lists "+jsonData["postListJson"][i]['label']);
|
div.setAttribute("class","lists "+jsonData[i]['label']);
|
||||||
let item=document.createElement("a");
|
let item=document.createElement("a");
|
||||||
item.setAttribute("class","SideNav-item d-flex flex-items-center flex-justify-between");
|
item.setAttribute("class","SideNav-item d-flex flex-items-center flex-justify-between");
|
||||||
item.setAttribute("href",jsonData["postListJson"][i]['postUrl']);
|
item.setAttribute("href",jsonData[i]['postUrl']);
|
||||||
|
|
||||||
let center=document.createElement("div");
|
let center=document.createElement("div");
|
||||||
center.setAttribute("class","d-flex flex-items-center");
|
center.setAttribute("class","d-flex flex-items-center");
|
||||||
@ -122,7 +122,7 @@ function showList(){
|
|||||||
|
|
||||||
let title=document.createElement("span");
|
let title=document.createElement("span");
|
||||||
title.setAttribute("class","listTitle");
|
title.setAttribute("class","listTitle");
|
||||||
title.innerHTML=jsonData["postListJson"][i]['postTitle'];
|
title.innerHTML=jsonData[i]['postTitle'];
|
||||||
center.appendChild(svg);
|
center.appendChild(svg);
|
||||||
center.appendChild(title);
|
center.appendChild(title);
|
||||||
|
|
||||||
@ -130,13 +130,13 @@ function showList(){
|
|||||||
listLabels.setAttribute("class","listLabels");
|
listLabels.setAttribute("class","listLabels");
|
||||||
let LabelName=document.createElement("span");
|
let LabelName=document.createElement("span");
|
||||||
LabelName.setAttribute("class","Label LabelName");
|
LabelName.setAttribute("class","Label LabelName");
|
||||||
LabelName.setAttribute("style","background-color:"+jsonData["postListJson"][i]['labelColor']);
|
LabelName.setAttribute("style","background-color:"+jsonData[i]['labelColor']);
|
||||||
LabelName.innerHTML=jsonData["postListJson"][i]['label'];
|
LabelName.innerHTML=jsonData[i]['label'];
|
||||||
listLabels.appendChild(LabelName);
|
listLabels.appendChild(LabelName);
|
||||||
let LabelTime=document.createElement("span");
|
let LabelTime=document.createElement("span");
|
||||||
LabelTime.setAttribute("class","Label LabelTime");
|
LabelTime.setAttribute("class","Label LabelTime");
|
||||||
LabelTime.setAttribute("style","background-color:"+jsonData["postListJson"][i]['dateLabelColor']);
|
LabelTime.setAttribute("style","background-color:"+jsonData[i]['dateLabelColor']);
|
||||||
LabelTime.innerHTML=jsonData["postListJson"][i]['createdDate'];
|
LabelTime.innerHTML=jsonData[i]['createdDate'];
|
||||||
listLabels.appendChild(LabelTime);
|
listLabels.appendChild(LabelTime);
|
||||||
|
|
||||||
item.appendChild(center);
|
item.appendChild(center);
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user