2022-05-26 15:18:53 +08:00
|
|
|
import {Constants} from "../constants";
|
|
|
|
|
/// #if !BROWSER
|
2023-04-13 11:49:26 +08:00
|
|
|
import {ipcRenderer, shell} from "electron";
|
2022-05-26 15:18:53 +08:00
|
|
|
/// #endif
|
2022-06-14 21:16:00 +08:00
|
|
|
import {isBrowser} from "../util/functions";
|
2022-05-26 15:18:53 +08:00
|
|
|
import {fetchPost} from "../util/fetch";
|
2022-10-27 19:34:26 +08:00
|
|
|
import {setAccessAuthCode} from "./util/setAccessAuthCode";
|
2022-05-26 15:18:53 +08:00
|
|
|
import {exportLayout} from "../layout/util";
|
2023-01-24 12:13:57 +08:00
|
|
|
import {exitSiYuan, processSync} from "../dialog/processSystem";
|
2022-08-27 21:09:40 +08:00
|
|
|
import {openByMobile, writeText} from "../protyle/util/compatibility";
|
2022-06-13 21:28:18 +08:00
|
|
|
import {showMessage} from "../dialog/message";
|
|
|
|
|
import {Dialog} from "../dialog";
|
2022-06-18 22:47:53 +08:00
|
|
|
import {confirmDialog} from "../dialog/confirmDialog";
|
2023-04-13 11:49:26 +08:00
|
|
|
import {setProxy} from "./util/setProxy";
|
2022-05-26 15:18:53 +08:00
|
|
|
|
|
|
|
|
export const about = {
|
|
|
|
|
element: undefined as Element,
|
|
|
|
|
genHTML: () => {
|
2022-12-09 16:35:11 +08:00
|
|
|
return `<label class="fn__flex b3-label${isBrowser() || "std" !== window.siyuan.config.system.container || "linux" === window.siyuan.config.system.os ? " fn__none" : ""}">
|
|
|
|
|
<div class="fn__flex-1">
|
|
|
|
|
${window.siyuan.languages.autoLaunch}
|
|
|
|
|
<div class="b3-label__text">${window.siyuan.languages.autoLaunchTip}</div>
|
|
|
|
|
</div>
|
|
|
|
|
<div class="fn__space"></div>
|
|
|
|
|
<input class="b3-switch fn__flex-center" id="autoLaunch" type="checkbox"${window.siyuan.config.system.autoLaunch ? " checked" : ""}>
|
|
|
|
|
</label>
|
2023-02-09 20:44:09 +08:00
|
|
|
<label class="fn__flex b3-label${isBrowser() || window.siyuan.config.system.isMicrosoftStore || window.siyuan.config.system.container !== "std" ? " fn__none" : ""}">
|
2022-09-08 22:29:03 +08:00
|
|
|
<div class="fn__flex-1">
|
|
|
|
|
${window.siyuan.languages.autoDownloadUpdatePkg}
|
|
|
|
|
<div class="b3-label__text">${window.siyuan.languages.autoDownloadUpdatePkgTip}</div>
|
|
|
|
|
</div>
|
|
|
|
|
<div class="fn__space"></div>
|
|
|
|
|
<input class="b3-switch fn__flex-center" id="downloadInstallPkg" type="checkbox"${window.siyuan.config.system.downloadInstallPkg ? " checked" : ""}>
|
2022-10-18 00:03:34 +08:00
|
|
|
</label>
|
2022-10-30 00:31:23 +08:00
|
|
|
<label class="b3-label fn__flex">
|
|
|
|
|
<div class="fn__flex-1">
|
|
|
|
|
${window.siyuan.languages.googleAnalytics}
|
|
|
|
|
<div class="b3-label__text">${window.siyuan.languages.googleAnalyticsTip}</div>
|
|
|
|
|
</div>
|
|
|
|
|
<div class="fn__space"></div>
|
2022-10-30 00:42:28 +08:00
|
|
|
<input class="b3-switch fn__flex-center" id="googleAnalytics" type="checkbox"${window.siyuan.config.system.disableGoogleAnalytics ? "" : " checked"}>
|
2022-10-30 00:31:23 +08:00
|
|
|
</label>
|
2022-10-18 00:03:34 +08:00
|
|
|
<label class="b3-label fn__flex">
|
2022-09-08 22:29:03 +08:00
|
|
|
<div class="fn__flex-1">
|
|
|
|
|
${window.siyuan.languages.about9}
|
|
|
|
|
<div class="b3-label__text">${window.siyuan.languages.about10}</div>
|
|
|
|
|
</div>
|
|
|
|
|
<div class="fn__space"></div>
|
|
|
|
|
<input class="b3-switch fn__flex-center" id="uploadErrLog" type="checkbox"${window.siyuan.config.system.uploadErrLog ? " checked" : ""}>
|
2022-10-18 00:03:34 +08:00
|
|
|
</label>
|
|
|
|
|
<label class="b3-label fn__flex">
|
2022-05-26 15:18:53 +08:00
|
|
|
<div class="fn__flex-1">
|
|
|
|
|
${window.siyuan.languages.about11}
|
|
|
|
|
<div class="b3-label__text">${window.siyuan.languages.about12}</div>
|
|
|
|
|
</div>
|
|
|
|
|
<div class="fn__space"></div>
|
|
|
|
|
<input class="b3-switch fn__flex-center" id="networkServe" type="checkbox"${window.siyuan.config.system.networkServe ? " checked" : ""}>
|
2022-10-18 00:03:34 +08:00
|
|
|
</label>
|
2023-01-02 16:12:03 +08:00
|
|
|
<label class="b3-label config__item${isBrowser() ? " fn__none" : " fn__flex"}">
|
2022-05-26 15:18:53 +08:00
|
|
|
<div class="fn__flex-1">
|
|
|
|
|
${window.siyuan.languages.about2}
|
2022-10-25 09:27:14 +08:00
|
|
|
<div class="b3-label__text">${window.siyuan.languages.about3.replace("${port}", location.port)}</div>
|
2022-08-12 12:08:16 +08:00
|
|
|
<span class="b3-label__text"><code class="fn__code">${window.siyuan.config.localIPs.join("</code> <code class='fn__code'>")}</code></span>
|
2023-01-31 17:03:06 +08:00
|
|
|
|
2022-05-26 15:18:53 +08:00
|
|
|
</div>
|
|
|
|
|
<div class="fn__space"></div>
|
2022-10-29 21:47:10 +08:00
|
|
|
<button data-type="open" data-url="http://${window.siyuan.config.system.networkServe ? window.siyuan.config.localIPs[0] : "127.0.0.1"}:${location.port}" class="b3-button b3-button--outline fn__size200 fn__flex-center">
|
2022-08-27 21:34:19 +08:00
|
|
|
<svg><use xlink:href="#iconLink"></use></svg>${window.siyuan.languages.about4}
|
|
|
|
|
</button>
|
2022-10-18 00:03:34 +08:00
|
|
|
</label>
|
2023-01-02 16:12:03 +08:00
|
|
|
<label class="b3-label fn__flex config__item">
|
2022-05-26 15:18:53 +08:00
|
|
|
<div class="fn__flex-1">
|
|
|
|
|
${window.siyuan.languages.about5}
|
|
|
|
|
<div class="b3-label__text">${window.siyuan.languages.about6}</div>
|
|
|
|
|
</div>
|
|
|
|
|
<div class="fn__space"></div>
|
|
|
|
|
<button class="fn__flex-center b3-button b3-button--outline fn__size200" id="authCode">
|
|
|
|
|
<svg><use xlink:href="#iconLock"></use></svg>${window.siyuan.languages.config}
|
|
|
|
|
</button>
|
2022-10-18 00:03:34 +08:00
|
|
|
</label>
|
2023-01-02 16:12:03 +08:00
|
|
|
<div class="b3-label fn__flex config__item">
|
2022-06-13 21:28:18 +08:00
|
|
|
<div class="fn__flex-1 fn__flex-center">
|
2022-06-13 23:15:00 +08:00
|
|
|
${window.siyuan.languages.dataRepoKey}
|
|
|
|
|
<div class="b3-label__text">${window.siyuan.languages.dataRepoKeyTip1}</div>
|
|
|
|
|
<div class="b3-label__text ft__error">${window.siyuan.languages.dataRepoKeyTip2}</div>
|
2022-06-13 20:36:06 +08:00
|
|
|
</div>
|
|
|
|
|
<div class="fn__space"></div>
|
2023-01-02 16:12:03 +08:00
|
|
|
<div class="fn__size200 config__item-line fn__flex-center${window.siyuan.config.repo.key ? " fn__none" : ""}">
|
|
|
|
|
<button class="b3-button b3-button--outline fn__block" id="importKey">
|
2022-07-21 23:47:02 +08:00
|
|
|
<svg><use xlink:href="#iconDownload"></use></svg>${window.siyuan.languages.importKey}
|
|
|
|
|
</button>
|
|
|
|
|
<div class="fn__hr"></div>
|
2023-01-02 16:12:03 +08:00
|
|
|
<button class="b3-button b3-button--outline fn__block" id="initKey">
|
2022-06-13 23:23:08 +08:00
|
|
|
<svg><use xlink:href="#iconLock"></use></svg>${window.siyuan.languages.genKey}
|
2022-06-13 21:28:18 +08:00
|
|
|
</button>
|
2022-06-18 22:47:53 +08:00
|
|
|
<div class="fn__hr"></div>
|
2023-01-02 16:12:03 +08:00
|
|
|
<button class="b3-button b3-button--outline fn__block" id="initKeyByPW">
|
2022-08-21 14:15:13 +08:00
|
|
|
<svg><use xlink:href="#iconHand"></use></svg>${window.siyuan.languages.genKeyByPW}
|
2022-07-21 23:43:47 +08:00
|
|
|
</button>
|
2022-06-18 22:47:53 +08:00
|
|
|
</div>
|
2023-01-02 16:12:03 +08:00
|
|
|
<div class="fn__size200 config__item-line fn__flex-center${window.siyuan.config.repo.key ? "" : " fn__none"}">
|
|
|
|
|
<button class="b3-button b3-button--outline fn__block" id="copyKey">
|
2022-06-13 23:23:08 +08:00
|
|
|
<svg><use xlink:href="#iconCopy"></use></svg>${window.siyuan.languages.copyKey}
|
2022-06-13 21:28:18 +08:00
|
|
|
</button>
|
2022-06-18 22:47:53 +08:00
|
|
|
<div class="fn__hr"></div>
|
2023-01-02 16:12:03 +08:00
|
|
|
<button class="b3-button b3-button--outline fn__block" id="resetRepo">
|
2022-06-18 23:11:03 +08:00
|
|
|
<svg><use xlink:href="#iconTrashcan"></use></svg>${window.siyuan.languages.resetRepo}
|
2022-06-18 22:47:53 +08:00
|
|
|
</button>
|
2022-06-13 21:28:18 +08:00
|
|
|
</div>
|
2022-05-26 15:18:53 +08:00
|
|
|
</div>
|
2023-04-20 18:54:24 +08:00
|
|
|
<label class="fn__flex b3-label config__item">
|
|
|
|
|
<div class="fn__flex-1">
|
|
|
|
|
${window.siyuan.languages.dataRepoPurge}
|
|
|
|
|
<div class="b3-label__text">${window.siyuan.languages.dataRepoPurgeTip}</div>
|
|
|
|
|
</div>
|
|
|
|
|
<div class="fn__space"></div>
|
|
|
|
|
<button id="purgeRepo" class="b3-button b3-button--outline fn__size200 fn__flex-center">
|
|
|
|
|
<svg><use xlink:href="#iconUpload"></use></svg>${window.siyuan.languages.purge}
|
|
|
|
|
</button>
|
|
|
|
|
</label>
|
2023-01-02 16:12:03 +08:00
|
|
|
<label class="fn__flex b3-label config__item">
|
2022-09-08 22:29:03 +08:00
|
|
|
<div class="fn__flex-1">
|
|
|
|
|
${window.siyuan.languages.systemLog}
|
|
|
|
|
<div class="b3-label__text">${window.siyuan.languages.systemLogTip}</div>
|
|
|
|
|
</div>
|
|
|
|
|
<div class="fn__space"></div>
|
|
|
|
|
<button id="exportLog" class="b3-button b3-button--outline fn__size200 fn__flex-center">
|
|
|
|
|
<svg><use xlink:href="#iconUpload"></use></svg>${window.siyuan.languages.export}
|
|
|
|
|
</button>
|
2022-10-18 00:03:34 +08:00
|
|
|
</label>
|
2023-01-02 16:12:03 +08:00
|
|
|
<label class="fn__flex b3-label config__item">
|
2022-05-26 15:18:53 +08:00
|
|
|
<div class="fn__flex-1">
|
|
|
|
|
${window.siyuan.languages.currentVer} v${Constants.SIYUAN_VERSION}
|
|
|
|
|
<span id="isInsider"></span>
|
|
|
|
|
<div class="b3-label__text">${window.siyuan.languages.visitAnnouncements}</div>
|
|
|
|
|
</div>
|
|
|
|
|
<div class="fn__space"></div>
|
2023-01-02 16:12:03 +08:00
|
|
|
<div class="fn__flex-center fn__size200 config__item-line">
|
|
|
|
|
<button id="checkUpdateBtn" class="b3-button b3-button--outline fn__block">
|
2022-09-17 12:19:03 +08:00
|
|
|
<svg><use xlink:href="#iconRefresh"></use></svg>${window.siyuan.languages.checkUpdate}
|
|
|
|
|
</button>
|
|
|
|
|
<div class="fn__hr${isBrowser() ? "" : " fn__none"}"></div>
|
2023-03-13 11:12:00 +08:00
|
|
|
<button id="menuSafeQuit" class="b3-button b3-button--outline fn__block${(window.webkit?.messageHandlers || window.JSAndroid) ? "" : " fn__none"}">
|
2022-09-17 12:19:03 +08:00
|
|
|
<svg><use xlink:href="#iconQuit"></use></svg>${window.siyuan.languages.safeQuit}
|
|
|
|
|
</button>
|
|
|
|
|
</div>
|
2022-10-18 00:03:34 +08:00
|
|
|
</label>
|
2023-01-02 16:12:03 +08:00
|
|
|
<label class="fn__flex config__item b3-label">
|
2022-08-27 21:34:19 +08:00
|
|
|
<div class="fn__flex-1">
|
2022-09-08 22:29:03 +08:00
|
|
|
${window.siyuan.languages.about13}
|
|
|
|
|
<div class="b3-label__text">${window.siyuan.languages.about14}</div>
|
2022-08-27 21:09:40 +08:00
|
|
|
</div>
|
2022-09-08 22:29:03 +08:00
|
|
|
<span class="fn__space"></span>
|
|
|
|
|
<input class="b3-text-field fn__flex-center fn__size200" id="token" value="${window.siyuan.config.api.token}" readonly="readonly">
|
|
|
|
|
</label>
|
|
|
|
|
<div class="b3-label${(window.siyuan.config.system.container === "std" || window.siyuan.config.system.container === "docker") ? "" : " fn__none"}">
|
|
|
|
|
${window.siyuan.languages.networkProxy}
|
|
|
|
|
<div class="b3-label__text">
|
|
|
|
|
${window.siyuan.languages.about17}
|
|
|
|
|
</div>
|
2023-01-02 16:12:03 +08:00
|
|
|
<div class="b3-label__text fn__flex config__item" style="padding: 4px 0 4px 4px;">
|
2022-09-08 22:29:03 +08:00
|
|
|
<select id="aboutScheme" class="b3-select">
|
|
|
|
|
<option value="" ${window.siyuan.config.system.networkProxy.scheme === "" ? "selected" : ""}>${window.siyuan.languages.directConnection}</option>
|
|
|
|
|
<option value="socks5" ${window.siyuan.config.system.networkProxy.scheme === "socks5" ? "selected" : ""}>SOCKS5</option>
|
2022-09-14 18:04:12 +08:00
|
|
|
<option value="https" ${window.siyuan.config.system.networkProxy.scheme === "https" ? "selected" : ""}>HTTPS</option>
|
2023-02-28 08:48:14 +08:00
|
|
|
<option value="http" ${window.siyuan.config.system.networkProxy.scheme === "http" ? "selected" : ""}>HTTP</option>
|
2022-09-08 22:29:03 +08:00
|
|
|
</select>
|
|
|
|
|
<span class="fn__space"></span>
|
2023-01-02 16:12:03 +08:00
|
|
|
<input id="aboutHost" placeholder="Host/IP" class="b3-text-field fn__block" value="${window.siyuan.config.system.networkProxy.host}"/>
|
2022-09-08 22:29:03 +08:00
|
|
|
<span class="fn__space"></span>
|
2023-01-02 16:12:03 +08:00
|
|
|
<input id="aboutPort" placeholder="Port" class="b3-text-field fn__block" value="${window.siyuan.config.system.networkProxy.port}" type="number"/>
|
2022-09-08 22:29:03 +08:00
|
|
|
<span class="fn__space"></span>
|
2023-01-02 16:12:03 +08:00
|
|
|
<button id="aboutConfirm" class="b3-button fn__size200 b3-button--outline">${window.siyuan.languages.confirm}</button>
|
2022-05-26 15:18:53 +08:00
|
|
|
</div>
|
|
|
|
|
</div>
|
|
|
|
|
<div class="b3-label">
|
|
|
|
|
<div class="config-about__logo">
|
|
|
|
|
<img src="/stage/icon.png">
|
|
|
|
|
<span>${window.siyuan.languages.siyuanNote}</span>
|
|
|
|
|
<span class="fn__space"></span>
|
|
|
|
|
<span class="ft__on-surface">${window.siyuan.languages.slogan}</span>
|
|
|
|
|
<span class="fn__space"></span>
|
|
|
|
|
<span style="color:var(--b3-theme-background);font-family: cursive;">会泽百家 至公天下</span>
|
|
|
|
|
</div>
|
|
|
|
|
<div class='fn__hr'></div>
|
|
|
|
|
${window.siyuan.languages.about1}
|
|
|
|
|
</div>`;
|
|
|
|
|
},
|
|
|
|
|
bindEvent: () => {
|
|
|
|
|
if (window.siyuan.config.system.isInsider) {
|
|
|
|
|
about.element.querySelector("#isInsider").innerHTML = "<span class='ft__secondary'>Insider Preview</span>";
|
|
|
|
|
}
|
|
|
|
|
const tokenElement = about.element.querySelector("#token") as HTMLInputElement;
|
|
|
|
|
tokenElement.addEventListener("click", () => {
|
|
|
|
|
tokenElement.select();
|
|
|
|
|
});
|
2022-08-27 21:09:40 +08:00
|
|
|
about.element.querySelector("#exportLog").addEventListener("click", () => {
|
|
|
|
|
fetchPost("/api/system/exportLog", {}, (response) => {
|
|
|
|
|
openByMobile(response.data.zip);
|
2022-08-28 12:44:28 +08:00
|
|
|
});
|
2022-08-27 21:09:40 +08:00
|
|
|
});
|
2022-09-17 12:19:03 +08:00
|
|
|
about.element.querySelector("#menuSafeQuit").addEventListener("click", () => {
|
|
|
|
|
exitSiYuan();
|
|
|
|
|
});
|
2022-05-26 15:18:53 +08:00
|
|
|
const updateElement = about.element.querySelector("#checkUpdateBtn");
|
|
|
|
|
updateElement.addEventListener("click", () => {
|
2022-09-01 11:22:50 +08:00
|
|
|
if (updateElement.firstElementChild.classList.contains("fn__rotate")) {
|
2022-05-26 15:18:53 +08:00
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
updateElement.innerHTML = `<svg class="fn__rotate"><use xlink:href="#iconRefresh"></use></svg>${window.siyuan.languages.checkUpdate}`;
|
|
|
|
|
fetchPost("/api/system/checkUpdate", {showMsg: true}, () => {
|
2022-09-01 11:22:50 +08:00
|
|
|
updateElement.innerHTML = `<svg><use xlink:href="#iconRefresh"></use></svg>${window.siyuan.languages.checkUpdate}`;
|
2022-05-26 15:18:53 +08:00
|
|
|
});
|
|
|
|
|
});
|
|
|
|
|
/// #if !BROWSER
|
|
|
|
|
about.element.querySelectorAll('[data-type="open"]').forEach(item => {
|
|
|
|
|
item.addEventListener("click", () => {
|
|
|
|
|
const url = item.getAttribute("data-url");
|
|
|
|
|
if (url.startsWith("http")) {
|
|
|
|
|
shell.openExternal(url);
|
|
|
|
|
} else {
|
|
|
|
|
shell.openPath(url);
|
|
|
|
|
}
|
|
|
|
|
});
|
|
|
|
|
});
|
|
|
|
|
/// #endif
|
2022-06-13 21:28:18 +08:00
|
|
|
about.element.querySelector("#authCode").addEventListener("click", () => {
|
2022-05-26 15:18:53 +08:00
|
|
|
setAccessAuthCode();
|
|
|
|
|
});
|
2022-06-14 00:43:25 +08:00
|
|
|
const importKeyElement = about.element.querySelector("#importKey");
|
2022-06-13 21:28:18 +08:00
|
|
|
importKeyElement.addEventListener("click", () => {
|
|
|
|
|
const passwordDialog = new Dialog({
|
2022-07-09 09:45:58 +08:00
|
|
|
title: "🔑 " + window.siyuan.languages.key,
|
2022-06-13 21:28:18 +08:00
|
|
|
content: `<div class="b3-dialog__content">
|
2022-06-13 23:23:08 +08:00
|
|
|
<textarea class="b3-text-field fn__block" placeholder="${window.siyuan.languages.keyPlaceholder}"></textarea>
|
2022-06-13 21:28:18 +08:00
|
|
|
</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>`,
|
2022-06-14 21:16:00 +08:00
|
|
|
width: "520px",
|
2022-06-13 21:28:18 +08:00
|
|
|
});
|
|
|
|
|
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}, () => {
|
2022-06-14 00:43:25 +08:00
|
|
|
window.siyuan.config.repo.key = textAreaElement.value;
|
2022-06-18 22:47:53 +08:00
|
|
|
importKeyElement.parentElement.classList.add("fn__none");
|
|
|
|
|
importKeyElement.parentElement.nextElementSibling.classList.remove("fn__none");
|
2022-06-13 22:10:41 +08:00
|
|
|
passwordDialog.destroy();
|
2022-06-14 00:43:25 +08:00
|
|
|
});
|
2022-06-13 21:28:18 +08:00
|
|
|
});
|
|
|
|
|
});
|
|
|
|
|
about.element.querySelector("#initKey").addEventListener("click", () => {
|
2022-07-09 09:45:58 +08:00
|
|
|
confirmDialog("🔑 " + window.siyuan.languages.genKey, window.siyuan.languages.initRepoKeyTip, () => {
|
2022-07-09 08:51:33 +08:00
|
|
|
fetchPost("/api/repo/initRepoKey", {}, (response) => {
|
|
|
|
|
window.siyuan.config.repo.key = response.data.key;
|
|
|
|
|
importKeyElement.parentElement.classList.add("fn__none");
|
|
|
|
|
importKeyElement.parentElement.nextElementSibling.classList.remove("fn__none");
|
|
|
|
|
});
|
2022-06-14 00:43:25 +08:00
|
|
|
});
|
2022-06-13 21:28:18 +08:00
|
|
|
});
|
2022-07-21 23:43:47 +08:00
|
|
|
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", () => {
|
2022-07-22 00:07:11 +08:00
|
|
|
if (!inputElement.value) {
|
|
|
|
|
showMessage(window.siyuan.languages._kernel[142]);
|
|
|
|
|
return;
|
|
|
|
|
}
|
2022-07-21 23:43:47 +08:00
|
|
|
confirmDialog("🔑 " + window.siyuan.languages.genKeyByPW, window.siyuan.languages.initRepoKeyTip, () => {
|
2022-07-22 00:04:45 +08:00
|
|
|
initDialog.destroy();
|
2022-12-15 10:29:10 +08:00
|
|
|
fetchPost("/api/repo/initRepoKeyFromPassphrase", {pass: inputElement.value}, (response) => {
|
2022-07-21 23:43:47 +08:00
|
|
|
window.siyuan.config.repo.key = response.data.key;
|
|
|
|
|
importKeyElement.parentElement.classList.add("fn__none");
|
|
|
|
|
importKeyElement.parentElement.nextElementSibling.classList.remove("fn__none");
|
|
|
|
|
});
|
|
|
|
|
});
|
|
|
|
|
});
|
|
|
|
|
});
|
2022-06-13 21:28:18 +08:00
|
|
|
about.element.querySelector("#copyKey").addEventListener("click", () => {
|
2022-06-14 00:43:25 +08:00
|
|
|
showMessage(window.siyuan.languages.copied);
|
|
|
|
|
writeText(window.siyuan.config.repo.key);
|
2022-06-13 21:28:18 +08:00
|
|
|
});
|
2022-06-18 23:11:03 +08:00
|
|
|
about.element.querySelector("#resetRepo").addEventListener("click", () => {
|
|
|
|
|
confirmDialog("⚠️ " + window.siyuan.languages.resetRepo, window.siyuan.languages.resetRepoTip, () => {
|
2022-06-18 22:47:53 +08:00
|
|
|
fetchPost("/api/repo/resetRepo", {}, () => {
|
|
|
|
|
window.siyuan.config.repo.key = "";
|
2022-08-22 00:11:32 +08:00
|
|
|
window.siyuan.config.sync.enabled = false;
|
2023-01-24 12:13:57 +08:00
|
|
|
processSync();
|
2022-06-18 22:47:53 +08:00
|
|
|
importKeyElement.parentElement.classList.remove("fn__none");
|
|
|
|
|
importKeyElement.parentElement.nextElementSibling.classList.add("fn__none");
|
|
|
|
|
});
|
|
|
|
|
});
|
|
|
|
|
});
|
2023-04-20 18:54:24 +08:00
|
|
|
about.element.querySelector("#purgeRepo").addEventListener("click", () => {
|
|
|
|
|
confirmDialog("♻️ " + window.siyuan.languages.dataRepoPurge, window.siyuan.languages.dataRepoPurgeConfirm, () => {
|
2023-04-22 15:12:38 +08:00
|
|
|
fetchPost("/api/repo/purgeRepo");
|
2023-04-20 18:54:24 +08:00
|
|
|
});
|
|
|
|
|
});
|
2022-05-26 15:18:53 +08:00
|
|
|
const networkServeElement = about.element.querySelector("#networkServe") as HTMLInputElement;
|
|
|
|
|
networkServeElement.addEventListener("change", () => {
|
|
|
|
|
fetchPost("/api/system/setNetworkServe", {networkServe: networkServeElement.checked}, () => {
|
2023-05-11 12:22:53 +08:00
|
|
|
exportLayout({
|
|
|
|
|
reload: false,
|
|
|
|
|
onlyData: false,
|
|
|
|
|
errorExit: true,
|
|
|
|
|
cb: exitSiYuan
|
|
|
|
|
});
|
2022-05-26 15:18:53 +08:00
|
|
|
});
|
|
|
|
|
});
|
2022-10-30 00:31:23 +08:00
|
|
|
const googleAnalyticsElement = about.element.querySelector("#googleAnalytics") as HTMLInputElement;
|
|
|
|
|
googleAnalyticsElement.addEventListener("change", () => {
|
|
|
|
|
fetchPost("/api/system/setGoogleAnalytics", {googleAnalytics: googleAnalyticsElement.checked}, () => {
|
2023-05-11 12:22:53 +08:00
|
|
|
exportLayout({
|
|
|
|
|
reload: true,
|
|
|
|
|
onlyData: false,
|
|
|
|
|
errorExit: false,
|
|
|
|
|
});
|
2022-10-30 00:31:23 +08:00
|
|
|
});
|
|
|
|
|
});
|
2022-05-26 15:18:53 +08:00
|
|
|
const uploadErrLogElement = about.element.querySelector("#uploadErrLog") as HTMLInputElement;
|
|
|
|
|
uploadErrLogElement.addEventListener("change", () => {
|
|
|
|
|
fetchPost("/api/system/setUploadErrLog", {uploadErrLog: uploadErrLogElement.checked}, () => {
|
2023-05-11 12:22:53 +08:00
|
|
|
exportLayout({
|
|
|
|
|
reload: false,
|
|
|
|
|
onlyData: false,
|
|
|
|
|
errorExit: true,
|
|
|
|
|
cb: exitSiYuan
|
|
|
|
|
});
|
2022-05-26 15:18:53 +08:00
|
|
|
});
|
|
|
|
|
});
|
2022-09-07 22:43:14 +08:00
|
|
|
const downloadInstallPkgElement = about.element.querySelector("#downloadInstallPkg") as HTMLInputElement;
|
|
|
|
|
downloadInstallPkgElement.addEventListener("change", () => {
|
|
|
|
|
fetchPost("/api/system/setDownloadInstallPkg", {downloadInstallPkg: downloadInstallPkgElement.checked}, () => {
|
2022-09-09 09:45:18 +08:00
|
|
|
window.siyuan.config.system.downloadInstallPkg = downloadInstallPkgElement.checked;
|
2022-09-07 22:43:14 +08:00
|
|
|
});
|
|
|
|
|
});
|
2022-12-09 23:12:47 +08:00
|
|
|
/// #if !BROWSER
|
2022-12-09 16:35:11 +08:00
|
|
|
const autoLaunchElement = about.element.querySelector("#autoLaunch") as HTMLInputElement;
|
|
|
|
|
autoLaunchElement.addEventListener("change", () => {
|
|
|
|
|
fetchPost("/api/system/setAutoLaunch", {autoLaunch: autoLaunchElement.checked}, () => {
|
|
|
|
|
window.siyuan.config.system.autoLaunch = autoLaunchElement.checked;
|
2023-04-13 11:49:26 +08:00
|
|
|
ipcRenderer.send(Constants.SIYUAN_AUTO_LAUNCH, {openAtLogin: autoLaunchElement.checked});
|
2022-12-09 16:35:11 +08:00
|
|
|
});
|
|
|
|
|
});
|
2022-12-09 23:12:47 +08:00
|
|
|
/// #endif
|
2022-11-24 11:25:00 +08:00
|
|
|
about.element.querySelector("#aboutConfirm").addEventListener("click", () => {
|
|
|
|
|
const scheme = (about.element.querySelector("#aboutScheme") as HTMLInputElement).value;
|
2022-11-25 23:09:16 +08:00
|
|
|
const host = (about.element.querySelector("#aboutHost") as HTMLInputElement).value;
|
2022-11-24 11:25:00 +08:00
|
|
|
const port = (about.element.querySelector("#aboutPort") as HTMLInputElement).value;
|
|
|
|
|
fetchPost("/api/system/setNetworkProxy", {scheme, host, port}, () => {
|
2022-11-25 23:09:16 +08:00
|
|
|
window.siyuan.config.system.networkProxy.scheme = scheme;
|
|
|
|
|
window.siyuan.config.system.networkProxy.host = host;
|
|
|
|
|
window.siyuan.config.system.networkProxy.port = port;
|
|
|
|
|
setProxy();
|
2022-05-26 15:18:53 +08:00
|
|
|
});
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
};
|