Jelajahi Sumber

【修复】页面不更改问题

PJ-568 2 tahun lalu
induk
melakukan
17d9f1cd82
2 mengubah file dengan 2 tambahan dan 2 penghapusan
  1. 1 1
      server/main.js
  2. 1 1
      server/server.py

+ 1 - 1
server/main.js

@@ -18,7 +18,7 @@
                 selectors: [
                     "head meta",
                     "head title",
-                    "body container",
+                    "body .container",
                     ".pjax-reload"
                 ],
                 cacheBust: false

+ 1 - 1
server/server.py

@@ -233,7 +233,7 @@ class ChatServer(http.server.BaseHTTPRequestHandler):
         return f'''body{{font-family:Arial,sans-serif;background-color:#f4f4f4;margin:0;padding-top:20px;color:#333}}.container{{box-sizing:border-box;overflow:hidden;width:100%;max-width:600px;margin:0 auto;padding:20px;background-color:#fff;border:1px solid #ccc;box-shadow:2px 2px 5px rgba(0,0,0,0.1);border-radius:5px}}fieldset{{border:1px solid #ddd;padding:10px;margin-bottom:5px}}legend{{font-weight:bold;padding:0 10px}}label{{display:block;margin-bottom:5px}}input[type="text"],iframe,.content{{box-sizing:border-box;max-width:100%;width:100%;padding:8px;margin-bottom:10px;border:1px solid #ddd;border-radius:3px}}a,a:visited,button{{align-items:center;text-decoration:none;padding:8px 15px;margin-right:5px;background-color:#007BFF;color:#fff;border:none;border-radius:3px;cursor:pointer}}a:hover,a:visited:hover,button:hover{{background-color:#0056b3}}button:active{{background-color:#0067b8}}@media (max-width:600px){{.container{{width:100%;height:100%;border:none;border-radius:0;box-shadow:none}}}}.loading-bar{{position:fixed;top:0;left:0;z-index:99999;opacity:0;transition:opacity .4s linear;.progress{{position:fixed;top:0;left:0;width:0;height:4px;background-color:#007bff;box-shadow:0 0 10px rgba(119,182,255,.7)}}&.loading{{opacity:1;transition:none;.progress{{transition:width .4s ease}}}}}}'''.encode('utf-8')
 
     def generate_js(self):
-        return f'''(function(){{var loadingBar=document.querySelector(".loading-bar");var progress=document.querySelector(".loading-bar .progress");var timer=null;let pjax;function initAni(){{loadingBar=document.querySelector(".loading-bar");progress=document.querySelector(".loading-bar .progress")}}function initPjax(){{try{{const Pjax=window.Pjax||function(){{}};pjax=new Pjax({{selectors:["head meta","head title","body container",".pjax-reload"],cacheBust:false}})}}catch(e){{console.log('PJAX 初始化出错:'+e)}}}}function endLoad(){{clearInterval(timer);progress.style.width="100%";loadingBar.classList.remove("loading");setTimeout(function(){{progress.style.width=0}},400)}}function initialize(){{initPjax();initAni()}}window.addEventListener('DOMContentLoaded',()=>initialize());document.addEventListener("pjax:send",function(){{var loadingBarWidth=20;var MAX_LOADING_WIDTH=95;loadingBar.classList.add("loading");progress.style.width=loadingBarWidth+"%";clearInterval(timer);timer=setInterval(function(){{loadingBarWidth+=3;if(loadingBarWidth>MAX_LOADING_WIDTH){{loadingBarWidth=MAX_LOADING_WIDTH}}progress.style.width=loadingBarWidth+"%"}},500)}});document.addEventListener("pjax:complete",function(){{endLoad()}})}})();'''.encode('utf-8')
+        return f'''(function(){{var loadingBar=document.querySelector(".loading-bar");var progress=document.querySelector(".loading-bar .progress");var timer=null;let pjax;function initAni(){{loadingBar=document.querySelector(".loading-bar");progress=document.querySelector(".loading-bar .progress")}}function initPjax(){{try{{const Pjax=window.Pjax||function(){{}};pjax=new Pjax({{selectors:["head meta","head title","body .container",".pjax-reload"],cacheBust:false}})}}catch(e){{console.log('PJAX 初始化出错:'+e)}}}}function endLoad(){{clearInterval(timer);progress.style.width="100%";loadingBar.classList.remove("loading");setTimeout(function(){{progress.style.width=0}},400)}}function initialize(){{initPjax();initAni()}}window.addEventListener('DOMContentLoaded',()=>initialize());document.addEventListener("pjax:send",function(){{var loadingBarWidth=20;var MAX_LOADING_WIDTH=95;loadingBar.classList.add("loading");progress.style.width=loadingBarWidth+"%";clearInterval(timer);timer=setInterval(function(){{loadingBarWidth+=3;if(loadingBarWidth>MAX_LOADING_WIDTH){{loadingBarWidth=MAX_LOADING_WIDTH}}progress.style.width=loadingBarWidth+"%"}},500)}});document.addEventListener("pjax:complete",function(){{endLoad()}})}})();'''.encode('utf-8')
 
     def generate_favicon(self):
         return f'''<svg xmlns="http://www.w3.org/2000/svg" width="50" height="50"><circle cx="25" cy="25" r="20" fill="blue" /></svg>'''.encode('utf-8')