diff --git a/app/src/config/about.ts b/app/src/config/about.ts index b6a318cb3..384fc0f70 100644 --- a/app/src/config/about.ts +++ b/app/src/config/about.ts @@ -227,6 +227,7 @@ export const about = { importKeyElement.classList.add("fn__none"); importKeyElement.previousElementSibling.classList.add("fn__none"); importKeyElement.nextElementSibling.classList.remove("fn__none"); + passwordDialog.destroy(); }) }); }); diff --git a/app/src/constants.ts b/app/src/constants.ts index 47a929a3b..05d313d2c 100644 --- a/app/src/constants.ts +++ b/app/src/constants.ts @@ -288,7 +288,7 @@ export abstract class Constants { hotkeyLangId: "outline", }, { type: "inbox", - size: {width: 250, height: 0}, + size: {width: 252, height: 0}, show: false, icon: "iconInbox", hotkeyLangId: "inbox", diff --git a/app/src/util/history.ts b/app/src/util/history.ts index 657fda034..b7210dda5 100644 --- a/app/src/util/history.ts +++ b/app/src/util/history.ts @@ -5,6 +5,7 @@ import {Constants} from "../constants"; import {MenuItem} from "../menus/Menu"; import {unicode2Emoji} from "../emoji"; import {escapeHtml} from "./escape"; +import {isMobile} from "./functions"; const renderDoc = (notebook: INotebook, element: HTMLElement) => { if (!notebook || !notebook.id) { @@ -27,7 +28,7 @@ const renderDoc = (notebook: INotebook, element: HTMLElement) => { } let logsHTML = switchHTML; response.data.histories.forEach((item: { items: { path: string, title: string }[], time: string }, index: number) => { - logsHTML += `
  • + logsHTML += `
  • 0 ? "" : " fn__hidden"}"> ${item.time}
  • `; @@ -67,7 +68,7 @@ const renderAssets = (element: HTMLElement) => { } let logsHTML = ""; response.data.histories.forEach((item: { items: { path: string, title: string }[], time: string }, index: number) => { - logsHTML += `
  • + logsHTML += `
  • 0 ? "" : " fn__hidden"}"> ${item.time}
  • `; @@ -101,6 +102,36 @@ const renderAssets = (element: HTMLElement) => { element.firstElementChild.innerHTML = logsHTML; }); }; +const renderRepo = (element: HTMLElement) => { + element.setAttribute("data-init", "true"); + fetchPost("/api/repo/getRepoIndexLogs", {page: 1}, (response) => { + if (response.data.histories.length === 0) { + element.innerHTML = `
  • ${window.siyuan.languages.emptyContent}
  • `; + return; + } + let logsHTML = ""; + response.data.histories.forEach((item: { items: { path: string, title: string }[], time: string }, index: number) => { + logsHTML += `
  • + 0 ? "" : " fn__hidden"}"> + ${item.time} +
  • `; + if (item.items.length > 0) { + logsHTML += `"; + } + }); + element.innerHTML = logsHTML; + }); +}; const renderRmNotebook = (element: HTMLElement) => { element.setAttribute("data-init", "true"); @@ -111,7 +142,7 @@ const renderRmNotebook = (element: HTMLElement) => { } let logsHTML = ""; response.data.histories.forEach((item: { items: { path: string, title: string }[], time: string }, index: number) => { - logsHTML += `
  • + logsHTML += `
  • 0 ? "" : " fn__hidden"}"> ${item.time}
  • `; @@ -150,6 +181,7 @@ export const openHistory = () => {
    ${window.siyuan.languages.doc}
    ${window.siyuan.languages.assets}
    ${window.siyuan.languages.removedNotebook}
    +
    ${window.siyuan.languages.xxx}
    @@ -167,6 +199,9 @@ export const openHistory = () => { +
    + +
    `, width: "80vw", @@ -202,19 +237,21 @@ export const openHistory = () => { dialog.element.addEventListener("click", (event) => { let target = event.target as HTMLElement; while (target && !target.isEqualNode(dialog.element)) { + const type = target.getAttribute("data-type") if (target.classList.contains("item")) { - const currentType = target.getAttribute("data-type"); target.parentElement.querySelector(".item--focus").classList.remove("item--focus"); Array.from(dialog.element.querySelector("#historyContainer").children).forEach((item: HTMLElement) => { - if (item.getAttribute("data-type") === currentType) { + if (item.getAttribute("data-type") === type) { item.classList.remove("fn__none"); item.classList.add("fn__block"); target.classList.add("item--focus"); if (item.getAttribute("data-init") !== "true") { - if (currentType === "assets") { + if (type === "assets") { renderAssets(item); - } else if (currentType === "notebook") { + } else if (type === "notebook") { renderRmNotebook(item); + } else if (type === "repo") { + renderRepo(item); } } } else { @@ -223,7 +260,7 @@ export const openHistory = () => { } }); break; - } else if (target.getAttribute("data-type") === "switchNotebook") { + } else if (type === "switchNotebook") { window.siyuan.menus.menu.remove(); window.siyuan.notebooks.forEach(item => { if (!item.closed) { @@ -260,20 +297,15 @@ export const openHistory = () => { } }); break; - } else if (target.classList.contains("b3-list-item")) { - if (!target.classList.contains("b3-list-item--hide-action")) { - if (target.getAttribute("data-type") === "notebook") { - break; - } - target.nextElementSibling.classList.toggle("fn__none"); - target.firstElementChild.firstElementChild.classList.toggle("b3-list-item__arrow--open"); - break; - } + } else if (type === "toggle") { + target.nextElementSibling.classList.toggle("fn__none"); + target.firstElementChild.firstElementChild.classList.toggle("b3-list-item__arrow--open"); + break; + } else if (target.classList.contains("b3-list-item") && type !== "notebook") { const dataPath = target.getAttribute("data-path"); - const dataType = target.getAttribute("data-type"); - if (dataPath && dataType !== "notebook") { + if (dataPath) { let currentItem; - if (dataType === "assets") { + if (type === "assets") { const type = dataPath.substr(dataPath.lastIndexOf(".")).toLowerCase(); if (Constants.SIYUAN_ASSETS_IMAGE.includes(type)) { firstPanelElement.nextElementSibling.lastElementChild.innerHTML = ``; @@ -285,7 +317,7 @@ export const openHistory = () => { firstPanelElement.nextElementSibling.lastElementChild.innerHTML = dataPath; } currentItem = firstPanelElement.nextElementSibling.querySelector(".b3-list-item--focus"); - } else if (dataType === "doc") { + } else if (type === "doc") { fetchPost("/api/history/getDocHistoryContent", { historyPath: dataPath }, (response) => { @@ -299,6 +331,29 @@ export const openHistory = () => { target.classList.add("b3-list-item--focus"); } break; + } else if (type === "genRepo") { + const genRepoDialog = new Dialog({ + title: window.siyuan.languages.memo, + content: `
    + +
    +
    +
    + +
    `, + width: isMobile() ? "80vw" : "520px", + }); + const textAreaElement = genRepoDialog.element.querySelector("textarea"); + textAreaElement.focus(); + const btnsElement = genRepoDialog.element.querySelectorAll(".b3-button"); + btnsElement[0].addEventListener("click", () => { + genRepoDialog.destroy(); + }); + btnsElement[1].addEventListener("click", () => { + fetchPost("/api/repo/indexRepo", {message: textAreaElement.value}, () => { + renderRepo(dialog.element.querySelector('#historyContainer [data-type="repo"]')) + }) + }); } target = target.parentElement; }