Przeglądaj źródła

【新增】优化 pValue 更新

PJ568 1 rok temu
rodzic
commit
21765dd1fe
1 zmienionych plików z 2 dodań i 12 usunięć
  1. 2 12
      index.html

+ 2 - 12
index.html

@@ -3,7 +3,7 @@
 <!-- 作者:PJ568 -->
 <!-- 项目地址:https://github.com/PJ-568/markdown.html/ -->
 <!-- 本项目遵循 CC BY-SA 4.0 International 许可协议 -->
-<!-- v 0.7.1 -->
+<!-- v 0.8.0 -->
 
 <head>
   <meta charset="utf-8">
@@ -24,9 +24,7 @@
 
       // 文档解析功能相关
       var existIndexPage = true;  // 是否存在索引页
-      var url = new URL(window.location.href);
-      var params = new URLSearchParams(url.search);
-      var pValue = formatPath(params.get('p'));
+      const pValue = formatPath(decodePath(window.location.href));
 
       // Pjax 相关
       let pjax;
@@ -198,13 +196,6 @@
         }
       }
 
-      // 更新 p 值
-      function updatePValue() {
-        url = new URL(window.location.href);
-        params = new URLSearchParams(url.search);
-        pValue = formatPath(params.get('p'));
-      }
-
       // 获取文件所在目录
       function getDirectory(path) {
         path = new URL(path, 'http://example.com').pathname;
@@ -370,7 +361,6 @@
       });
       //// 监听 Pjax 完成后,重新加载
       document.addEventListener('pjax:complete', function () {
-        updatePValue();
         initContent();
         translate.execute();    // 手动触发翻译,但是理论上 translate-js 会监听页面变化
         initCostumedPjax();	//// 初始化自定义 PJAX