Jelajahi Sumber

:art: fix https://github.com/siyuan-note/siyuan/issues/10846

Vanessa 1 tahun lalu
induk
melakukan
cf2079edf9
2 mengubah file dengan 9 tambahan dan 5 penghapusan
  1. 0 1
      app/src/history/doc.ts
  2. 9 4
      app/src/history/history.ts

+ 0 - 1
app/src/history/doc.ts

@@ -181,7 +181,6 @@ export const openDocHistory = (options: {
     });
     });
 };
 };
 
 
-
 const getHistoryPath = (target: Element, op: string, id: string, cb: (path: string) => void) => {
 const getHistoryPath = (target: Element, op: string, id: string, cb: (path: string) => void) => {
     isLoading = true;
     isLoading = true;
     const path = target.getAttribute("data-path");
     const path = target.getAttribute("data-path");

+ 9 - 4
app/src/history/history.ts

@@ -312,7 +312,7 @@ export const openHistory = (app: App) => {
         }
         }
     });
     });
 
 
-    let notebookSelectHTML = `<option value='%' ${!existLocalHistoryNoteID? "selected" : ""}>${window.siyuan.languages.allNotebooks}</option>`;
+    let notebookSelectHTML = `<option value='%' ${!existLocalHistoryNoteID ? "selected" : ""}>${window.siyuan.languages.allNotebooks}</option>`;
     window.siyuan.notebooks.forEach((item) => {
     window.siyuan.notebooks.forEach((item) => {
         if (!item.closed) {
         if (!item.closed) {
             notebookSelectHTML += ` <option value="${item.id}"${item.id === window.siyuan.storage[Constants.LOCAL_HISTORYNOTEID] ? " selected" : ""}>${escapeHtml(item.name)}</option>`;
             notebookSelectHTML += ` <option value="${item.id}"${item.id === window.siyuan.storage[Constants.LOCAL_HISTORYNOTEID] ? " selected" : ""}>${escapeHtml(item.name)}</option>`;
@@ -510,7 +510,7 @@ const bindEvent = (app: App, element: Element, dialog?: Dialog) => {
                         });
                         });
                     } else if (dataType === "doc") {
                     } else if (dataType === "doc") {
                         fetchPost("/api/history/rollbackDocHistory", {
                         fetchPost("/api/history/rollbackDocHistory", {
-                            notebook: (firstPanelElement.querySelector('.b3-select[data-type="notebookselect"]') as HTMLSelectElement).value,
+                            notebook: target.parentElement.getAttribute("data-notebook-id"),
                             historyPath: target.parentElement.getAttribute("data-path")
                             historyPath: target.parentElement.getAttribute("data-path")
                         });
                         });
                     } else if (dataType === "notebook") {
                     } else if (dataType === "notebook") {
@@ -557,7 +557,12 @@ const bindEvent = (app: App, element: Element, dialog?: Dialog) => {
                         }, (response) => {
                         }, (response) => {
                             iconElement.classList.add("b3-list-item__arrow--open");
                             iconElement.classList.add("b3-list-item__arrow--open");
                             let html = "";
                             let html = "";
-                            response.data.items.forEach((docItem: { title: string, path: string, op: string }) => {
+                            response.data.items.forEach((docItem: {
+                                title: string,
+                                path: string,
+                                op: string,
+                                notebook: string
+                            }) => {
                                 let chipClass = " b3-chip b3-chip--list ";
                                 let chipClass = " b3-chip b3-chip--list ";
                                 if (docItem.op === "clean") {
                                 if (docItem.op === "clean") {
                                     chipClass += "b3-chip--primary ";
                                     chipClass += "b3-chip--primary ";
@@ -572,7 +577,7 @@ const bindEvent = (app: App, element: Element, dialog?: Dialog) => {
                                 } else if (docItem.op === "replace") {
                                 } else if (docItem.op === "replace") {
                                     chipClass += "b3-chip--secondary ";
                                     chipClass += "b3-chip--secondary ";
                                 }
                                 }
-                                html += `<li title="${escapeAttr(docItem.title)}" data-created="${created}" data-type="${typeElement.value === "2" ? "assets" : "doc"}" data-path="${docItem.path}" class="b3-list-item b3-list-item--hide-action" style="padding-left: 22px">
+                                html += `<li data-notebook-id="${docItem.notebook}" title="${escapeAttr(docItem.title)}" data-created="${created}" data-type="${typeElement.value === "2" ? "assets" : "doc"}" data-path="${docItem.path}" class="b3-list-item b3-list-item--hide-action" style="padding-left: 22px">
     <span class="${opElement.value === "all" ? "" : "fn__none"}${chipClass}b3-tooltips b3-tooltips__n" aria-label="${docItem.op}">${docItem.op.substring(0, 1).toUpperCase()}</span>
     <span class="${opElement.value === "all" ? "" : "fn__none"}${chipClass}b3-tooltips b3-tooltips__n" aria-label="${docItem.op}">${docItem.op.substring(0, 1).toUpperCase()}</span>
     <span class="b3-list-item__text">${escapeHtml(docItem.title)}</span>
     <span class="b3-list-item__text">${escapeHtml(docItem.title)}</span>
     <span class="fn__space"></span>
     <span class="fn__space"></span>