diff --git a/app/src/assets/scss/_function.scss b/app/src/assets/scss/_function.scss
index 0476b225b..2731ff8e5 100644
--- a/app/src/assets/scss/_function.scss
+++ b/app/src/assets/scss/_function.scss
@@ -162,5 +162,9 @@
&__repoheader {
padding: 8px 16px;
+
+ .block__icon {
+ opacity: 1;
+ }
}
}
diff --git a/app/src/util/history.ts b/app/src/util/history.ts
index c41c6f269..1a17eac2e 100644
--- a/app/src/util/history.ts
+++ b/app/src/util/history.ts
@@ -6,7 +6,7 @@ import {MenuItem} from "../menus/Menu";
import {unicode2Emoji} from "../emoji";
import {escapeHtml} from "./escape";
import {isMobile} from "./functions";
-import {getDisplayName} from "./pathName";
+import {hasClosestByClassName} from "../protyle/util/hasClosest";
const renderDoc = (notebook: INotebook, element: HTMLElement) => {
if (!notebook || !notebook.id) {
@@ -104,18 +104,38 @@ const renderAssets = (element: HTMLElement) => {
});
};
-const renderRepo = (element: HTMLElement) => {
+const renderRepo = (element: Element, currentPage: number) => {
element.setAttribute("data-init", "true");
- fetchPost("/api/repo/getRepoIndexLogs", {page: 1}, (response) => {
+ element.setAttribute("data-page", currentPage.toString());
+ const previousElement = element.querySelector('[data-type="previous"]')
+ const nextElement = element.querySelector('[data-type="next"]')
+ if (currentPage > 1) {
+ previousElement.removeAttribute("disabled")
+ } else {
+ previousElement.setAttribute("disabled", "disabled");
+ }
+ fetchPost("/api/repo/getRepoIndexLogs", {page: currentPage}, (response) => {
+ if (currentPage < response.data.pageCount) {
+ nextElement.removeAttribute("disabled")
+ } else {
+ nextElement.setAttribute("disabled", "disabled");
+ }
if (response.data.logs.length === 0) {
element.lastElementChild.firstElementChild.innerHTML = `
${window.siyuan.languages.emptyContent}`;
return;
}
let repoHTML = "";
- response.data.logs.forEach((item: { files: { path: string, id: string }[], id: string, hCreated: string }) => {
- repoHTML += `
+ response.data.logs.forEach((item: { memo: string, id: string, hCreated: string }, index: number) => {
+ repoHTML += `
${item.hCreated}
+
+
+
+
`;
+ if (index === 0) {
+ element.lastElementChild.lastElementChild.innerHTML = `${item.memo}`;
+ }
});
element.lastElementChild.firstElementChild.innerHTML = `${repoHTML}`;
});
@@ -189,18 +209,17 @@ export const openHistory = () => {
- ${window.siyuan.languages.emptyContent}
-
+
@@ -235,6 +254,7 @@ export const openHistory = () => {
const firstPanelElement = dialog.element.querySelector("#historyContainer [data-type=doc]") as HTMLElement;
renderDoc(currentNotebook, firstPanelElement);
+ const repoElement = dialog.element.querySelector('#historyContainer [data-type="repo"]')
dialog.element.addEventListener("click", (event) => {
let target = event.target as HTMLElement;
while (target && !target.isEqualNode(dialog.element)) {
@@ -252,7 +272,7 @@ export const openHistory = () => {
} else if (type === "notebook") {
renderRmNotebook(item);
} else if (type === "repo") {
- renderRepo(item);
+ renderRepo(item, 1);
}
}
} else {
@@ -282,19 +302,24 @@ export const openHistory = () => {
break;
} else if (target.classList.contains("b3-list-item__action")) {
confirmDialog("⚠️ " + window.siyuan.languages.rollback, `${window.siyuan.languages.rollbackConfirm.replace("${date}", target.parentElement.textContent.trim())}`, () => {
- if (target.parentElement.getAttribute("data-type") === "assets") {
+ const dataType = target.parentElement.getAttribute("data-type")
+ if (dataType === "assets") {
fetchPost("/api/history/rollbackAssetsHistory", {
historyPath: target.parentElement.getAttribute("data-path")
});
- } else if (target.parentElement.getAttribute("data-type") === "doc") {
+ } else if (dataType === "doc") {
fetchPost("/api/history/rollbackDocHistory", {
notebook: currentNotebook.id,
historyPath: target.parentElement.getAttribute("data-path")
});
- } else {
+ } else if (dataType === "notebook") {
fetchPost("/api/history/rollbackNotebookHistory", {
historyPath: target.parentElement.getAttribute("data-path")
});
+ } else {
+ fetchPost("/api/repo/checkoutRepo", {
+ id: target.parentElement.getAttribute("data-id")
+ });
}
});
break;
@@ -304,33 +329,34 @@ export const openHistory = () => {
break;
} else if (target.classList.contains("b3-list-item") && type !== "notebook") {
const dataPath = target.getAttribute("data-path");
- if (dataPath) {
- let currentItem;
- if (type === "assets") {
- const type = dataPath.substr(dataPath.lastIndexOf(".")).toLowerCase();
- if (Constants.SIYUAN_ASSETS_IMAGE.includes(type)) {
- firstPanelElement.nextElementSibling.lastElementChild.innerHTML = `
`;
- } else if (Constants.SIYUAN_ASSETS_AUDIO.includes(type)) {
- firstPanelElement.nextElementSibling.lastElementChild.innerHTML = ``;
- } else if (Constants.SIYUAN_ASSETS_VIDEO.includes(type)) {
- firstPanelElement.nextElementSibling.lastElementChild.innerHTML = ``;
- } else {
- firstPanelElement.nextElementSibling.lastElementChild.innerHTML = dataPath;
- }
- currentItem = firstPanelElement.nextElementSibling.querySelector(".b3-list-item--focus");
- } else if (type === "doc") {
- fetchPost("/api/history/getDocHistoryContent", {
- historyPath: dataPath
- }, (response) => {
- firstPanelElement.lastElementChild.innerHTML = response.data.content;
- });
- currentItem = firstPanelElement.querySelector(".b3-list-item--focus");
+ if (type === "assets") {
+ const type = dataPath.substr(dataPath.lastIndexOf(".")).toLowerCase();
+ if (Constants.SIYUAN_ASSETS_IMAGE.includes(type)) {
+ firstPanelElement.nextElementSibling.lastElementChild.innerHTML = `
`;
+ } else if (Constants.SIYUAN_ASSETS_AUDIO.includes(type)) {
+ firstPanelElement.nextElementSibling.lastElementChild.innerHTML = ``;
+ } else if (Constants.SIYUAN_ASSETS_VIDEO.includes(type)) {
+ firstPanelElement.nextElementSibling.lastElementChild.innerHTML = ``;
+ } else {
+ firstPanelElement.nextElementSibling.lastElementChild.innerHTML = dataPath;
}
+ } else if (type === "doc") {
+ fetchPost("/api/history/getDocHistoryContent", {
+ historyPath: dataPath
+ }, (response) => {
+ firstPanelElement.lastElementChild.innerHTML = response.data.content;
+ });
+ } else if (type === "repo") {
+ target.parentElement.nextElementSibling.innerHTML = target.getAttribute("data-memo");
+ }
+ let currentItem = hasClosestByClassName(target, "b3-list") as HTMLElement
+ if (currentItem) {
+ currentItem = currentItem.querySelector(".b3-list-item--focus")
if (currentItem) {
currentItem.classList.remove("b3-list-item--focus");
}
- target.classList.add("b3-list-item--focus");
}
+ target.classList.add("b3-list-item--focus");
break;
} else if (type === "genRepo") {
const genRepoDialog = new Dialog({
@@ -352,10 +378,15 @@ export const openHistory = () => {
});
btnsElement[1].addEventListener("click", () => {
fetchPost("/api/repo/indexRepo", {message: textAreaElement.value}, () => {
- renderRepo(dialog.element.querySelector('#historyContainer [data-type="repo"]'))
+ renderRepo(repoElement, 1)
})
genRepoDialog.destroy();
});
+ 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);
+ break;
}
target = target.parentElement;
}