Browse Source

:art: history

Vanessa 1 năm trước cách đây
mục cha
commit
a9cd07b2f9
1 tập tin đã thay đổi với 6 bổ sung7 xóa
  1. 6 7
      app/src/history/history.ts

+ 6 - 7
app/src/history/history.ts

@@ -33,11 +33,12 @@ const renderDoc = (element: HTMLElement, currentPage: number) => {
     const docElement = element.querySelector('.history__text[data-type="docPanel"]');
     const docElement = element.querySelector('.history__text[data-type="docPanel"]');
     const assetElement = element.querySelector('.history__text[data-type="assetPanel"]');
     const assetElement = element.querySelector('.history__text[data-type="assetPanel"]');
     const mdElement = element.querySelector('.history__text[data-type="mdPanel"]') as HTMLTextAreaElement;
     const mdElement = element.querySelector('.history__text[data-type="mdPanel"]') as HTMLTextAreaElement;
-    docElement.classList.add("fn__none");
+    const listElement = element.querySelector(".b3-list");
+    assetElement.classList.add("fn__none");
     mdElement.classList.add("fn__none");
     mdElement.classList.add("fn__none");
+    docElement.classList.add("fn__none");
     if (typeElement.value === "2") {
     if (typeElement.value === "2") {
         notebookElement.setAttribute("disabled", "disabled");
         notebookElement.setAttribute("disabled", "disabled");
-        assetElement.classList.remove("fn__none");
         if (window.siyuan.storage[Constants.LOCAL_HISTORY].type !== 2) {
         if (window.siyuan.storage[Constants.LOCAL_HISTORY].type !== 2) {
             opElement.value = "all";
             opElement.value = "all";
         }
         }
@@ -50,7 +51,6 @@ const renderDoc = (element: HTMLElement, currentPage: number) => {
         opElement.querySelector('option[value="outline"]').classList.add("fn__none")
         opElement.querySelector('option[value="outline"]').classList.add("fn__none")
     } else {
     } else {
         notebookElement.removeAttribute("disabled");
         notebookElement.removeAttribute("disabled");
-        assetElement.classList.add("fn__none");
         if (window.siyuan.storage[Constants.LOCAL_HISTORY].type === 2) {
         if (window.siyuan.storage[Constants.LOCAL_HISTORY].type === 2) {
             opElement.value = "all";
             opElement.value = "all";
         }
         }
@@ -82,9 +82,7 @@ const renderDoc = (element: HTMLElement, currentPage: number) => {
         }
         }
         nextElement.nextElementSibling.nextElementSibling.textContent = `${currentPage}/${response.data.pageCount || 1}`;
         nextElement.nextElementSibling.nextElementSibling.textContent = `${currentPage}/${response.data.pageCount || 1}`;
         if (response.data.histories.length === 0) {
         if (response.data.histories.length === 0) {
-            element.lastElementChild.lastElementChild.previousElementSibling.classList.add("fn__none");
-            element.lastElementChild.lastElementChild.classList.add("fn__none");
-            element.lastElementChild.firstElementChild.innerHTML = `<li class="b3-list--empty">${window.siyuan.languages.emptyContent}</li>`;
+            listElement.innerHTML = `<li class="b3-list--empty">${window.siyuan.languages.emptyContent}</li>`;
             return;
             return;
         }
         }
         let logsHTML = "";
         let logsHTML = "";
@@ -94,7 +92,7 @@ const renderDoc = (element: HTMLElement, currentPage: number) => {
     <span style="padding-left: 4px" class="b3-list-item__text">${dayjs(parseInt(item) * 1000).format("YYYY-MM-DD HH:mm:ss")}</span>
     <span style="padding-left: 4px" class="b3-list-item__text">${dayjs(parseInt(item) * 1000).format("YYYY-MM-DD HH:mm:ss")}</span>
 </li>`;
 </li>`;
         });
         });
-        element.lastElementChild.firstElementChild.innerHTML = logsHTML;
+        listElement.innerHTML = logsHTML;
     });
     });
 };
 };
 
 
@@ -647,6 +645,7 @@ const bindEvent = (app: App, element: Element, dialog?: Dialog) => {
             } else if (target.classList.contains("b3-list-item") && (type === "assets" || type === "doc")) {
             } else if (target.classList.contains("b3-list-item") && (type === "assets" || type === "doc")) {
                 const dataPath = target.getAttribute("data-path");
                 const dataPath = target.getAttribute("data-path");
                 if (type === "assets") {
                 if (type === "assets") {
+                    assetElement.classList.remove("fn__none");
                     assetElement.innerHTML = renderAssetsPreview(dataPath);
                     assetElement.innerHTML = renderAssetsPreview(dataPath);
                 } else if (type === "doc") {
                 } else if (type === "doc") {
                     fetchPost("/api/history/getDocHistoryContent", {
                     fetchPost("/api/history/getDocHistoryContent", {