@@ -188,10 +199,49 @@ export const about = {
workspaceDirElement.value = window.siyuan.config.system.workspaceDir;
});
/// #endif
- const authCodeElement = about.element.querySelector("#authCode") as HTMLInputElement;
- authCodeElement.addEventListener("click", () => {
+ about.element.querySelector("#authCode").addEventListener("click", () => {
setAccessAuthCode();
});
+ const importKeyElement = about.element.querySelector("#importKey")
+ importKeyElement.addEventListener("click", () => {
+ const passwordDialog = new Dialog({
+ title: window.siyuan.languages.password,
+ content: `
+
+
+
+
+
+
`,
+ width: isMobile() ? "80vw" : "520px",
+ });
+ 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");
+ })
+ });
+ });
+ about.element.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");
+ })
+ });
+ about.element.querySelector("#copyKey").addEventListener("click", () => {
+ showMessage(window.siyuan.languages.copied)
+ writeText(window.siyuan.config.repo.key)
+ });
const networkServeElement = about.element.querySelector("#networkServe") as HTMLInputElement;
networkServeElement.addEventListener("change", () => {
fetchPost("/api/system/setNetworkServe", {networkServe: networkServeElement.checked}, () => {
diff --git a/app/src/types/index.d.ts b/app/src/types/index.d.ts
index 672ce2f47..7949fe022 100644
--- a/app/src/types/index.d.ts
+++ b/app/src/types/index.d.ts
@@ -238,6 +238,9 @@ declare interface IAccount {
}
declare interface IConfig {
+ repo: {
+ key: string
+ },
e2eePasswd: string
e2eePasswdMode: number
sync: {