From c0ceb5c7d39322f6b8840d4a4c9c442ca0643fc9 Mon Sep 17 00:00:00 2001 From: Vanessa Date: Mon, 24 Apr 2023 16:07:47 +0800 Subject: [PATCH] :lipstick: https://github.com/siyuan-note/siyuan/issues/8094 --- app/src/assets/scss/business/_history.scss | 5 ++ app/src/assets/scss/util/_responsive.scss | 14 ++++ app/src/history/diff.ts | 6 +- app/src/history/history.ts | 85 ++++++++++++++++------ 4 files changed, 86 insertions(+), 24 deletions(-) diff --git a/app/src/assets/scss/business/_history.scss b/app/src/assets/scss/business/_history.scss index b336352ca..0307ac667 100644 --- a/app/src/assets/scss/business/_history.scss +++ b/app/src/assets/scss/business/_history.scss @@ -31,4 +31,9 @@ padding: 8px 0; overflow: auto; } + + &__panel > .b3-list, + &__panel > .history__diff { + width: 200px; + } } diff --git a/app/src/assets/scss/util/_responsive.scss b/app/src/assets/scss/util/_responsive.scss index dda0c4cdf..aae2828f8 100644 --- a/app/src/assets/scss/util/_responsive.scss +++ b/app/src/assets/scss/util/_responsive.scss @@ -58,4 +58,18 @@ } } } + + .history { + &__panel { + flex-direction: column; + + & > .b3-list, + & > .history__diff { + height: 40%; + overflow: auto; + padding-bottom: 8px; + width: auto; + } + } + } } diff --git a/app/src/history/diff.ts b/app/src/history/diff.ts index 7a7fef948..7d3481fe0 100644 --- a/app/src/history/diff.ts +++ b/app/src/history/diff.ts @@ -115,7 +115,7 @@ export const showDiff = (data: { id: string, time: string }[]) => { const dialog = new Dialog({ title: window.siyuan.languages.compare, content: "", - width: isMobile() ? "92vw" : "80vw", + width: isMobile() ? "92vw" : "90vw", height: "80vh", destroyCallback() { leftEditor = undefined; @@ -178,8 +178,8 @@ const genHTML = (left: string, right: string, dialog: Dialog, direct:string) => ${dayjs(response.data.right.created).format("YYYY-MM-DD HH:mm")} `; - headElement.nextElementSibling.innerHTML = `
-
+ headElement.nextElementSibling.innerHTML = `
+
  • diff --git a/app/src/history/history.ts b/app/src/history/history.ts index e89732795..87d684aa8 100644 --- a/app/src/history/history.ts +++ b/app/src/history/history.ts @@ -57,7 +57,7 @@ const renderDoc = (element: HTMLElement, currentPage: number) => { } else { nextElement.setAttribute("disabled", "disabled"); } - nextElement.nextElementSibling.nextElementSibling.textContent = `${currentPage}/${response.data.pageCount||1}`; + nextElement.nextElementSibling.nextElementSibling.textContent = `${currentPage}/${response.data.pageCount || 1}`; if (response.data.histories.length === 0) { element.lastElementChild.lastElementChild.previousElementSibling.classList.add("fn__none"); element.lastElementChild.lastElementChild.classList.add("fn__none"); @@ -155,6 +155,7 @@ const renderRepoItem = (response: IWebSocketData, element: Element, type: string } /// #endif let repoHTML = ""; + const isPhone = isMobile(); response.data.snapshots.forEach((item: { memo: string, id: string, @@ -169,27 +170,26 @@ const renderRepoItem = (response: IWebSocketData, element: Element, type: string }) => { let statHTML = ""; if (item.typesCount) { - statHTML = '
    '; + statHTML = `
    +${window.siyuan.languages.fileCount} ${item.count}`; item.typesCount.forEach(subItem => { statHTML += `${subItem.type} ${subItem.count}`; }); statHTML += "
    "; } - const infoHTML = `
    - ${escapeHtml(item.memo)} - - ${item.tag} -
    -
    - ${item.id.substring(0, 7)} - + const infoHTML = ` ${item.hCreated} ${item.hSize} - ${window.siyuan.languages.fileCount} ${item.count} + ${item.systemOS}${(item.systemName && item.systemOS) ? "/" : ""}${item.systemName} - ${item.systemOS}/${item.systemName} + ${item.tag} +
    +
    + ${escapeHtml(item.memo)} + + ${item.id.substring(0, 7)}
    ${statHTML}`; /// #if MOBILE @@ -198,6 +198,12 @@ ${statHTML}`; ${infoHTML}
    ${actionHTML} + + + + ${window.siyuan.languages.more} + +
  • `; @@ -242,7 +248,7 @@ const renderRepo = (element: Element, currentPage: number) => { } else { nextElement.setAttribute("disabled", "disabled"); } - pageElement.textContent = `${currentPage}/${response.data.pageCount||1}`; + pageElement.textContent = `${currentPage}/${response.data.pageCount || 1}`; renderRepoItem(response, element, selectValue); }); } @@ -313,9 +319,9 @@ export const openHistory = () => {
    - + - + 1/1 @@ -331,7 +337,7 @@ export const openHistory = () => { - @@ -348,8 +354,8 @@ export const openHistory = () => {
    -
    -
      +
      +
      • ${window.siyuan.languages.emptyContent}
      @@ -363,9 +369,9 @@ export const openHistory = () => {
      - + - + 1/1 @@ -403,7 +409,7 @@ export const openHistory = () => { } else { const dialog = new Dialog({ content: contentHTML, - width: "80vw", + width: "90vw", height: "80vh", destroyCallback() { historyEditor = undefined; @@ -477,6 +483,8 @@ const bindEvent = (element: Element, dialog?: Dialog) => { item.classList.remove("fn__block"); } }); + event.stopPropagation(); + event.preventDefault(); break; } else if (target.classList.contains("b3-list-item__action") && type === "rollback" && !window.siyuan.config.readonly) { confirmDialog("⚠️ " + window.siyuan.languages.rollback, `${window.siyuan.languages.rollbackConfirm.replace("${date}", target.parentElement.textContent.trim())}`, () => { @@ -500,6 +508,15 @@ const bindEvent = (element: Element, dialog?: Dialog) => { }); } }); + event.stopPropagation(); + event.preventDefault(); + break; + } else if (type === "more") { + target.parentElement.parentElement.querySelectorAll(".b3-list-item__meta").forEach(item => { + item.classList.toggle("fn__none"); + }) + event.stopPropagation(); + event.preventDefault(); break; } else if (type === "toggle") { const iconElement = target.firstElementChild.firstElementChild; @@ -537,10 +554,14 @@ const bindEvent = (element: Element, dialog?: Dialog) => { }); } } + event.stopPropagation(); + event.preventDefault(); break; } else if (type === "rmtoggle") { target.nextElementSibling.classList.toggle("fn__none"); target.firstElementChild.firstElementChild.classList.toggle("b3-list-item__arrow--open"); + event.stopPropagation(); + event.preventDefault(); break; } else if (target.classList.contains("b3-list-item") && type === "repoitem" && ["getRepoSnapshots", "getRepoTagSnapshots"].includes(repoSelectElement.value)) { @@ -570,6 +591,8 @@ const bindEvent = (element: Element, dialog?: Dialog) => { btnElement.setAttribute("disabled", "disabled"); } btnElement.setAttribute("data-ids", JSON.stringify(idJSON)); + event.stopPropagation(); + event.preventDefault(); break; } else if (target.classList.contains("b3-list-item") && (type === "assets" || type === "doc")) { const dataPath = target.getAttribute("data-path"); @@ -599,6 +622,8 @@ const bindEvent = (element: Element, dialog?: Dialog) => { } } target.classList.add("b3-list-item--focus"); + event.stopPropagation(); + event.preventDefault(); break; } else if (type === "genRepo") { const genRepoDialog = new Dialog({ @@ -627,6 +652,8 @@ const bindEvent = (element: Element, dialog?: Dialog) => { }); genRepoDialog.destroy(); }); + event.stopPropagation(); + event.preventDefault(); break; } else if (type === "removeRepoTagSnapshot" || type === "removeCloudRepoTagSnapshot") { const tag = target.parentElement.getAttribute("data-tag"); @@ -635,18 +662,24 @@ const bindEvent = (element: Element, dialog?: Dialog) => { renderRepo(repoElement, 1); }); }); + event.stopPropagation(); + event.preventDefault(); break; } else if (type === "uploadSnapshot") { fetchPost("/api/repo/uploadCloudSnapshot", { tag: target.parentElement.getAttribute("data-tag"), id: target.parentElement.getAttribute("data-id") }); + event.stopPropagation(); + event.preventDefault(); break; } else if (type === "downloadSnapshot") { fetchPost("/api/repo/downloadCloudSnapshot", { tag: target.parentElement.getAttribute("data-tag"), id: target.parentElement.getAttribute("data-id") }); + event.stopPropagation(); + event.preventDefault(); break; } else if (type === "genTag") { const genTagDialog = new Dialog({ @@ -690,14 +723,20 @@ const bindEvent = (element: Element, dialog?: Dialog) => { }); genTagDialog.destroy(); }); + event.stopPropagation(); + event.preventDefault(); break; } else if ((type === "previous" || type === "next") && target.getAttribute("disabled") !== "disabled") { const currentPage = parseInt(repoElement.getAttribute("data-page")); renderRepo(repoElement, type === "previous" ? currentPage - 1 : currentPage + 1); + event.stopPropagation(); + event.preventDefault(); break; } else if ((type === "docprevious" || type === "docnext") && target.getAttribute("disabled") !== "disabled") { const currentPage = parseInt(firstPanelElement.getAttribute("data-page")); renderDoc(firstPanelElement, type === "docprevious" ? currentPage - 1 : currentPage + 1); + event.stopPropagation(); + event.preventDefault(); break; } else if (type === "rebuildIndex") { fetchPost("/api/history/reindexHistory"); @@ -707,9 +746,13 @@ const bindEvent = (element: Element, dialog?: Dialog) => { closeModel(); historyEditor = undefined; } + event.stopPropagation(); + event.preventDefault(); break; } else if (type === "compare" && !target.getAttribute("disabled")) { showDiff(JSON.parse(target.getAttribute("data-ids") || "[]")); + event.stopPropagation(); + event.preventDefault(); break; } target = target.parentElement;