mirror of
https://github.com/siyuan-note/siyuan.git
synced 2026-03-02 02:40:15 +01:00
This commit is contained in:
parent
7dbfa43de4
commit
6ca6817465
3 changed files with 49 additions and 78 deletions
|
|
@ -12,6 +12,7 @@ import {showMessage} from "../dialog/message";
|
|||
import {Dialog} from "../dialog";
|
||||
import {confirmDialog} from "../dialog/confirmDialog";
|
||||
import {setProxy} from "./util/setProxy";
|
||||
import {setKey} from "../sync/syncGuide";
|
||||
|
||||
export const about = {
|
||||
element: undefined as Element,
|
||||
|
|
@ -265,39 +266,9 @@ export const about = {
|
|||
});
|
||||
});
|
||||
about.element.querySelector("#initKeyByPW").addEventListener("click", () => {
|
||||
const initDialog = new Dialog({
|
||||
title: "🔑 " + window.siyuan.languages.genKeyByPW,
|
||||
content: `<div class="b3-dialog__content">
|
||||
<input class="b3-text-field fn__block" placeholder="${window.siyuan.languages.password}">
|
||||
</div>
|
||||
<div class="b3-dialog__action">
|
||||
<button class="b3-button b3-button--cancel">${window.siyuan.languages.cancel}</button><div class="fn__space"></div>
|
||||
<button class="b3-button b3-button--text">${window.siyuan.languages.confirm}</button>
|
||||
</div>`,
|
||||
width: "520px",
|
||||
});
|
||||
const inputElement = initDialog.element.querySelector(".b3-text-field") as HTMLInputElement;
|
||||
inputElement.focus();
|
||||
const btnsElement = initDialog.element.querySelectorAll(".b3-button");
|
||||
initDialog.bindInput(inputElement, () => {
|
||||
(btnsElement[1] as HTMLButtonElement).click();
|
||||
});
|
||||
btnsElement[0].addEventListener("click", () => {
|
||||
initDialog.destroy();
|
||||
});
|
||||
btnsElement[1].addEventListener("click", () => {
|
||||
if (!inputElement.value) {
|
||||
showMessage(window.siyuan.languages._kernel[142]);
|
||||
return;
|
||||
}
|
||||
confirmDialog("🔑 " + window.siyuan.languages.genKeyByPW, window.siyuan.languages.initRepoKeyTip, () => {
|
||||
initDialog.destroy();
|
||||
fetchPost("/api/repo/initRepoKeyFromPassphrase", {pass: inputElement.value}, (response) => {
|
||||
window.siyuan.config.repo.key = response.data.key;
|
||||
importKeyElement.parentElement.classList.add("fn__none");
|
||||
importKeyElement.parentElement.nextElementSibling.classList.remove("fn__none");
|
||||
});
|
||||
});
|
||||
setKey(false, () => {
|
||||
importKeyElement.parentElement.classList.add("fn__none");
|
||||
importKeyElement.parentElement.nextElementSibling.classList.remove("fn__none");
|
||||
});
|
||||
});
|
||||
about.element.querySelector("#copyKey").addEventListener("click", () => {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue