From c4561b6a743b64269446ff39ddf454635597970f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=91=86=E7=93=9C=E4=BA=91?= Date: Tue, 5 Sep 2023 17:17:27 +0800 Subject: [PATCH] =?UTF-8?q?config=E9=85=8D=E7=BD=AE=E6=96=87=E4=BB=B6?= =?UTF-8?q?=E7=B2=BE=E7=AE=80=EF=BC=8C=E6=B7=BB=E5=8A=A0=E9=85=8D=E7=BD=AE?= =?UTF-8?q?Theme=E5=8F=82=E6=95=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- CONIFG.md | 7 ------- Gmeek.py | 22 ++++++++++++---------- templates/base.html | 8 ++++---- 3 files changed, 16 insertions(+), 21 deletions(-) diff --git a/CONIFG.md b/CONIFG.md index 128c687..040fb13 100644 --- a/CONIFG.md +++ b/CONIFG.md @@ -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" } ``` diff --git a/Gmeek.py b/Gmeek.py index 46fa37c..e206150 100644 --- a/Gmeek.py +++ b/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) diff --git a/templates/base.html b/templates/base.html index 22370a7..f9c9282 100644 --- a/templates/base.html +++ b/templates/base.html @@ -8,8 +8,8 @@ {% block head %}{% endblock %} @@ -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");}