config配置文件精简,添加配置Theme参数
This commit is contained in:
parent
369543e155
commit
c4561b6a74
@ -12,14 +12,7 @@
|
||||
"homeUrl":"http://blog.meekdai.com",
|
||||
"avatarUrl":"http://meekdai.com/avatar.jpg",
|
||||
"faviconUrl":"http://meekdai.com/favicon.ico",
|
||||
"email":"meekdai@163.com",
|
||||
"startSite":"02/16/2015",
|
||||
"filingNum":"浙ICP备20023628号",
|
||||
"onePageListNum":15,
|
||||
"singlePage":["link","about"],
|
||||
"commentLabelColor":"#006b75",
|
||||
"yearColorList":["#bc4c00", "#0969da", "#1f883d", "#A333D0"],
|
||||
"i18n":"CN",
|
||||
"GMEEK_VERSION":"v2.3"
|
||||
}
|
||||
```
|
||||
|
||||
22
Gmeek.py
22
Gmeek.py
@ -43,18 +43,9 @@ class GMEEK():
|
||||
self.labelColorDict=json.loads('{}')
|
||||
for label in self.repo.get_labels():
|
||||
self.labelColorDict[label.name]='#'+label.color
|
||||
|
||||
print(self.labelColorDict)
|
||||
|
||||
config=json.loads(open('config.json', 'r', encoding='utf-8').read())
|
||||
self.blogBase=config.copy()
|
||||
self.blogBase["postListJson"]=json.loads('{}')
|
||||
self.blogBase["singeListJson"]=json.loads('{}')
|
||||
|
||||
if self.blogBase["i18n"]=="CN":
|
||||
self.i18n=i18nCN
|
||||
else:
|
||||
self.i18n=i18n
|
||||
self.defaultConfig()
|
||||
|
||||
def cleanFile(self):
|
||||
if os.path.exists(self.backup_dir):
|
||||
@ -67,6 +58,17 @@ class GMEEK():
|
||||
os.mkdir(self.root_dir)
|
||||
os.mkdir(self.post_dir)
|
||||
|
||||
def defaultConfig(self):
|
||||
dconfig={"startSite":"","filingNum":"","onePageListNum":15,"commentLabelColor":"#006b75","yearColorList":["#bc4c00", "#0969da", "#1f883d", "#A333D0"],"i18n":"CN","dayTheme":"light","nightTheme":"dark"}
|
||||
config=json.loads(open('config.json', 'r', encoding='utf-8').read())
|
||||
self.blogBase={**dconfig,**config}.copy()
|
||||
self.blogBase["postListJson"]=json.loads('{}')
|
||||
self.blogBase["singeListJson"]=json.loads('{}')
|
||||
if self.blogBase["i18n"]=="CN":
|
||||
self.i18n=i18nCN
|
||||
else:
|
||||
self.i18n=i18n
|
||||
|
||||
def get_repo(self,user:Github, repo:str):
|
||||
return user.get_repo(repo)
|
||||
|
||||
|
||||
@ -8,8 +8,8 @@
|
||||
<link rel="icon" href="{{ blogBase['faviconUrl'] }}">
|
||||
<script>
|
||||
if(localStorage.getItem("meek_theme")==null){}
|
||||
else if(localStorage.getItem("meek_theme")=="dark"){document.getElementsByTagName("html")[0].attributes.getNamedItem("data-color-mode").value="dark";}
|
||||
else if(localStorage.getItem("meek_theme")=="light"){document.getElementsByTagName("html")[0].attributes.getNamedItem("data-color-mode").value="light";}
|
||||
else if(localStorage.getItem("meek_theme")=="dark"){document.getElementsByTagName("html")[0].attributes.getNamedItem("data-color-mode").value="{{ blogBase['nightTheme'] }}";}
|
||||
else if(localStorage.getItem("meek_theme")=="light"){document.getElementsByTagName("html")[0].attributes.getNamedItem("data-color-mode").value="{{ blogBase['dayTheme'] }}";}
|
||||
</script>
|
||||
{% block head %}{% endblock %}
|
||||
</head>
|
||||
@ -46,13 +46,13 @@ else if(localStorage.getItem("meek_theme")=="dark"){changeDark();}
|
||||
else if(localStorage.getItem("meek_theme")=="light"){changeLight();}
|
||||
|
||||
function changeDark(){
|
||||
document.getElementsByTagName("html")[0].attributes.getNamedItem("data-color-mode").value="dark";
|
||||
document.getElementsByTagName("html")[0].attributes.getNamedItem("data-color-mode").value="{{ blogBase['nightTheme'] }}";
|
||||
document.getElementById("themeSwitch").setAttribute("d",value=IconList["moon"]);
|
||||
document.getElementById("themeSwitch").parentNode.style.color="#00f0ff";
|
||||
if(utterancesLoad==1){utterancesTheme("dark-blue");}
|
||||
}
|
||||
function changeLight(){
|
||||
document.getElementsByTagName("html")[0].attributes.getNamedItem("data-color-mode").value="light";
|
||||
document.getElementsByTagName("html")[0].attributes.getNamedItem("data-color-mode").value="{{ blogBase['dayTheme'] }}";
|
||||
document.getElementById("themeSwitch").setAttribute("d",value=IconList["sun"]);
|
||||
document.getElementById("themeSwitch").parentNode.style.color="#ff5000";
|
||||
if(utterancesLoad==1){utterancesTheme("github-light");}
|
||||
|
||||
Loading…
Reference in New Issue
Block a user