${window.siyuan.languages.flashcardList}
diff --git a/app/src/mobile/settings/about.ts b/app/src/mobile/settings/about.ts
new file mode 100644
index 000000000..57ae45437
--- /dev/null
+++ b/app/src/mobile/settings/about.ts
@@ -0,0 +1,384 @@
+import {Constants} from "../../constants";
+import {setAccessAuthCode} from "../../config/util/setAccessAuthCode";
+import {Dialog} from "../../dialog";
+import {fetchPost} from "../../util/fetch";
+import {confirmDialog} from "../../dialog/confirmDialog";
+import {showMessage} from "../../dialog/message";
+import {openByMobile, writeText} from "../../protyle/util/compatibility";
+import {exitSiYuan, processSync} from "../../dialog/processSystem";
+import {pathPosix} from "../../util/pathName";
+import {openModel} from "../util/model";
+
+export const initAbout = () => {
+ if (!window.siyuan.config.localIPs || window.siyuan.config.localIPs.length === 0 ||
+ (window.siyuan.config.localIPs.length === 1 && window.siyuan.config.localIPs[0] === "")) {
+ window.siyuan.config.localIPs = ["127.0.0.1"];
+ }
+
+ openModel({
+ title: window.siyuan.languages.about,
+ icon: "iconInfo",
+ html: `
+
+ ${window.siyuan.languages.about11}
+
${window.siyuan.languages.about12}
+
+
+
+
+
+ ${window.siyuan.languages.about2}
+
+
+
${window.siyuan.languages.about3.replace("${port}", location.port)}
+
+
${window.siyuan.config.localIPs.join(" ")}
+
+
+ ${window.siyuan.languages.about5}
+
+
+
${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}
+
+
+
${window.siyuan.languages.about14}
+
+
+
+ ${window.siyuan.languages.export}
+
+
+
+
+
${window.siyuan.languages.exportDataTip}
+
+
+
+
${window.siyuan.languages.systemLogTip}
+
+
+
+ ${window.siyuan.languages.import}
+
+
+
+
+
${window.siyuan.languages.importDataTip}
+
+
+ ${window.siyuan.languages.workspaceList}
+
+
+
+
+
+
+
+
+
+

+
+
+ ${window.siyuan.languages.siyuanNote}
+
+ v${Constants.SIYUAN_VERSION}
+
+ ${window.siyuan.languages.slogan}
+
+
+
会泽百家 至公天下
+ ${window.siyuan.languages.about1}
+
`,
+ bindEvent(modelMainElement: HTMLElement) {
+ const workspaceDirElement = modelMainElement.querySelector("#workspaceDir");
+ genWorkspace(workspaceDirElement);
+ const importKeyElement = modelMainElement.querySelector("#importKey");
+ modelMainElement.addEventListener("click", (event) => {
+ let target = event.target as HTMLElement;
+ while (target && !target.isSameNode(modelMainElement)) {
+ if (target.id === "authCode") {
+ setAccessAuthCode();
+ event.preventDefault();
+ event.stopPropagation();
+ break;
+ } else if (target.id === "importKey") {
+ 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.parentElement.classList.add("fn__none");
+ importKeyElement.parentElement.nextElementSibling.classList.remove("fn__none");
+ passwordDialog.destroy();
+ });
+ });
+ event.preventDefault();
+ event.stopPropagation();
+ break;
+ } else if (target.id === "initKey") {
+ confirmDialog("🔑 " + window.siyuan.languages.genKey, window.siyuan.languages.initRepoKeyTip, () => {
+ 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");
+ });
+ });
+ event.preventDefault();
+ event.stopPropagation();
+ break;
+ } else if (target.id === "initKeyByPW") {
+ const initDialog = new Dialog({
+ title: "🔑 " + window.siyuan.languages.genKeyByPW,
+ content: `
+
+
+
+
+
+
`,
+ width: "80vw",
+ });
+ 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");
+ });
+ });
+ });
+ event.preventDefault();
+ event.stopPropagation();
+ break;
+ } else if (target.id === "copyKey") {
+ showMessage(window.siyuan.languages.copied);
+ writeText(window.siyuan.config.repo.key);
+ event.preventDefault();
+ event.stopPropagation();
+ break;
+ } else if (target.id === "removeKey") {
+ confirmDialog("⚠️ " + window.siyuan.languages.resetRepo, window.siyuan.languages.resetRepoTip, () => {
+ fetchPost("/api/repo/resetRepo", {}, () => {
+ window.siyuan.config.repo.key = "";
+ window.siyuan.config.sync.enabled = false;
+ processSync();
+ importKeyElement.parentElement.classList.remove("fn__none");
+ importKeyElement.parentElement.nextElementSibling.classList.add("fn__none");
+ });
+ });
+ event.preventDefault();
+ event.stopPropagation();
+ break;
+ } else if (target.id === "token") {
+ showMessage(window.siyuan.languages.copied);
+ writeText(window.siyuan.config.api.token);
+ event.preventDefault();
+ event.stopPropagation();
+ break;
+ } else if (target.id === "exportData") {
+ fetchPost("/api/export/exportData", {}, response => {
+ openByMobile(response.data.zip);
+ });
+ event.preventDefault();
+ event.stopPropagation();
+ break;
+ } else if (target.id === "exportLog") {
+ fetchPost("/api/system/exportLog", {}, (response) => {
+ openByMobile(response.data.zip);
+ });
+ event.preventDefault();
+ event.stopPropagation();
+ break;
+ } else if (target.id === "openWorkspace") {
+ fetchPost("/api/system/getMobileWorkspaces", {}, (response) => {
+ let selectHTML = "";
+ response.data.forEach((item: string, index: number) => {
+ selectHTML += `
`;
+ });
+ const openWorkspaceDialog = new Dialog({
+ title: window.siyuan.languages.openBy,
+ content: `
+
+
+
+
+
+
`,
+ width: "80vw",
+ });
+ const btnsElement = openWorkspaceDialog.element.querySelectorAll(".b3-button");
+ btnsElement[0].addEventListener("click", () => {
+ openWorkspaceDialog.destroy();
+ });
+ btnsElement[1].addEventListener("click", () => {
+ const openPath = openWorkspaceDialog.element.querySelector("select").value;
+ if (openPath === window.siyuan.config.system.workspaceDir) {
+ openWorkspaceDialog.destroy();
+ return;
+ }
+ confirmDialog(window.siyuan.languages.confirm, `${pathPosix().basename(window.siyuan.config.system.workspaceDir)} -> ${pathPosix().basename(openPath)}?`, () => {
+ fetchPost("/api/system/setWorkspaceDir", {
+ path: openPath
+ }, () => {
+ exitSiYuan();
+ });
+ });
+ });
+ });
+ event.preventDefault();
+ event.stopPropagation();
+ break;
+ } else if (target.id === "creatWorkspace") {
+ const createWorkspaceDialog = new Dialog({
+ title: window.siyuan.languages.new,
+ content: `
+
+
+
+
+
+
`,
+ width: "80vw",
+ });
+ const inputElement = createWorkspaceDialog.element.querySelector("input");
+ inputElement.focus();
+ const btnsElement = createWorkspaceDialog.element.querySelectorAll(".b3-button");
+ btnsElement[0].addEventListener("click", () => {
+ createWorkspaceDialog.destroy();
+ });
+ btnsElement[1].addEventListener("click", () => {
+ fetchPost("/api/system/createWorkspaceDir", {
+ path: pathPosix().join(pathPosix().dirname(window.siyuan.config.system.workspaceDir), inputElement.value)
+ }, () => {
+ genWorkspace(workspaceDirElement);
+ createWorkspaceDialog.destroy();
+ });
+ });
+ event.preventDefault();
+ event.stopPropagation();
+ break;
+ } else if (target.getAttribute("data-type") === "remove") {
+ fetchPost("/api/system/removeWorkspaceDir", {path: target.parentElement.getAttribute("data-path")}, () => {
+ genWorkspace(workspaceDirElement);
+ });
+ event.preventDefault();
+ event.stopPropagation();
+ break;
+ } else if (target.classList.contains("b3-list-item") && !target.classList.contains("b3-list-item--focus")) {
+ confirmDialog(window.siyuan.languages.confirm, `${pathPosix().basename(window.siyuan.config.system.workspaceDir)} -> ${pathPosix().basename(target.getAttribute("data-path"))}?`, () => {
+ fetchPost("/api/system/setWorkspaceDir", {
+ path: target.getAttribute("data-path")
+ }, () => {
+ exitSiYuan();
+ });
+ });
+ event.preventDefault();
+ event.stopPropagation();
+ break;
+ }
+ target = target.parentElement;
+ }
+ });
+ modelMainElement.querySelector("#importData").addEventListener("change", (event: InputEvent & {
+ target: HTMLInputElement
+ }) => {
+ const formData = new FormData();
+ formData.append("file", event.target.files[0]);
+ fetchPost("/api/import/importData", formData);
+ });
+ const networkServeElement = modelMainElement.querySelector("#networkServe") as HTMLInputElement;
+ networkServeElement.addEventListener("change", () => {
+ fetchPost("/api/system/setNetworkServe", {networkServe: networkServeElement.checked}, () => {
+ exitSiYuan();
+ });
+ });
+ }
+ });
+};
+
+const genWorkspace = (workspaceDirElement: Element) => {
+ fetchPost("/api/system/getWorkspaces", {}, (response) => {
+ let html = "";
+ response.data.forEach((item: IWorkspace) => {
+ html += `
+ ${pathPosix().basename(item.path)}
+
+
+
+`;
+ });
+ workspaceDirElement.innerHTML = html;
+ });
+};
diff --git a/app/src/mobile/settings/account.ts b/app/src/mobile/settings/account.ts
new file mode 100644
index 000000000..6f5adff22
--- /dev/null
+++ b/app/src/mobile/settings/account.ts
@@ -0,0 +1,215 @@
+import {openModel} from "../util/model";
+import {getEventName} from "../../protyle/util/compatibility";
+import {fetchPost} from "../../util/fetch";
+import {closePanel} from "../util/closePanel";
+import {processSync} from "../../dialog/processSystem";
+import {confirmDialog} from "../../dialog/confirmDialog";
+import {showMessage} from "../../dialog/message";
+import md5 from "blueimp-md5";
+
+export const showAccountInfo = () => {
+ let userTitlesHTML = "";
+ if (window.siyuan.user.userTitles.length > 0) {
+ userTitlesHTML = '
';
+ window.siyuan.user.userTitles.forEach((item) => {
+ userTitlesHTML += `
${item.icon} ${item.name}
`;
+ });
+ userTitlesHTML += "
";
+ }
+ openModel({
+ title: window.siyuan.languages.accountManage,
+ icon: "iconAccount",
+ html: `
+
+
+
+
+ ${userTitlesHTML}
+
+
`,
+ bindEvent(modelMainElement: HTMLElement) {
+ modelMainElement.querySelector("#logout").addEventListener(getEventName(), () => {
+ fetchPost("/api/setting/logoutCloudUser", {}, () => {
+ window.siyuan.user = null;
+ closePanel();
+ document.getElementById("menuAccount").innerHTML = ``;
+ processSync();
+ });
+ });
+ modelMainElement.querySelector("#deactivateUser").addEventListener(getEventName(), () => {
+ confirmDialog("⚠️ " + window.siyuan.languages.deactivateUser, window.siyuan.languages.deactivateUserTip, () => {
+ fetchPost("/api/account/deactivate", {}, () => {
+ window.siyuan.user = null;
+ closePanel();
+ document.getElementById("menuAccount").innerHTML = ``;
+ processSync();
+ });
+ });
+ });
+ const refreshElement = modelMainElement.querySelector("#refresh");
+ refreshElement.addEventListener("click", () => {
+ const svgElement = refreshElement.firstElementChild;
+ if (svgElement.classList.contains("fn__rotate")) {
+ return;
+ }
+ svgElement.classList.add("fn__rotate");
+ fetchPost("/api/setting/getCloudUser", {
+ token: window.siyuan.user.userToken,
+ }, response => {
+ window.siyuan.user = response.data;
+ showMessage(window.siyuan.languages.refreshUser, 3000);
+ showAccountInfo();
+ const menuAccountElement = document.getElementById("menuAccount");
+ if (window.siyuan.user) {
+ menuAccountElement.innerHTML = ``;
+ } else {
+ menuAccountElement.innerHTML = ``;
+ }
+ processSync();
+ });
+ });
+ }
+ })
+};
+
+export const login = () => {
+ openModel({
+ title: window.siyuan.languages.login,
+ icon: "iconAccount",
+ html: `
+
`,
+ bindEvent(modelMainElement: HTMLElement) {
+ const agreeLoginElement = modelMainElement.querySelector("#agreeLogin") as HTMLInputElement;
+ const userNameElement = modelMainElement.querySelector("#userName") as HTMLInputElement;
+ const userPasswordElement = modelMainElement.querySelector("#userPassword") as HTMLInputElement;
+ const captchaImgElement = modelMainElement.querySelector("#captchaImg") as HTMLInputElement;
+ const captchaElement = modelMainElement.querySelector("#captcha") as HTMLInputElement;
+ const twofactorAuthCodeElement = modelMainElement.querySelector("#twofactorAuthCode") as HTMLInputElement;
+ const loginBtnElement = modelMainElement.querySelector("#login") as HTMLButtonElement;
+ const login2BtnElement = modelMainElement.querySelector("#login2") as HTMLButtonElement;
+ userNameElement.focus();
+ let token: string;
+ let needCaptcha: string;
+ agreeLoginElement.addEventListener("click", () => {
+ if (agreeLoginElement.checked) {
+ loginBtnElement.removeAttribute("disabled");
+ } else {
+ loginBtnElement.setAttribute("disabled", "disabled");
+ }
+ });
+ captchaImgElement.addEventListener("click", () => {
+ captchaImgElement.setAttribute("src", `https://ld246.com/captcha/login?needCaptcha=${needCaptcha}&t=${new Date().getTime()}`);
+ });
+ loginBtnElement.addEventListener("click", () => {
+ fetchPost("/api/account/login", {
+ userName: userNameElement.value.replace(/(^\s*)|(\s*$)/g, ""),
+ userPassword: md5(userPasswordElement.value),
+ captcha: captchaElement.value.replace(/(^\s*)|(\s*$)/g, ""),
+ }, (data) => {
+ if (data.code === 1) {
+ showMessage(data.msg);
+ if (data.data.needCaptcha) {
+ // 验证码
+ needCaptcha = data.data.needCaptcha;
+ captchaElement.parentElement.classList.remove("fn__none");
+ captchaElement.previousElementSibling.setAttribute("src",
+ `https://ld246.com/captcha/login?needCaptcha=${data.data.needCaptcha}`);
+ captchaElement.value = "";
+ return;
+ }
+ return;
+ }
+ if (data.code === 10) {
+ // 两步验证
+ modelMainElement.querySelector("#form1").classList.add("fn__none");
+ modelMainElement.querySelector("#form2").classList.remove("fn__none");
+ twofactorAuthCodeElement.focus();
+ token = data.data.token;
+ return;
+ }
+ fetchPost("/api/setting/getCloudUser", {
+ token: data.data.token,
+ }, response => {
+ window.siyuan.user = response.data;
+ closePanel();
+ document.getElementById("menuAccount").innerHTML = `
+`;
+ processSync();
+ });
+ });
+ });
+
+ login2BtnElement.addEventListener("click", () => {
+ fetchPost("/api/setting/login2faCloudUser", {
+ code: twofactorAuthCodeElement.value,
+ token,
+ }, faResponse => {
+ fetchPost("/api/setting/getCloudUser", {
+ token: faResponse.data.token,
+ }, response => {
+ window.siyuan.user = response.data;
+ closePanel();
+ document.getElementById("menuAccount").innerHTML = `
+`;
+ processSync();
+ });
+ });
+ });
+ }
+ });
+};
diff --git a/app/src/mobile/settings/ai.ts b/app/src/mobile/settings/ai.ts
new file mode 100644
index 000000000..5c56e5be3
--- /dev/null
+++ b/app/src/mobile/settings/ai.ts
@@ -0,0 +1,14 @@
+import {openModel} from "../util/model";
+import {ai} from "../../config/ai";
+
+export const initAI = () => {
+ openModel({
+ title: "AI",
+ icon: "iconSparkles",
+ html: ai.genHTML(),
+ bindEvent(modelMainElement: HTMLElement) {
+ ai.element = modelMainElement;
+ ai.bindEvent();
+ }
+ })
+}
diff --git a/app/src/mobile/settings/appearance.ts b/app/src/mobile/settings/appearance.ts
index f400c11cd..acded9881 100644
--- a/app/src/mobile/settings/appearance.ts
+++ b/app/src/mobile/settings/appearance.ts
@@ -2,12 +2,13 @@ import {fetchPost} from "../../util/fetch";
import {setInlineStyle} from "../../util/assets";
import {genOptions} from "../../util/genOptions";
import {reloadProtyle} from "../../protyle/util/reload";
+import {openModel} from "../util/model";
-export const initAppearance = (modelElement: HTMLElement, modelMainElement: HTMLElement) => {
- modelElement.style.top = "0";
- modelElement.querySelector(".toolbar__icon").innerHTML = '
';
- modelElement.querySelector(".toolbar__text").textContent = window.siyuan.languages.appearance;
- modelMainElement.innerHTML = `
+export const initAppearance = () => {
+ openModel({
+ title: window.siyuan.languages.appearance,
+ icon:"iconTheme",
+ html: `
${window.siyuan.languages.appearance4}
`;
- modelMainElement.querySelector(".b3-slider").addEventListener("input", (event: InputEvent & { target: HTMLInputElement }) => {
- modelMainElement.querySelector("#fontSize").textContent = event.target.value + "px";
- window.siyuan.config.editor.fontSize = parseInt(event.target.value);
- fetchPost("/api/setting/setEditor", window.siyuan.config.editor, (response) => {
- window.siyuan.config.editor = response.data;
- reloadProtyle(window.siyuan.mobile.editor.protyle);
- setInlineStyle();
- });
- });
- modelMainElement.querySelectorAll("select").forEach(item => {
- item.addEventListener("change", () => {
- const modeElementValue = parseInt((modelMainElement.querySelector("#mode") as HTMLSelectElement).value);
- fetchPost("/api/setting/setAppearance", Object.assign({}, window.siyuan.config.appearance, {
- icon: (modelMainElement.querySelector("#icon") as HTMLSelectElement).value,
- mode: modeElementValue === 2 ? window.siyuan.config.appearance.mode : modeElementValue,
- modeOS: modeElementValue === 2,
- themeDark: (modelMainElement.querySelector("#themeDark") as HTMLSelectElement).value,
- themeLight: (modelMainElement.querySelector("#themeLight") as HTMLSelectElement).value,
- lang: (modelMainElement.querySelector("#lang") as HTMLSelectElement).value,
- }), () => {
- window.location.reload();
+
`,
+ bindEvent(modelMainElement: HTMLElement) {
+ modelMainElement.querySelector(".b3-slider").addEventListener("input", (event: InputEvent & {
+ target: HTMLInputElement
+ }) => {
+ modelMainElement.querySelector("#fontSize").textContent = event.target.value + "px";
+ window.siyuan.config.editor.fontSize = parseInt(event.target.value);
+ fetchPost("/api/setting/setEditor", window.siyuan.config.editor, (response) => {
+ window.siyuan.config.editor = response.data;
+ reloadProtyle(window.siyuan.mobile.editor.protyle);
+ setInlineStyle();
+ });
});
- });
+ modelMainElement.querySelectorAll("select").forEach(item => {
+ item.addEventListener("change", () => {
+ const modeElementValue = parseInt((modelMainElement.querySelector("#mode") as HTMLSelectElement).value);
+ fetchPost("/api/setting/setAppearance", Object.assign({}, window.siyuan.config.appearance, {
+ icon: (modelMainElement.querySelector("#icon") as HTMLSelectElement).value,
+ mode: modeElementValue === 2 ? window.siyuan.config.appearance.mode : modeElementValue,
+ modeOS: modeElementValue === 2,
+ themeDark: (modelMainElement.querySelector("#themeDark") as HTMLSelectElement).value,
+ themeLight: (modelMainElement.querySelector("#themeLight") as HTMLSelectElement).value,
+ lang: (modelMainElement.querySelector("#lang") as HTMLSelectElement).value,
+ }), () => {
+ window.location.reload();
+ });
+ });
+ });
+ }
});
};
diff --git a/app/src/mobile/settings/riffCard.ts b/app/src/mobile/settings/riffCard.ts
new file mode 100644
index 000000000..13679101e
--- /dev/null
+++ b/app/src/mobile/settings/riffCard.ts
@@ -0,0 +1,14 @@
+import {openModel} from "../util/model";
+import {flashcard} from "../../config/flashcard";
+
+export const initRiffCard = () => {
+ openModel({
+ title: window.siyuan.languages.riffCard,
+ icon: "iconRiffCard",
+ html: flashcard.genHTML(),
+ bindEvent(modelMainElement: HTMLElement) {
+ flashcard.element = modelMainElement;
+ flashcard.bindEvent();
+ }
+ });
+};
diff --git a/app/src/mobile/util/MobileTags.ts b/app/src/mobile/util/MobileTags.ts
index 222ce3685..81a9aba0f 100644
--- a/app/src/mobile/util/MobileTags.ts
+++ b/app/src/mobile/util/MobileTags.ts
@@ -67,7 +67,7 @@ export class MobileTags {
} else {
const modelElement = document.getElementById("model");
const modelMainElement = document.getElementById("modelMain");
- popSearch(modelElement, modelMainElement);
+ popSearch();
(document.getElementById("toolbarSearch") as HTMLInputElement).value = `#${element.getAttribute("data-label")}#`;
toolbarSearchEvent();
}
diff --git a/app/src/mobile/util/menu.ts b/app/src/mobile/util/menu.ts
index 32ab38b08..c6aae01df 100644
--- a/app/src/mobile/util/menu.ts
+++ b/app/src/mobile/util/menu.ts
@@ -1,118 +1,19 @@
-import {fetchPost} from "../../util/fetch";
-import {getEventName, openByMobile, writeText} from "../../protyle/util/compatibility";
import {popSearch} from "./search";
import {initAppearance} from "../settings/appearance";
import {closePanel} from "./closePanel";
-import {Constants} from "../../constants";
-import {setAccessAuthCode} from "../../config/util/setAccessAuthCode";
import {mountHelp, newDailyNote, newNotebook} from "../../util/mount";
import {repos} from "../../config/repos";
-import * as md5 from "blueimp-md5";
-import {showMessage} from "../../dialog/message";
import {exitSiYuan, lockScreen, processSync} from "../../dialog/processSystem";
-import {confirmDialog} from "../../dialog/confirmDialog";
import {openHistory} from "../../history/history";
-import {Dialog} from "../../dialog";
import {syncGuide} from "../../sync/syncGuide";
import {openCard} from "../../card/openCard";
-import {pathPosix} from "../../util/pathName";
import {activeBlur, hideKeyboardToolbar} from "./keyboardToolbar";
+import {initAI} from "../settings/ai";
+import {initRiffCard} from "../settings/riffCard";
+import {login, showAccountInfo} from "../settings/account";
+import {openModel} from "./model";
+import {initAbout} from "../settings/about";
-const showAccountInfo = (modelElement: HTMLElement, modelMainElement: Element) => {
- let userTitlesHTML = "";
- if (window.siyuan.user.userTitles.length > 0) {
- userTitlesHTML = '
';
- window.siyuan.user.userTitles.forEach((item) => {
- userTitlesHTML += `
${item.icon} ${item.name}
`;
- });
- userTitlesHTML += "
";
- }
- modelElement.style.top = "0";
- modelElement.querySelector(".toolbar__icon").innerHTML = '
';
- modelElement.querySelector(".toolbar__text").textContent = window.siyuan.languages.accountManage;
- modelMainElement.innerHTML = `
-
-
-
-
- ${userTitlesHTML}
-
-
`;
-
- modelMainElement.querySelector("#logout").addEventListener(getEventName(), () => {
- fetchPost("/api/setting/logoutCloudUser", {}, () => {
- window.siyuan.user = null;
- closePanel();
- document.getElementById("menuAccount").innerHTML = ``;
- processSync();
- });
- });
- modelMainElement.querySelector("#deactivateUser").addEventListener(getEventName(), () => {
- confirmDialog("⚠️ " + window.siyuan.languages.deactivateUser, window.siyuan.languages.deactivateUserTip, () => {
- fetchPost("/api/account/deactivate", {}, () => {
- window.siyuan.user = null;
- closePanel();
- document.getElementById("menuAccount").innerHTML = ``;
- processSync();
- });
- });
- });
- const refreshElement = modelMainElement.querySelector("#refresh");
- refreshElement.addEventListener("click", () => {
- const svgElement = refreshElement.firstElementChild;
- if (svgElement.classList.contains("fn__rotate")) {
- return;
- }
- svgElement.classList.add("fn__rotate");
- fetchPost("/api/setting/getCloudUser", {
- token: window.siyuan.user.userToken,
- }, response => {
- window.siyuan.user = response.data;
- showMessage(window.siyuan.languages.refreshUser, 3000);
- showAccountInfo(modelElement, modelMainElement);
- const menuAccountElement = document.getElementById("menuAccount");
- if (window.siyuan.user) {
- menuAccountElement.innerHTML = ``;
- } else {
- menuAccountElement.innerHTML = ``;
- }
- processSync();
- });
- });
-};
-
-const genWorkspace = (workspaceDirElement: Element) => {
- fetchPost("/api/system/getWorkspaces", {}, (response) => {
- let html = "";
- response.data.forEach((item: IWorkspace) => {
- html += `
- ${pathPosix().basename(item.path)}
-
-
-
-`;
- });
- workspaceDirElement.innerHTML = html;
- });
-};
export const popMenu = () => {
activeBlur();
hideKeyboardToolbar();
@@ -161,6 +62,12 @@ ${accountHTML}
+
+
@@ -182,10 +89,8 @@ ${accountHTML}