瀏覽代碼

feat: 添加ICP备案

SongZihuan 2 年之前
父節點
當前提交
feac43dc50
共有 4 個文件被更改,包括 39 次插入1 次删除
  1. 1 0
      configure/__init__.py
  2. 4 0
      static/styles/base.css
  3. 3 0
      templates/base.html
  4. 31 1
      templates/index/hello.html

+ 1 - 0
configure/__init__.py

@@ -35,6 +35,7 @@ conf = {
     "LOG_LEVEL": logging.INFO,
     "LOG_STDERR": True,
     "LOGO": "logo.jpg",
+    "ICP": None,
 }
 
 

+ 4 - 0
static/styles/base.css

@@ -10,4 +10,8 @@ body {
 #foot {
     text-align: center;
     padding-bottom: 10px;
+}
+
+#ICP {
+    background-color: rgb(255, 255, 255, 60%);
 }

+ 3 - 0
templates/base.html

@@ -110,6 +110,9 @@
     <footer id="foot">
         <hr>
         {{ conf['FOOT'] }}
+        {% if conf["ICP"] %}
+            <br> <a id="ICP" href="https://beian.miit.gov.cn"> {{ conf['ICP'] }} </a>
+        {% endif %}
     </footer>
     <script>
         function SetFooter (mutationsList, observer) {

+ 31 - 1
templates/index/hello.html

@@ -25,4 +25,34 @@
     </section>
 {% endblock %}
 
-{% block footer %} {% endblock %}
+{% block footer %}
+    {% if conf["ICP"] %}
+        <footer id="foot">
+            <a id="ICP" href="https://beian.miit.gov.cn"> {{ conf['ICP'] }} </a>
+        </footer>
+        <script>
+            function SetFooter (mutationsList, observer) {
+                let foot = document.getElementById('foot')
+                let content_height = content.getBoundingClientRect().bottom
+                let win_height = 0
+                if (window.innerHeight)
+                    win_height = window.innerHeight;
+                else if ((document.body) && (document.body.clientHeight))
+                    win_height = document.body.clientHeight;
+
+                if (win_height - content_height - foot.clientHeight <= 0)
+                    foot.style.marginTop = "0"
+                else
+                    foot.style.marginTop = (win_height - content_height - foot.clientHeight).toString() + "px"
+            }
+            let MutationObserver = window.MutationObserver;
+            let observer = new MutationObserver(SetFooter);
+            let content = document.getElementById('content')
+            observer.observe(content, {
+                attributes: true, // 属性的变动
+                subtree: true, // 是否将观察器应用于该节点的所有后代节点
+            });
+            SetFooter()
+        </script>
+    {% endif %}
+{% endblock %}