diff --git a/app/src/assets/scss/mobile.scss b/app/src/assets/scss/mobile.scss index 7c221c803..b47e271c8 100644 --- a/app/src/assets/scss/mobile.scss +++ b/app/src/assets/scss/mobile.scss @@ -292,6 +292,15 @@ flex: 1; } } + + .history__repo > .fn__flex-1 { + flex-direction: column; + + ul { + width: auto !important; + flex: 1; + } + } } @media (max-width: 620px) { diff --git a/app/src/mobile/util/menu.ts b/app/src/mobile/util/menu.ts index 840795274..248c2f5c0 100644 --- a/app/src/mobile/util/menu.ts +++ b/app/src/mobile/util/menu.ts @@ -13,6 +13,7 @@ import {showMessage} from "../../dialog/message"; import {exitSiYuan} from "../../dialog/processSystem"; import {confirmDialog} from "../../dialog/confirmDialog"; import {openHistory} from "../../util/history"; +import {Dialog} from "../../dialog"; const showAccountInfo = (modelElement: HTMLElement, modelMainElement: Element) => { closePanel(); @@ -204,6 +205,21 @@ ${accountHTML}
${window.siyuan.languages.about6}
+
+ ${window.siyuan.languages.dataRepoKey} +
+ + + +
${window.siyuan.languages.dataRepoKeyTip1}
+
${window.siyuan.languages.dataRepoKeyTip2}
+
${window.siyuan.languages.about13} ${window.siyuan.config.api.token} @@ -261,6 +277,47 @@ ${accountHTML} authCodeElement.addEventListener("click", () => { setAccessAuthCode(); }); + const importKeyElement = modelMainElement.querySelector("#importKey"); + importKeyElement.addEventListener("click", () => { + const passwordDialog = new Dialog({ + title: window.siyuan.languages.key, + content: `
+ +
+
+
+ +
`, + width: "80vw", + }); + const textAreaElement = passwordDialog.element.querySelector("textarea"); + textAreaElement.focus(); + const btnsElement = passwordDialog.element.querySelectorAll(".b3-button"); + btnsElement[0].addEventListener("click", () => { + passwordDialog.destroy(); + }); + btnsElement[1].addEventListener("click", () => { + fetchPost("/api/repo/importRepoKey", {key: textAreaElement.value}, () => { + window.siyuan.config.repo.key = textAreaElement.value; + importKeyElement.classList.add("fn__none"); + importKeyElement.previousElementSibling.classList.add("fn__none"); + importKeyElement.nextElementSibling.classList.remove("fn__none"); + passwordDialog.destroy(); + }); + }); + }); + modelMainElement.querySelector("#initKey").addEventListener("click", () => { + fetchPost("/api/repo/initRepoKey", {}, (response) => { + window.siyuan.config.repo.key = response.data.key; + importKeyElement.classList.add("fn__none"); + importKeyElement.previousElementSibling.classList.add("fn__none"); + importKeyElement.nextElementSibling.classList.remove("fn__none"); + }); + }); + modelMainElement.querySelector("#copyKey").addEventListener("click", () => { + showMessage(window.siyuan.languages.copied); + writeText(window.siyuan.config.repo.key); + }); modelMainElement.querySelector("#token").addEventListener("click", () => { writeText(window.siyuan.config.api.token); }); diff --git a/app/src/protyle/header/Title.ts b/app/src/protyle/header/Title.ts index d2193f480..3597a6d87 100644 --- a/app/src/protyle/header/Title.ts +++ b/app/src/protyle/header/Title.ts @@ -183,6 +183,30 @@ export class Title { submenu: copySubMenu(protyle.block.rootID, "") }).element); if (!window.siyuan.config.readonly) { + window.siyuan.menus.menu.append(movePathToMenu(protyle.notebookId, protyle.path)); + window.siyuan.menus.menu.append(new MenuItem({ + icon: "iconTrashcan", + label: window.siyuan.languages.delete, + click: () => { + fetchPost("/api/block/getDocInfo", { + id: protyle.block.rootID + }, (response) => { + let tip = `${window.siyuan.languages.confirmDelete} ${escapeHtml(this.editElement.textContent)}?`; + if (response.data.subFileCount > 0) { + tip = `${window.siyuan.languages.confirmDelete} ${escapeHtml(this.editElement.textContent)} ${window.siyuan.languages.andSubFile.replace("x", response.data.subFileCount)}?`; + } + confirmDialog(window.siyuan.languages.delete, tip, () => { + fetchPost("/api/filetree/removeDoc", { + notebook: protyle.notebookId, + path: protyle.path + }); + }); + }); + } + }).element); + } + if (!window.siyuan.config.readonly) { + window.siyuan.menus.menu.append(new MenuItem({type: "separator"}).element); window.siyuan.menus.menu.append(new MenuItem({ label: window.siyuan.languages.attr, accelerator: window.siyuan.config.keymap.editor.general.attr.custom + "/" + updateHotkeyTip("⇧Click"), @@ -190,38 +214,8 @@ export class Title { openFileAttr(response.data.ial, protyle.block.rootID); } }).element); - window.siyuan.menus.menu.append(movePathToMenu(protyle.notebookId, protyle.path)); } window.siyuan.menus.menu.append(new MenuItem({type: "separator"}).element); - window.siyuan.menus.menu.append(new MenuItem({ - label: window.siyuan.languages.wechatReminder, - icon: "iconMp", - click() { - openFileWechatNotify(protyle); - } - }).element); - window.siyuan.menus.menu.append(new MenuItem({type: "separator"}).element); - window.siyuan.menus.menu.append(new MenuItem({ - icon: "iconTrashcan", - label: window.siyuan.languages.delete, - click: () => { - fetchPost("/api/block/getDocInfo", { - id: protyle.block.rootID - }, (response) => { - let tip = `${window.siyuan.languages.confirmDelete} ${escapeHtml(this.editElement.textContent)}?`; - if (response.data.subFileCount > 0) { - tip = `${window.siyuan.languages.confirmDelete} ${escapeHtml(this.editElement.textContent)} ${window.siyuan.languages.andSubFile.replace("x", response.data.subFileCount)}?`; - } - confirmDialog(window.siyuan.languages.delete, tip, () => { - fetchPost("/api/filetree/removeDoc", { - notebook: protyle.notebookId, - path: protyle.path - }); - }); - }); - } - }).element); - window.siyuan.menus.menu.append(new MenuItem({type: "separator"}).element); window.siyuan.menus.menu.append(new MenuItem({ icon: "iconAlignCenter", label: window.siyuan.languages.outline, @@ -247,6 +241,14 @@ export class Title { } }).element); window.siyuan.menus.menu.append(new MenuItem({type: "separator"}).element); + window.siyuan.menus.menu.append(new MenuItem({ + label: window.siyuan.languages.wechatReminder, + icon: "iconMp", + click() { + openFileWechatNotify(protyle); + } + }).element); + window.siyuan.menus.menu.append(new MenuItem({type: "separator"}).element); window.siyuan.menus.menu.append(new MenuItem({ type: "readonly", label: `${window.siyuan.languages.modifiedAt} ${dayjs(response.data.ial.updated).format("YYYY-MM-DD HH:mm:ss")}