فهرست منبع

【修复】优化 updateContent 函数参数设计

- 将 updateContent 函数的 mdPath 参数默认值改为 pValue
- 移除了冗余的参数设计,简化了函数调用
- 优化了代码结构,提高了代码的可读性和维护性
PJ568 1 سال پیش
والد
کامیت
c15beb549d
1فایلهای تغییر یافته به همراه3 افزوده شده و 3 حذف شده
  1. 3 3
      index.html

+ 3 - 3
index.html

@@ -1,7 +1,7 @@
 <!doctype html>
 
 <html>
-<markdown-html version="1.18.0" author="PJ568" repo="https://github.com/PJ-568/markdown.html"
+<markdown-html version="1.18.1" author="PJ568" repo="https://github.com/PJ-568/markdown.html"
   license="CC BY-SA 4.0 International"></markdown-html>
 
 <head>
@@ -316,7 +316,7 @@
       }
 
       // 处理错误
-      function updateContent(article, title = null, mdPath = null) {
+      function updateContent(article, title = null, mdPath = pValue) {
         try {
           document.querySelector('.markdown-body').innerHTML = `<div class="old-content Animated Animated-remove Animated--reverse Animate--fast Animate--noDelay Animate--slideInLeft">${document.querySelector('.markdown-body .content').innerHTML}</div><div class="content Animated Animate--slideInRight">${article}</div>`;
           firstH1 = document.querySelector('.markdown-body .content h1');
@@ -444,7 +444,7 @@
         }
         try {
           pValue = mdPath ? mdPath : path;
-          updateContent(await getMarkdown((mdPath ? mdPath : path), response), pValue)
+          updateContent(await getMarkdown((mdPath ? mdPath : path), response))
           document.querySelector('html').classList.add('loaded');	//// 防止缓存的页面被自定义 PJAX 中覆写的处理响应的函数捕获
           waitForAnimationsEnd(document.querySelector('.markdown-body'), '.content, .old-content', ['Animation-slideInRight', 'Animation-slideInLeft']).then(async () => {
             await showMarkdownEnded();