From f252d0f16e0f8510d95c9d9a3e31f5db3382184c Mon Sep 17 00:00:00 2001 From: Meekdai Date: Tue, 2 Apr 2024 14:01:54 +0800 Subject: [PATCH] =?UTF-8?q?=E9=80=9A=E8=BF=87themeMode=E9=85=8D=E7=BD=AE?= =?UTF-8?q?=E4=B8=BB=E9=A2=98=E6=A8=A1=E5=BC=8F=E4=BF=AE=E6=94=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 目前默认为manual,和固定主题fix --- Gmeek.py | 9 +++++---- templates/base.html | 10 +++++++++- templates/plist.html | 2 +- templates/post.html | 9 ++++----- templates/tag.html | 2 +- 5 files changed, 20 insertions(+), 12 deletions(-) diff --git a/Gmeek.py b/Gmeek.py index 777f8e6..d9c782a 100644 --- a/Gmeek.py +++ b/Gmeek.py @@ -28,7 +28,8 @@ IconBase={ "rss":"M2.002 2.725a.75.75 0 0 1 .797-.699C8.79 2.42 13.58 7.21 13.974 13.201a.75.75 0 0 1-1.497.098 10.502 10.502 0 0 0-9.776-9.776.747.747 0 0 1-.7-.798ZM2.84 7.05h-.002a7.002 7.002 0 0 1 6.113 6.111.75.75 0 0 1-1.49.178 5.503 5.503 0 0 0-4.8-4.8.75.75 0 0 1 .179-1.489ZM2 13a1 1 0 1 1 2 0 1 1 0 0 1-2 0Z", "upload":"M2.75 14A1.75 1.75 0 0 1 1 12.25v-2.5a.75.75 0 0 1 1.5 0v2.5c0 .138.112.25.25.25h10.5a.25.25 0 0 0 .25-.25v-2.5a.75.75 0 0 1 1.5 0v2.5A1.75 1.75 0 0 1 13.25 14Z M11.78 4.72a.749.749 0 1 1-1.06 1.06L8.75 3.811V9.5a.75.75 0 0 1-1.5 0V3.811L5.28 5.78a.749.749 0 1 1-1.06-1.06l3.25-3.25a.749.749 0 0 1 1.06 0l3.25 3.25Z", "github":"M8 0c4.42 0 8 3.58 8 8a8.013 8.013 0 0 1-5.45 7.59c-.4.08-.55-.17-.55-.38 0-.27.01-1.13.01-2.2 0-.75-.25-1.23-.54-1.48 1.78-.2 3.65-.88 3.65-3.95 0-.88-.31-1.59-.82-2.15.08-.2.36-1.02-.08-2.12 0 0-.67-.22-2.2.82-.64-.18-1.32-.27-2-.27-.68 0-1.36.09-2 .27-1.53-1.03-2.2-.82-2.2-.82-.44 1.1-.16 1.92-.08 2.12-.51.56-.82 1.28-.82 2.15 0 3.06 1.86 3.75 3.64 3.95-.23.2-.44.55-.51 1.07-.46.21-1.61.55-2.33-.66-.15-.24-.6-.83-1.23-.82-.67.01-.27.38.01.53.34.19.73.9.82 1.13.16.45.68 1.31 2.69.94 0 .67.01 1.3.01 1.49 0 .21-.15.45-.55.38A7.995 7.995 0 0 1 0 8c0-4.42 3.58-8 8-8Z", - "home":"M6.906.664a1.749 1.749 0 0 1 2.187 0l5.25 4.2c.415.332.657.835.657 1.367v7.019A1.75 1.75 0 0 1 13.25 15h-3.5a.75.75 0 0 1-.75-.75V9H7v5.25a.75.75 0 0 1-.75.75h-3.5A1.75 1.75 0 0 1 1 13.25V6.23c0-.531.242-1.034.657-1.366l5.25-4.2Zm1.25 1.171a.25.25 0 0 0-.312 0l-5.25 4.2a.25.25 0 0 0-.094.196v7.019c0 .138.112.25.25.25H5.5V8.25a.75.75 0 0 1 .75-.75h3.5a.75.75 0 0 1 .75.75v5.25h2.75a.25.25 0 0 0 .25-.25V6.23a.25.25 0 0 0-.094-.195Z" + "home":"M6.906.664a1.749 1.749 0 0 1 2.187 0l5.25 4.2c.415.332.657.835.657 1.367v7.019A1.75 1.75 0 0 1 13.25 15h-3.5a.75.75 0 0 1-.75-.75V9H7v5.25a.75.75 0 0 1-.75.75h-3.5A1.75 1.75 0 0 1 1 13.25V6.23c0-.531.242-1.034.657-1.366l5.25-4.2Zm1.25 1.171a.25.25 0 0 0-.312 0l-5.25 4.2a.25.25 0 0 0-.094.196v7.019c0 .138.112.25.25.25H5.5V8.25a.75.75 0 0 1 .75-.75h3.5a.75.75 0 0 1 .75.75v5.25h2.75a.25.25 0 0 0 .25-.25V6.23a.25.25 0 0 0-.094-.195Z", + "sync":"M1.705 8.005a.75.75 0 0 1 .834.656 5.5 5.5 0 0 0 9.592 2.97l-1.204-1.204a.25.25 0 0 1 .177-.427h3.646a.25.25 0 0 1 .25.25v3.646a.25.25 0 0 1-.427.177l-1.38-1.38A7.002 7.002 0 0 1 1.05 8.84a.75.75 0 0 1 .656-.834ZM8 2.5a5.487 5.487 0 0 0-4.131 1.869l1.204 1.204A.25.25 0 0 1 4.896 6H1.25A.25.25 0 0 1 1 5.75V2.104a.25.25 0 0 1 .427-.177l1.38 1.38A7.002 7.002 0 0 1 14.95 7.16a.75.75 0 0 1-1.49.178A5.5 5.5 0 0 0 8 2.5Z" } ###################################################################################### class GMEEK(): @@ -150,16 +151,16 @@ class GMEEK(): if issue["label"] in self.blogBase["singlePage"]: postBase["bottomText"]='' - keys=['sun','moon','home','github'] + keys=['sun','moon','sync','home','github'] postIcon=dict(zip(keys, map(IconBase.get, keys))) self.renderHtml('post.html',postBase,{},issue["htmlDir"],postIcon) print("create postPage title=%s file=%s " % (issue["postTitle"],issue["htmlDir"])) def createPlistHtml(self): self.blogBase["postListJson"]=dict(sorted(self.blogBase["postListJson"].items(),key=lambda x:(x[1]["top"],x[1]["createdAt"]),reverse=True))#使列表由时间排序 - keys=list(OrderedDict.fromkeys(['sun', 'moon', 'search', 'rss', 'upload', 'post'] + self.blogBase["singlePage"])) + keys=list(OrderedDict.fromkeys(['sun', 'moon','sync', 'search', 'rss', 'upload', 'post'] + self.blogBase["singlePage"])) plistIcon={**dict(zip(keys, map(IconBase.get, keys))),**self.blogBase["iconList"]} - keys=['sun','moon','home','search','post'] + keys=['sun','moon','sync','home','search','post'] tagIcon=dict(zip(keys, map(IconBase.get, keys))) postNum=len(self.blogBase["postListJson"]) diff --git a/templates/base.html b/templates/base.html index 521cac6..f3ed74d 100644 --- a/templates/base.html +++ b/templates/base.html @@ -1,5 +1,5 @@ - + @@ -11,6 +11,7 @@ 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 {document.getElementsByTagName("html")[0].attributes.getNamedItem("data-color-mode").value="auto";} {%- endif -%} {% block head %}{% endblock %} @@ -35,6 +36,7 @@ var utterancesLoad=0; if(localStorage.getItem("meek_theme")==null){localStorage.setItem("meek_theme","light");changeLight();} else if(localStorage.getItem("meek_theme")=="dark"){changeDark();} else if(localStorage.getItem("meek_theme")=="light"){changeLight();} +else if(localStorage.getItem("meek_theme")=="auto"){changeAuto();} function changeDark(){ document.getElementsByTagName("html")[0].attributes.getNamedItem("data-color-mode").value="dark"; @@ -48,8 +50,14 @@ function changeLight(){ document.getElementById("themeSwitch").parentNode.style.color="#ff5000"; if(utterancesLoad==1){utterancesTheme("github-light");} } +function changeAuto(){ + document.getElementsByTagName("html")[0].attributes.getNamedItem("data-color-mode").value="auto"; + document.getElementById("themeSwitch").setAttribute("d",value=IconList["sync"]); + if(utterancesLoad==1){utterancesTheme("preferred-color-scheme");} +} function modeSwitch(){ if(document.getElementsByTagName("html")[0].attributes[0].value=="light"){changeDark();localStorage.setItem("meek_theme","dark");} + else if(document.getElementsByTagName("html")[0].attributes[0].value=="dark"){changeAuto();localStorage.setItem("meek_theme","auto");} else{changeLight();localStorage.setItem("meek_theme","light");} } diff --git a/templates/plist.html b/templates/plist.html index 39a19fb..9e8477c 100644 --- a/templates/plist.html +++ b/templates/plist.html @@ -58,7 +58,7 @@ - {% endif %} - -